Inconsistent MissingMethodException

Inconsistent MissingMethodException

floretti
Advocate Advocate
831 Views
6 Replies
Message 1 of 7

Inconsistent MissingMethodException

floretti
Advocate
Advocate

G'day folks. I've got two classes: A and B, both calling public methods from class C.

 

Class A runs perfectly fine but class B throws a MissingMethodException as it seems it can't find a method from class C (refer to screenshot below). Any ideas why that could be happening? It's worth mentioning that class B is calling a private method inside itself, which is calling a method from class C.

FabioLorettiOliveira_0-1641794256927.png

 

0 Likes
Accepted solutions (1)
832 Views
6 Replies
Replies (6)
Message 2 of 7

jeremy_tammik
Alumni
Alumni

Since .NET applications are compiled into IL, intermediate language, the resulting assembly DLL can easily be explored to find out exactly what classes and methods they define. Use a tool such as Reflector, ILSpy et al to dive into your assemblies and find out what they define and what is missing:

 

https://github.com/icsharpcode/ILSpy

  

 

Jeremy Tammik Developer Advocacy and Support + The Building Coder + Autodesk Developer Network + ADN Open
0 Likes
Message 3 of 7

floretti
Advocate
Advocate
Oh, I didn't know that was a possibility. I'll explore that option and report back on this post. Thanks for taking the time to reply, much appreciated.
0 Likes
Message 4 of 7

floretti
Advocate
Advocate

@jeremy_tammik  After going through my class C assembly in ILSpy I noticed my class and methods are present however, after checking the assembly load log I noticed the issues below when loading RevitAPI and RevitAPIUI.

 

FabioLorettiOliveira_0-1641855573027.png

 

I'm not even sure they are related to the issue I'm facing but I've done some research to find out what is causing it without success. Any help would be very appreciated.

0 Likes
Message 5 of 7

jeremy_tammik
Alumni
Alumni
Accepted solution

There are many possible mistakes you can make. One fundamental one is to have multiple copies of the different DLLs in your system, and inadvertently loading the wrong one. Please ensure that you have only one single copy each of RevitAPI, RevitAPIUI, A, B and C.dll in your system to ensure no confusion. You can also use fuslogv to analyse the assembly loading, as described here:

 

  

Jeremy Tammik Developer Advocacy and Support + The Building Coder + Autodesk Developer Network + ADN Open
0 Likes
Message 6 of 7

floretti
Advocate
Advocate

Thanks again, Jeremy. Your previous comment helped me find the issue and it was spot on a duplicate of a DLL being loaded for another plugin I built.

 

For the sake of others who may have the same issue in the future, I have a solution in VS containing two projects which are two different plugins for Revit plus another 2-3 projects in the same solution which I use as containers for "support" classes such as Windows forms I can use for both plugins, complex classes/methods to simplify the code inside the plugins, loggers, etc.

 

Because both plugins use these support classes, I end up with DLL files for these support projects in both plugins when I compile them, which caused my Revit Add-in folder to have duplicates like shown below.

 

FabioLorettiOliveira_0-1641958324266.png

 

0 Likes
Message 7 of 7

jeremy_tammik
Alumni
Alumni

Congratulations on solving! Thank you for your appreciation and glad I was able to help!

   

Jeremy Tammik Developer Advocacy and Support + The Building Coder + Autodesk Developer Network + ADN Open
0 Likes