tags:

views:

59

answers:

3

Hello,

I have a big and bloated software and I want to add a new GUI element to it. The GUI element was written using XAML and WPF. I created the UI element in a separate assembly, and reference it in the big software. The two projects compiled smoothly under VS2010, but when I run my application I get a TypeLoadException.

Looking into the exception with the debugger, I get the following message : Could not load type GUI.Dashboard from assembly GUI, blah, blah. There is no InnerException nor any further detail.

The .GNU documentation says that this message appears when there is no message passed to the constructor of the exception. I assume that the producer of the exception itself does not know how it happened.

I tried using the tool Fuslogvw.exe and it effectively showed me some minor missing dependencies which are unrelated. However, it cannot find any information on this very exception.

What kind of problem can possibly throw an imprecise exception like this one ? Is there a way to make Fuslogvw.exe aware of it to get some details ?

Thank you in advance,

Edit : I effectively compiled my application with debugging symbols. The exception happens when I try to instanciate a class containing a reference to the problematic symbol. i.e.:

class SomeClass
{
    GUI.Dashboard dashboard;
}

And the call trace looks loke this:

at SomeClass..ctor()
at MainClass.Main() din MainClass.cs:line 42
A: 

Possible issues include:

  1. The assembly you reference is x64 only and your consumer is x86 or AnyCPU on a 32-Bit CLR
  2. Your consumer assembly was compiled against a different version of the referenced assembly

You can try to use FusLogVW to turn on assembly binding logging and check the logfile for more information about what failed.

Michael Stum
I double-checked the configuration and the two projects are targeted for AnyCPU. Furthermore, as I precise in my post, I used `Fuslogvw.exe` to get details about this error, but it does not even show it, although it lists all the other assembly loaded by the application (the successful and failed ones)
kbok
A: 

TypeLoadException is thrown when the common language runtime cannot find the assembly, the type within the assembly, or cannot load the type.

TypeLoadException uses the HRESULT COR_E_TYPELOAD, that has the value 0x80131522.

For a list of initial property values for an instance of TypeLoadException, see the TypeLoadException constructors.

Source: MSDN

Kim
A: 

I finally found a reason for this bug : apparently, in some cases referencing a .exe file does not work properly. Some methods and classes loads OK but some fails. In another project, referencing this .exe file cause no problem.

Switching to the .dll format solved all linking problems. I think this is a bug in the CLR.

kbok