views:

132

answers:

3

Hi folks:

I meet following exception when I copy the whole program directoy to another machine. Which tools can I employ to debug it? Thank you.

Unhandled Exception: System.TypeInitializationException: The type initializer fo r 'SomeClass' threw an exceptio n. ---> System.IO.FileLoadException: Could not load file or assembly 'SomeAssembly.dll, Version=0.0.0.0, Culture=neut ral, PublicKeyToken=null' or one of its dependencies. This application has faile d to start because the application configuration is incorrect. Reinstalling the application may fix this problem. (Exception from HRESULT: 0x800736B1) File name: 'SomeAssembly.dll, Version =0.0.0.0, Culture=neutral, PublicKeyToken=null' ---> System.Runtime.InteropServi ces.COMException (0x800736B1): This application has failed to start because the application configuration is incorrect. Reinstalling the application may fix thi s problem. (Exception from HRESULT: 0x800736B1)

A: 

If you're just copying the files over, check that the dll's aren't being blocked by the OS. To check that, right click on the dll, go to Properties and look on the bottom right of the dialog under the Advanced button. If there's a button there that says "Unblock" then click it. You'll have to either do that to all of them, or else add them to the GAC using the gacutil utility.

Paul

Paul
+1  A: 

You can use the fusion log to debug this sort of problem. It will show you where it is searching for the dependencies, and if it found them, and if it found them and failed to load them, why.

Logan Capaldo
nice tool, thank u!
Ricky
+3  A: 

It is a Windows error, not a .NET error. The error code is 14001, ERROR_SXS_CANT_GEN_ACTCTX, "The application has failed to start because its side-by-side configuration is incorrect. Please see the application event log for more detail."

Look in the Windows event log, it tells you what DLL you forgot to install on the target machine. If it is a mixed-mode assembly then it is typically the C/C++ runtime DLL, or you deployed the debug build.

Hans Passant
@bobugz: The error message is "Dependent Assembly Microsoft.VC90.DebugCRT could not be found and Last Error was The referenced assembly is not installed on your system." How do I search "Microsoft.VC90.DebugCRT" in my successful machine?
Ricky
Hans Passant
The same exception still is thrown out after installing the link u provided.
Ricky
Probably because you're still using the debug build.
Hans Passant