IExternalCommandAvailability weakpointer error

IExternalCommandAvailability weakpointer error

Anonymous
Not applicable
1,135 Views
3 Replies
Message 1 of 4

IExternalCommandAvailability weakpointer error

Anonymous
Not applicable

Hello! Sometimes an error occurs while initializing command availabilty in the object of class which implements IExternalCommandAvailability interface (see attachments). How can this be prevented? ProjectSettingsDto is custom settings class which is used to load settings saved in the parameters of zero point of the model.

0 Likes
1,136 Views
3 Replies
Replies (3)
Message 2 of 4

jeremytammik
Autodesk
Autodesk

What do you mean by 'sometimes'?

 

Do you have a quantum computer that works statistically? That must be cool.

 

Please provide a minimal reproducible case that demonstrates the problematic behaviour all the time:

 

https://thebuildingcoder.typepad.com/blog/about-the-author.html#1b

 



Jeremy Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder

0 Likes
Message 3 of 4

mhannonQ65N2
Collaborator
Collaborator

You are likely storing a document that is no longer loaded. The Settings method appears to be indirectly access a dictionary that uses Document as its key. When the dictionary tries to see if it has the requested document, it calls the Document.Equals() method on an invalid document.

 

One way to solve this is to simplify not store Document objects that have been unloaded. Another potential solution would be to provide the dictionary with an equality checker that first checks the Document.IsValidObject property before calling Document.Equals().

Message 4 of 4

Anonymous
Not applicable

Thank you for your reply, I will test your method to avoid this error and come back with results.

0 Likes