- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
VB.net Addin unload itself?
I would like a DLL addin to be able to unload it self. I found some code that works running it from VBA but not from inside my addin. Is is possible for an addin to unload itself?
ThisApplication.ApplicationAddIns.ItemById("{idstringhere]").Deactivate()
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello pball,
@pball wrote:I would like a DLL addin to be able to unload it self. I found some code that works running it from VBA but not from inside my addin. Is is possible for an addin to unload itself?
ThisApplication.ApplicationAddIns.ItemById("{idstringhere]").Deactivate()
I got same result with c# now. It seems that the add-ins cannot be disabled by themselves.
Note that the add-in is only disabled by Deactivate() and the dll isn't unloaded.
(To unload the dll, you must restart Inventor.)
=====
Hideo Yamada
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi,
Create a new add in to unload the add in you want to unload!
Regards,
Arthur Knoors
Autodesk Affiliations:
Autodesk Software:Inventor Professional 2025 | Vault Professional 2024 | Autocad Mechanical 2024
Programming Skills:Vba | Vb.net (Add ins Vault / Inventor, Applications) | I-logic
Programming Examples:Drawing List!|Toggle Drawing Sheet!|Workplane Resize!|Drawing View Locker!|Multi Sheet to Mono Sheet!|Drawing Weld Symbols!|Drawing View Label Align!|Open From Balloon!|Model State Lock!
Posts and Ideas:Dimension Component!|Partlist Export!|Derive I-properties!|Vault Prompts Via API!|Vault Handbook/Manual!|Drawing Toggle Sheets!|Vault Defer Update!
! For administrative reasons, please mark a "Solution as solved" when the issue is solved !
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi,
@jjstr8 wrote:I am able to self-deactivate in C# in Inventor 2017.
I tried with Inventor 2020 and got an exception.
Where did you do "Deactivate()"? I did at "OnExecute()".
=====
Freeradical
Hideo Yamada
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
It was in an OnExecute method for one of my command's button definition.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi,
@jjstr8 wrote:If that's exactly what you're using, the ']' at the end should be a '}'
You are right!
I could deactive with Inventor 2020.
(I had specified the internal name of AddIn to the argument of ItemById at my test.
We have to use clsid that described in the manifest.)
=====
Hideo Yamada
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi,
@GeorgK wrote:please could you share your code.
The codes and complied dll are attached to this post.
Please try this.
=====
Hideo Yamada
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Sorry, I tried with C#.
I'll try with VB.net if you need. (Please let me know if so.)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
@jjstr8I checked and that typo is just in my post, the addin ID is properly formatted in my real code.
Long story short I noticed calling the sub where I try to deactivate the addin from the main Activate sub in the addin failed. While calling the sub after Inventor was started up worked. So I played around a bit and found the application events on ready event. Calling my sub from there works just fine. The only difference is instead of happening while the splash screen is up it happens after Inventor has loaded which isn't an issue for me.
Private Sub m_appevents_onready() Handles m_ApplicationEvents.OnReady
Log_User() 'This sub has the deactivate line in it
End Sub
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi,
I didn't know the event 'OnReady'. This seems useful.
If you can, could you tell me the scenario why Deactivate at Activate?
Are you trying to cancel activation?
=====
Hideo Yamada
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
People around here do not like to update the company Addin I manage and I haven't found a simple way to have it auto update. So I finally got around to adding a nag if the addin is out of date. Figured I could also have the addin stop working so people would be more likely to update it. Sadly that nag and time bomb feature will only start working with the next update, assuming people update to this version lol.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi,
@pball wrote:People around here do not like to update the company Addin I manage and I haven't found a simple way to have it auto update. So I finally got around to adding a nag if the addin is out of date. Figured I could also have the addin stop working so people would be more likely to update it. Sadly that nag and time bomb feature will only start working with the next update, assuming people update to this version lol.
As far as I know, Inventor will not mark as "Loaded" if an exception is thrown at the add-in's Activate() to Inventor.
So I think you just throw some exception in Activate() to avoid the actication.
In this case Deactivate() will not be called and so you must release the resources if you have obtained at Activate().
I think it is more friendly that the alert message will be shown when the command is executed, rather than suddenly the add-in disappears.
(When the add-in disappears, you will get many phone calls from every users!!)
And more one thing, even if the add-in has deactivated at OnReady(), users can reactivate it at Addin Manager and the add-in has been marked as loaded (activated).
In this scenario user can execute the command and the trouble may cause if you don't initialize the add-in completely if it is expired.
=====
Hideo Yamada
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
The user will get a message before the addin is deactivated. There are also only 8 users here and most if not all of them will immediately ask me if something doesn't work. Which will end up with me telling them to upgrade or stop complaining. So I'm not concerned about users re-enabling the addin or getting angry phone calls. If I was supporting a large group with this addin, I would invest the time into a better more seamless solution like automagical upgrading.
This addin is just something I made for personal use and shared with everyone because I'm nice. So I don't have large amounts of time to invest as it isn't explicitly something I'm paid or told to do.