11-26-2024
01:34 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
11-26-2024
01:34 AM
Hmm, strange.
I followed your explanation to the letter. Running the iLogic-rule results in a System.NullReferenceException: 'Object variable or With block variable not set.' when getting the .MyVariable (at line 4 in your example)...
In de 'Active'-sub routine I then added a Try-block with 3 messageboxes to follow the progress.
MessageBox.Show("Started")
Try
' initialize the MyVariableObject class
_myVariableObject = New MyVariableObject()
_myVariableObject.MyVariable = "Test"
Catch ex As Exception
' Show a message if any thing goes wrong.
MessageBox.Show(ex.Message)
End Try
MessageBox.Show("Succeeded?")No exception thrown. The other two messages are shown.
I can get the name of the AddIn. It is also activated (of course, because it shows two Message Boxes)
If I set the last line of the iLogic-rule example in an if-block it goes for the 'else'...
Dim addIn As ApplicationAddIn = ThisApplication.ApplicationAddIns.ItemById("{bec4b251-a925-4ac7-828b-0bd050b2b6de}")
Logger.Info(addIn.DisplayName)
Dim myVariableObject As Object = addIn.Automation
If Not (myVariableObject Is Nothing) Then
Logger.Info(myVariableObject.MyVariable)
Else
Logger.Info("Apparently the object remains Nothing")
End If
What could go wrong in this very simple code?
Using Autodesk Inventor 2023.5.1. Microsoft Visual Studio 2022. Class Library with .NET Framework 4.8.1
René van der Starre