System.TypeLoadException: Could Not Load Type, is the exception I get when Im trying to load my own class libray compiles with Visual Studio

System.TypeLoadException: Could Not Load Type, is the exception I get when Im trying to load my own class libray compiles with Visual Studio

eduardooost
Participant Participant
2,494 Views
2 Replies
Message 1 of 3

System.TypeLoadException: Could Not Load Type, is the exception I get when Im trying to load my own class libray compiles with Visual Studio

eduardooost
Participant
Participant

System.TypeLoadException_CouldNoTLoadType.png

Im getting this error message when executing an external command that references a class library that I compiled using Visual Studio and .NETframework 4.8. 

 

That class library itself was compiled using Visual Studio and .NETframework 4.8, and works fine when I execute it. Next I'll share an image of the working script.

 

System.TypeLoadException_CouldNoTLoadType_Script-to-be-loaded.png

But when I reference this library into another project, I get this message:

 

"

System.TypeLoadException: Could not load type 'BIMIQS_modeling_from_autocad_drawing.BIMIQs_default_generic_variables' from assembly 'BIMIQS_modeling_from_autocad_drawing, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null', at Test.Main.Execute...

"

 

Does somebody knows how to fix this problem? Thanks in advance!

Accepted solutions (1)
2,495 Views
2 Replies
Replies (2)
Message 2 of 3

caroline.gitonga
Autodesk
Autodesk
Accepted solution

Hi @eduardooost ,

This does not seem to be a Revit API exception but a .NET one. From afar this looks like referencing mixup to your class library. You could take a closer look at your project references, your web.config file and your .dll versions to make sure that all your references are correct.

Also, take a look at this thread with exact same issue, see if yu could get any insights: https://stackoverflow.com/questions/124841/could-not-load-type-from-assembly-error to solve it

Carol Gitonga, Developer Advocacy and Support, ADN Open
Message 3 of 3

eduardooost
Participant
Participant

Thank you so much Caroline. Your response was very helpful. It helped me to see that the problem was in the connection between the class libraries.

 

I think that the problem was the compiling architecture of the class library and of the script that referenced it.

 

I canged the build platform to x64 in all build configurations on both scripts and it was able to load the first class library.