开发者

TypeLoadException thrown erroniously

In a simple app I'm working on, I've got three related assemblies:

  1. "MyCompany.Geography.Windows.Forms" which is a class library with the winforms controls in it
  2. "MyCompany.Geography" which has some definitions for some base types and the like.
  3. "MyCompany.Geography.Windows" which is a quick knock up app with a simple form, and one of the controls dropped on it as a basic test harness.

Now, everything was going well and I could drop my control on tot he form in the designer, and it merrily added the relevant references, but when I try and actually run it under debug, I get:

System.TypeLoadException occurred
  Message="Could not load type 'MyCompany.Geography.Windows.Forms.MyControl' from assembly 'MyCompany.Geography.Windows, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'."
  Sourc开发者_运维问答e="MyCompany.Geography.Windows"
  TypeName="MyCompany.Geography.Windows.Forms.MyControl"
  StackTrace:
       at MyCompany.Geography.Windows.Form1.InitializeComponent()
       at MyCompany.Geography.Windows.Form1..ctor() in ...\Projects\MyCompany.Geography\MyCompany.Geography.Windows\Form1.cs:line 10
  InnerException: 

Normally I'd go and look at the inner exception, but there is none. the bit that's really confusing me is that I'd have exepcted it to have followed the reference, and looked in there, and I'm a bit stuck as to what to check?


Make sure that the executable application references both MyCompany.Geography.Windows.Forms.dll and MyCompany.Geography.dll.

Have you checked the Output window during the debug session for any information about failing to load the assembly? It could also be related to conflicting versions of the assembly. When the application breaks into the debugger at the point of the exception, open the Modules window (Debug -> Windows -> Modules) and see if the assemblies are in fact loaded.


Use the fuslogvw.exe tool to find out what assembly it is using. The exception indicates that it does find the assembly but that the assembly doesn't contain the MyControl type. Maybe it finds an old version of the assembly. Fuslogvw will tell you.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜