Ilogic dll Error Message

Ilogic dll Error Message

johnster100
Collaborator Collaborator
935 Views
7 Replies
Message 1 of 8

Ilogic dll Error Message

johnster100
Collaborator
Collaborator

Hi there,

I've made a lot of ilogic rules which use dlls to look up text files for ratio values. The dlls all work fine and are stored in "C:\Program Files\Autodesk\Inventor 2012\Bin\iLogicAdd".

 

To add the dll I use the following method:

 

AddReference "Core_xxxx.dll" Dim dll as New Core_xxxx.Core_xxxx_Class

 

If, however, someone opens the file on a computer which does not have the dlls they get an error message saying

 

" Error on Line 0 : could not find library 'Core_xxxxxxx.dll'

  Error on Line 0 : compiler initialization failed unexpectedly: 0x80070002 "

 

Is there any way I can catch or silence this error? I would like to be able to open the model on computers which do not contain the dlls without the error message apprearing.

 

thanks,

John

936 Views
7 Replies
Replies (7)
Message 2 of 8

adam.nagy
Autodesk Support
Autodesk Support

Hi,

 

Did you try to put that section inside a Try/Catch block?

 

Cheers,



Adam Nagy
Autodesk Platform Services
0 Likes
Message 3 of 8

johnster100
Collaborator
Collaborator

Tried that, no luck unfortunately 😞

0 Likes
Message 4 of 8

MjDeck
Autodesk
Autodesk

John,

 

 Sorry, there's no way to suppress that error message.

 

 Here's a workaround: the dll doesn't have to be in the application directory. iLogic will be able to find it if it is in the same directory as the document, or in the project workspace directory. So when you copy the file to another computer, copy the dll's along with it.

 

 Another option would be to suppress the rule.


Mike Deck
Software Developer
Autodesk, Inc.

0 Likes
Message 5 of 8

Bram_Baars
Enthusiast
Enthusiast

I'm looking for the same thing. We have an iLogic which uses webservice dll's, but on pc's without that dll I want the code to run as well. (On the PC of an engineer at an external engineering company)
Sadly I cannot seem to escape the declaration in the header.

0 Likes
Message 6 of 8

MjDeck
Autodesk
Autodesk

@Bram_Baars , you can create a separate rule to run the original. In the new rule, check to see if the WebServices DLL is already loaded in the process. Here's sample code:

Imports System.Reflection
Sub Main
	If AssemblyIsLoaded("Autodesk.Connectivity.WebServices") Then
		iLogicVb.RunRule("RequiresWebServices")
	End If
End Sub

Function AssemblyIsLoaded(name As String) As Boolean
	Dim assemblies As Assembly() = AppDomain.CurrentDomain.GetAssemblies()

	For Each asm As Assembly In assemblies
		If asm.FullName.StartsWith(name) Then
			Return True
		End If
	Next
	Return False
End Function

 

Then you can set this rule to run on an event, instead of the original rule.
(Replace "RequiresWebServices" with the name of the original rule.)

This should work for the WebServices DLL because it's very likely that the Vault add-in will have loaded it before your rule runs.
Alternatively, you could use System.IO.File.Exists (and possibly other System.IO functions) to see if the DLL is available.


Mike Deck
Software Developer
Autodesk, Inc.

0 Likes
Message 7 of 8

Bram_Baars
Enthusiast
Enthusiast

@MjDeck Thanks, those sound like good suggestions, we'll start fiddling with it!

0 Likes
Message 8 of 8

Bram_Baars
Enthusiast
Enthusiast

Works like a charm!

0 Likes