MissingMethodException using COM through Excel and VBA

48 Views Asked by At

I have a C# library from which I have exposed a couple of method to COM so that they can be called from Excel VBA. This library references another .NEt library from a 3rd party. This all works very nicely when deployed to a Windows Server 2016. When it is moved to an instance of Windows Server 2012 then I get a MissingMethodException when the JIT compiler attempts to JIT a method with a call to the 3rd party library.

I can compile the code on the target server and test it all fine, I can even call the code without any issues from another .Net application. It is only when it is called from the VBA code that it then fails to load and execute the 3rd party code.

I have changed the code in my library to do an Assembly.LoadFrom() on the 3rd part library and I can then use reflection to find the method. However, if I then invoke the method from the MethodInfo I get a failed result and on inspection in the QuickWatch Window I have a message "Internal error in the C# compiler". I can debug my code through executing Excel and stopping in my library and all seems fine except when trying to execute the method containing the code to the 3rd party library as the JIT won't compile it.

How do I debug why the JIT compiler can't find and load the assembly that I am using?

0

There are 0 best solutions below