Where to place dependent DLL files for Add-in?

Where to place dependent DLL files for Add-in?

vijay.shindeSLE5F
Enthusiast Enthusiast
781 Views
3 Replies
Message 1 of 4

Where to place dependent DLL files for Add-in?

vijay.shindeSLE5F
Enthusiast
Enthusiast

Hi BrianEkinsMattWynn,

 

We have developed an add-in for Fusion 360 which has dependency on some third party DLL. So, now we have main add-in DLL and one more DLL file for dependent library.

 

When we placed both add-in and third party dll in "%appdata%\Autodesk\Autodesk Fusion 360\API\AddIns\MyAddin" folder then we are receiving below error while loading our add-in.
Add-in load issue.png

We tired placing third party DLL under resources folder. In this case we didn't observed this issue, but add-in fails to load.

 

Is there any way we can mention dependent DLL and it's path within Manifest file?

 

Can you please help us here with placing dependent DLL at correct location to load add-in successfully.

 

Thanks in advance.

0 Likes
Accepted solutions (1)
782 Views
3 Replies
Replies (3)
Message 2 of 4

vijay.shindeSLE5F
Enthusiast
Enthusiast

Hi boopathi.sivakumar,

 

Can you help us with the issue.

0 Likes
Message 3 of 4

chris.monachanZWSCF
Enthusiast
Enthusiast
Accepted solution

You didn't mention if you were using C++, but I'll assume you are. If you are then the default path it will search is the Fusion360.exe directory (and a bunch of others). 

There are a few ways round this in code, assuming you're using late binding to bring in your 3rd party DLL? If so specifying the 3rd party DLL to be Delay Loaded will give you a chance to change where the DLL is searched in your code for before it is actually loaded.

You could in theory LoadLibary() it yourself with the correct path and when it goes to look for it later when required, it should find the in-memory version first. There might be security updates which means this old method doesnt work anymore

The way I've done it is to specify it as Delay Loaded then at the start of my add-in I get the path to my add-in DLL and carefully add it to the overall DLL search path using SetDllDirectory() a Win32 function.

You can use GetModuleHandleEx(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS | GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT, (LPCWSTR)&Anyfunctioninyourdll, &hm) to get a module handle which you can then pass into GetModuleFileName() to get the name & path of your addin dll file, which you can then use to alter the path for DLL lookup.

Hope this helps


Message 4 of 4

vijay.shindeSLE5F
Enthusiast
Enthusiast

Hi chris.monachanZWSCF

 

Thanks for your reply.

 

Yes, add-in is developed using C++. We have placed third part DLL in Fusion360.exe directory. We wrote a PowerShell script to copy DLL to Fusion directory while add-in is installed.

 

Now it's add-in is loaded successfully.

0 Likes