• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 313
  • Last Modified:

TypeLoadException was undhandled, please help!

hi expert

i have a DLL, a .NET Wrapper

i downloaded here : http://midimick.com/magicknet/magickDoc.html

when i added the dll in the reference of my project, no problem
when i launch the application (winform) : no problem

now i add just ONE LINE that are using the DLL, the project cannot be launched :

=> unable to launch assembly...
=> typeloadException was undhandled

can somebody help me?

  • 3
1 Solution
Probably throwing an exception in the static constructor for the type you referenced. Try adding a try/catch in the static constructor code, and log the exception, or put a breakpoint in the static constructor code and step through it in the debugger.
Dnx_7Author Commented:
you meant in the "NEW" constructor of the form?

if yes, then the initialize component doesn't throw exception but just after the "new" constructor, the exception is thrown...

No, I really meant the class level initialization, not the object constructor; something like this:

static MyOtherClassThatThrowsAnException trouble = new MyOtherClassThatThrowsAnException();
// or this
static int uninitialized[];
static MyClass()
     uninitialized[0] = 1;

would cause this trouble.

But, for your specific case I see that you didn't write the DLL you are referencing, and perhaps you don't have BOTH DLLs required for what you are tring to do. There is a .Net DLL which is an intermediate layer for working the C DLL you are trying to use. It could be that the .Net DLL is having trouble (in it's static initialization) hooking up with the magic DLL. Make sure both DLLs are where they are supposed to be.
The source of the exception was identified in the answers.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now