0

I have a Visual studio project with lots of commercial DLL files that I use in my program. I have used many of these DLL files so far without any problem.

Yesterday I had to use a yet another DLL file. I linked the DLL file as a referense (as usual), I can see it is added to the project since code-completion works and I could build the project successfully.

But when I run this on the target PC, I get a TypeLoadException.

A .NET exception (TypeLoadException) occured in the module

I tried to catch and print the exact information in the exception but I did not help at all.

Below is the complete exception that I receive:

A .NET exception (TypeLoadException) occured in the module LightSwitch\nError message: Could not load type 'Backbone2.LightMode_Status_Ctr_1' from assembly 'Backbone2, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'.\nThrowing method: DiagModule.SetSwitch\n

(I can not perform any debugging and provide more info, since I build my project as dll which is then used on the target PC, and actually I can run the program on my PC since it is missing all the required hardware)

theAlse
  • 5,577
  • 11
  • 68
  • 110
  • Can you edit your question and add the entire error and exception information? Also, you can enable additional assembly loader logging, via the instructions in this question: http://stackoverflow.com/questions/255669/how-to-enable-assembly-bind-failure-logging-fusion-in-net – Merlyn Morgan-Graham Mar 16 '11 at 05:50

5 Answers5

1

Check whether the dll is built for the same architecture as your pc. I mean, if your pc is 64 bit, make sure that the dll is built corresponding to that and vice versa

Naveed Butt
  • 2,861
  • 6
  • 32
  • 55
1

Thanks for all the replies, I managed to find the issue. The problem was that the project included a couple of library files (dll) with different versions in different folders. During runtime (still don´t know why) a dll file would be choose and since the file was different between different versions, some methods were missing. So updating the DLL files to the same version in all folders fixed the issue.

theAlse
  • 5,577
  • 11
  • 68
  • 110
0

Check that the DLL is in the right location (or in GAC) on the target PC.

Andrew Cooper
  • 32,176
  • 5
  • 81
  • 116
0

Launch FusLogVw.exe -- it is part of .Net SDK and could be launched from VS 2010 command prompt. Configure logging to record all failures. Reproduce problem, refresh view in FusLogVw.exe window. You should be able to find record that corresponds to your problem, it will tell you exactly what it is doing and you should be able to figure out how to correct the problem.

seva titov
  • 11,720
  • 2
  • 35
  • 54
  • I have edited my post, this is simply not possibe as I build a dll that only can be run on the target PC. – theAlse Mar 16 '11 at 05:59
  • Can you copy FusLogVw.exe to target PC and run it from there? – seva titov Mar 16 '11 at 06:29
  • There are lots of restriction for installing software on the target pc. – theAlse Mar 16 '11 at 06:31
  • What kind of restrictions? If you are able to copy Backbone2.dll, why cannot you copy one more binary? – seva titov Mar 16 '11 at 07:24
  • I need to install Microsoft SDK, in order to access FusLogVm.exe, right? (http://msdn.microsoft.com/sv-se/windows/bb980924.aspx?wt.svl=more_downloads) – theAlse Mar 16 '11 at 08:39
  • It is FusLogVw.exe, not FusLogVm.exe. You can Windows SDK if you like. However if you just need to run this one tool, you copy over fuslogvw.exe to any directory you like. The command is 'xcopy', or 'robocopy' if you are so inclined. – seva titov Mar 27 '11 at 22:11
0

Check if you are reference one version of the DLL and another one is loaded (from GAC) during runtime.

jgauffin
  • 99,844
  • 45
  • 235
  • 372
  • How can I check this? I can see that all of the DLL files that I am using (all the working one and the problematic one) have the same property as Runtime Version and Version. – theAlse Mar 16 '11 at 06:26