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
Hi,
Did you try to put that section inside a Try/Catch block?
Cheers,
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.
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.
@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.