I’m getting this error message on all projects (including brand new empty templates) I’m trying to build with Visual Studio 2008:
Unexpected debug information initialization error — ‘Failed to find a required export in the runtime.’
The Error Help for Compiler Error CS0040 is not very helpful:
This error can occur when using the /debug compiler option and indicates that the compiler was unable to write to the .pdb file. Possible resolutions to this error include reinstalling Visual Studio, ensuring that the compiler has write access to a file or directory, or not compiling with /debug.
I can manually create files in the intended {bin,obj}\Debug directories, running the Studio as Administrator didn’t help, uninstalling both the 3.5 framework and the Visual Studio 2008 and re-installed both with their respective Service Packs and I’m still getting the error.
Removing all /debug switches from the command line obviously removes the error message as indicated, but is no option for further development.
How can I further debug this?
In the end, I used the Process Monitor from the Sysinternals Suite to take a look at the things the compiler was doing. By starting
csc.exefrom the Visual Studio 2008 Command Prompt and filtering byProcess Name is 'csc.exe'in the process monitor, I got a good picture of what the compiler was doing.‘Inspired’ by the ‘Failed to find a required export in the runtime’ message I searched for missing DLLs and actually found that
csc.exewas trying to accessWindows\Microsoft.NET\Framework\v2.0.50727\diasymreader.dllbut failed. Getting that DLL from another installation fixed the error for me.