Add-in automatically unloads on some computers

Add-in automatically unloads on some computers

TA.Fehr
Advocate Advocate
3,642 Views
21 Replies
Message 1 of 22

Add-in automatically unloads on some computers

TA.Fehr
Advocate
Advocate

I've written an add-in that is currently in the appstore, but with the last version it isn't doesn't stay loaded on some computers. It works on my computer, but the appstore testers were noting that it wasn't staying loaded on their computers.

If I load it on a computer that has never installed the add-in it opens the add-in manager and the user can enable it and everything works fine. But on other computers that had previous versions, the add-in manager unloads the add-in as soon as inventor opens up, or the add-in manager is closed.

 

I'm sure it has something to do with the add-in registry within Inventor itself because I can copy the working files from my computer to the not working computer and nothing changes. But I can copy the files on the not working computer to mine and it loads correctly.

Is there a way to clear the class-id or whatever references in the Inventor application? Or would this be some different problem?

0 Likes
Accepted solutions (2)
3,643 Views
21 Replies
Replies (21)
Message 2 of 22

HideoYamada
Advisor
Advisor

Hello,

 

Isn't StandardAddInServer.Activate() throwing an exception?

Activate() is called when a load check box in the Add-In Manager is checked. If any exception is thrown from Active(), loading sequence fails and you will see check is off when reopen the Add-In Manager.

 

=====

Freeradical

 Hideo Yamada

 

 

=====
Freeradical
 Hideo Yamada
https://www.freeradical.jp
0 Likes
Message 3 of 22

TA.Fehr
Advocate
Advocate
I don't have visual studio installed on the other machines but I will check
that out. And report back

I thought I could just give it a new guid, so today I tried recompiling and
running it but that yielded the same result.
0 Likes
Message 4 of 22

HideoYamada
Advisor
Advisor

Hello,

 

Try this for now. (This is just for determining problem., not for permanent solution.)

You don't need install VS to the other computers.

 

public void Activate(ApplicationAddInSite addInSiteObject, bool firstTime)
{
try {
// do something
// do something
// do something
} catch {}
}

 

=====

Freeraidical

 Hideo Yamada

 

 

=====
Freeradical
 Hideo Yamada
https://www.freeradical.jp
0 Likes
Message 5 of 22

CAD-e-Shack
Enthusiast
Enthusiast

Thanks,

where would I put this? I am completely self taught and have no idea how I would implement code without running it through VS.

0 Likes
Message 6 of 22

HideoYamada
Advisor
Advisor

Hello,

 

Put the exception guard into Active() of your AddIn.

This is done at the PC that VS is installed, and then copy the AddIn maked to the other PC.

 

Since Activate() doesn't throw any exception, so you can enable the AddIn at AddIn Manager.

(If the problem is existing in Active(). )

 

=====

Freeradical

 Hideo Yamada

 

=====
Freeradical
 Hideo Yamada
https://www.freeradical.jp
0 Likes
Message 7 of 22

TA.Fehr
Advocate
Advocate

Ok, I see what you're saying.

Sorry I logged in with my other account, so that question was from me. 

0 Likes
Message 8 of 22

frederic.vandenplas
Collaborator
Collaborator

do you use the same GUID?

If you think this answer fullfilled your needs, improved your knowledge or leads to a solution,
please feel free to "kudos"
0 Likes
Message 9 of 22

TA.Fehr
Advocate
Advocate

@HideoYamada I ran a test with your suggested inputs and it yielded no results. The "Activate" command was not firing at all on the other computer. The Add-in shows in the list, so I don't know how it gets there without running through the activate command.

@frederic.vandenplas  I had recompiled it with a different GUID to force Inventor to re-add it to the list of add-ins but it yielded the same results.

0 Likes
Message 10 of 22

HideoYamada
Advisor
Advisor

Hello,

 

Please let me check.

> I ran a test with your suggested inputs and it yielded no results.

> The "Activate" command was not firing at all on the other computer.

> The Add-in shows in the list, ....

 

Does this mean :

* The Add-in name was listed in the Add-in manager.

* You checked the load checkbox, but check was cleared when re-open the Add-in manager.

OK? (In other words, has nothing changed?)

 

=====

Freeradical

 Hideo Yamada

 

=====
Freeradical
 Hideo Yamada
https://www.freeradical.jp
0 Likes
Message 11 of 22

HideoYamada
Advisor
Advisor

Check the constructor and Activate are called and done correctly.

 

 

public StandardAddInServer()
{
    MessageBox.Show("Constructor Start");
    //
    // something to do.
    //
    MessageBox.Show("Constructor End");
}

public void Activate(Inventor.ApplicationAddInSite addInSiteObject, bool firstTime)
{
    MessageBox.Show("Activate Start");
    //
    // something to do.
    //
    MessageBox.Show("Activate End");
}

 

And check these items don't throw the exception also.

* Member objects of StandardAddInServer()

* Static objects in any class.

 

=====

Freeradical

 Hideo Yamada

 

 

=====
Freeradical
 Hideo Yamada
https://www.freeradical.jp
0 Likes
Message 12 of 22

TA.Fehr
Advocate
Advocate

I implemented a messagebox notification which worked on my computer when starting inventor so I know the triggers and notifications are correct, but on the other computer there was no messages.

When I open the add-in manager on the computer that doesn't work, the add-in shows as "Automatic/Unloaded". The Properties show the correct destination of the .dll. Clicking the "load" checkbox still doesn't throw the notification message.

0 Likes
Message 13 of 22

HideoYamada
Advisor
Advisor
Accepted solution

Hello,

 

Is .NET Framework that you selected in VS installed?

Do all of reference Assemblies or COM objects exist?

 

If there is no problem, let's try the primitive method.

1) Create a copy of the VS Project. (Or backup the VS Project.)

2) Remove all classes and members except those required for Inventor (such as Activate, Deactivate, etc...)

The rest in the project will be almost the same as the project just created from the template.

If this code run, the problem is existing in the code you removed at 2).

 

=====

Freeradical

 Hideo Yamada

 

=====
Freeradical
 Hideo Yamada
https://www.freeradical.jp
Message 14 of 22

JelteDeJong
Mentor
Mentor
Accepted solution

i did have sort of simular problem with one of mine addons. I found that the problem was, that i compiled my addon for a diferent inventor version/update than my users where using. you could check the version/update your users have installed. if that is not the same as you are using try installing the same update.

 

If that is the problem try to reference a Autodesk.Inventor.Interop.dll that is on all computers. you can see in visual studio the version your are referencing.

dllVersion.png

 

 

Jelte de Jong
Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.

EESignature


Blog: hjalte.nl - github.com

Message 15 of 22

TA.Fehr
Advocate
Advocate

Not sure who to thank, but it appears as though the issue is resolved.

I used Resharper to remove all the unused references as suggested by @HideoYamada, and I also updated the Autodesk.Inventor.nterop.dll as suggested by @JelteDeJong . And now the app shows up correctly on the problem computer.

 

Many thanks.

0 Likes
Message 16 of 22

COLINBRUSCHI
Enthusiast
Enthusiast

Old post, but had the same issue recently. Visual studio by default doesn't copy Autodesk.Inventor.Interop.dll to the build location, presumably the copy in bin is then referenced. Setting the 'copy local' to true resolved this for me.

 

COLINBRUSCHI_0-1603801407104.png

 

Message 17 of 22

phlyx
Collaborator
Collaborator

I have to thank @TA.Fehr and anyone they were thanking.  We had an add-in that would only load on 'some' machines.  Was going cRaZy trying to figure things out and stumbled across this thread.   From the solution above we tried the one part referring to Autodesk.Inventor.nterop.dll.  We copied that file from a workstation that worked to ones that didn't and all of a sudden, ALL of them work.  THANKS TO ALL!!!!  

 

Oh yeah, can't just copy that.  Had to rename the extension, copy it in to latest C:\Windows\Microsoft.NET\assembly\GAC_MSIL\Autodesk.Inventor.Interop\ folder, rename the existing dll and then rename the new file to the correct dll name, then reboot.  Had to get around the Windoze police. 

Message 18 of 22

c.kawabata
Explorer
Explorer

Hello @phlyx ,

 

I am also struggling with my add-in not loading for the client but loading for all of our test computers. 

 

are you saying that just doing what @COLINBRUSCHI did is not enough? (setting Autodesk.Inventor.nterop.dll  copy local to true)

 

What exactly would I have to do beyond that? Unfortunately I do not have access to the machine unable to load our add-in so testing  is trouble some.

 

"Oh yeah, can't just copy that.  Had to rename the extension, copy it in to latest C:\Windows\Microsoft.NET\assembly\GAC_MSIL\Autodesk.Inventor.Interop\ folder, rename the existing dll and then rename the new file to the correct dll name, then reboot.  Had to get around the Windoze police. " -> would I need to do this on every computer? which extension should I rename? Rename my dll? What's the correct dll name?

Thanks for the help!

0 Likes
Message 19 of 22

HideoYamada
Advisor
Advisor

Hello,

 

The problem may cause by the version incompatibilities of Autodesk.Inventor.Interop and/or .NET Framework.

 

Check the versions in your VisualStudio project and make sure the target PC supports these versions.

 

HideoYamada_0-1670864710733.png

 

=====
Freeradical
 Hideo Yamada
https://www.freeradical.jp
Message 20 of 22

HideoYamada
Advisor
Advisor

The picture in my previous post says that my add-in "SketchPlus" supports .NET Framework 4.7.2 or higher and Inventor 2019.0.0.0 or higher.

 

=====
Freeradical
 Hideo Yamada
https://www.freeradical.jp