.NET Project with multiple dll. How to load them in a correct way?

.NET Project with multiple dll. How to load them in a correct way?

gary.wuEQ8E4
Contributor Contributor
1,141 Views
2 Replies
Message 1 of 3

.NET Project with multiple dll. How to load them in a correct way?

gary.wuEQ8E4
Contributor
Contributor

Hey... I have a .NET solution that contains multiple projects since the application is a bit complex so I want to separate them. However, I am facing a problem is that how to load these assemblies in a right way.

 

So I have an main assembly, let's call it "Assembly A" and it refers to "Assembly B" and "Assembly C" and they are all store in the same directly. In the "Assembly A", it has an entry class implements `IExtensionApplication`. I open the AutoCAD and use command `NETLOAD`, select A, which loads correctly. 

 

However, if I move "Assembly B" and "C" into a different folder and try to `NETLOAD` the assembly A. But assembly won't even execute. (I put a break point at `Initialize()` method but it never hit). I was wondering to `Load()` the reference assembly when it execute `Initialize()` method but since it never gets to that point, I won't be able to load reference assembly B and C.

 

So what's the best way to load a .net project that contains multiple dll? Why it doesn't work if I put reference assembly into different directory?

 

0 Likes
Accepted solutions (1)
1,142 Views
2 Replies
Replies (2)
Message 2 of 3

Ed__Jobe
Mentor
Mentor

When you build your solution, VS will put the compiled dll's into the \Bin\Release folder. Just copy all 3 dll's to the same deployment folder. When A loads, it will find the other 2 dll's and load them automatically. You don't manually load referenced files.

Ed


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.
How to post your code.

EESignature

0 Likes
Message 3 of 3

Norman_Yuan
Mentor
Mentor
Accepted solution

Firstly, you want ask yourself that why to place referenced DLL s in different folder? 

 

If for some reasons you have to do it (for example, those shared DLLS may be shared by many other applications other than AutoCAD add-ins, then you may consider to digitally sign these assemblies and place them into GAC (Global Assembly Caches).

 

This document would help you to understand how .NET framework runtime locate required assemblies:

https://learn.microsoft.com/en-us/dotnet/framework/deployment/how-the-runtime-locates-assemblies 

 

 

Norman Yuan

Drive CAD With Code

EESignature