Revit API Forum
Welcome to Autodesk’s Revit API Forums. Share your knowledge, ask questions, and explore popular Revit API topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Confusing assembly location when use one assembly for two Revit-Addin projects

1 REPLY 1
Reply
Message 1 of 2
vominhdoan90
392 Views, 1 Reply

Confusing assembly location when use one assembly for two Revit-Addin projects

Hi everybody,

I create a project as library to make custom classes and functions, then I use this library reference to two Revit-Addin projects.

 

Because I want to install  each project separately so each project should contain their own library assembly in their setup folder. In this way, I can easily manage every single project without caring about others.

 

I use method Assembly.GetExecutingAssembly() to check where the library.dll is referring to. When I first run the project 1, I get the correct assembly path - the project 1 folder. Then I run project 2 and get the unexpected result, the path is in the project 1 folder again. This should return project 2 folder as my expectation. The similar problem occur if i run the project 2 first.

 

In my knowledge, I guess after I run the project 1, the assembly path have save in computer memory. Then when I run the project 2, the code get the reference in computer memory and return unexpected result.

 

 

Is anyone here have had same problem? Can you give me solution? I would like to attach my Solution here for your information

 

Thank a lot!

 

P/s: Here are some screen shots

Add Assembly.PNGAdd Assembly2.PNG

1 REPLY 1
Message 2 of 2
jeremytammik
in reply to: vominhdoan90

If you load an assembly A into the .NET framework from directory Da and then load another version of assembly A from a different location Db, the .NET framework will determine that A has already been loaded and reuse the existing instance from Da, ignoring your request to load a second instance from Db. There are ways to work around this, presumably, but I will not even try to dive into that. I suggest that you design your two add-ins so that they do not rely on the location of the assembly A that you load in any way. You can easily move your assembly location determination code out of A into the main two add-ins instead.

 



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

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Rail Community