TypeLoadException was undhandled, please help!

Posted on 2007-07-30
Last Modified: 2013-11-07
hi expert

i have a DLL, a .NET Wrapper

i downloaded here :

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?

Question by:Dnx_7
    LVL 7

    Expert Comment

    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.
    LVL 2

    Author Comment

    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...

    LVL 7

    Accepted Solution

    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.
    LVL 7

    Expert Comment

    The source of the exception was identified in the answers.

    Featured Post

    Live: Real-Time Solutions, Start Here

    Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

    Join & Write a Comment

    A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
    Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
    Internet Business Fax to Email Made Easy - With eFax Corporate (, you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
    Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

    745 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    18 Experts available now in Live!

    Get 1:1 Help Now