Search code examples
c#event-viewer

How can I determine what is referencing Microsoft.VC90.DebugCRT?


I have a large web application project, including code in C#, C++, and C, with many references (project references, DLL references) and I am making a release build. Testing my program in a virtual machine I get the following error:

Could not load file or assembly <MyAssembly.DLL> or one of its dependencies.
The application has failed to start because its side-by-side configuration is incorrect.
Please see the application event log or use the command-line sxstrace.exe tool for more detail.

So I check the event log, and I find this:

Activation context generation failed for "C:\Windows\Microsoft.NET\Framework\...\MyAssembly.DLL".
Dependent Assembly Microsoft.VC90.DebugCRT,processorArchitecture="x86",
publicKeyToken="1fc8b3b9a1e18e3b",type="win32",version="9.0.21022.8"
could not be found. Please use sxstrace.exe for detailed diagnosis.

I also used sxstrace as suggested and simply ended up with a file that says:

ERROR: Cannot resolve reference Microsoft.VC90.DebugCRT,processorArchitecture="x86",
publicKeyToken="1fc8b3b9a1e18e3b",type="win32",version="9.0.21022.8"

I checked the configuration for my projects and they are all set to build in release. Why is MyAssembly referencing Microsoft.VC90.DebugCRT? And how can I fix it?

Note that I did install x86 and x64 MSVC++ redistributables on my virtual machine.

EDIT I also ran dependency walker on MyAssembly.dll, and I got a bunch of entries that say "Error opening file. The system cannot find the file specified":

API-MS-WIN-... (4x)
EXT-MS-WIN-...
MSVCM90D.DLL
MSVCR90.DLL
MSVCR90D.DLL
IESHIMS.DLL
MFPLAT.DLL
SETTINGSYNPOLICY.DLL
WLANAPI.DLL

Solution

  • As mentioned in some comments, a solution is to use dependency walker.

    Indeed MyAssembly.dll was being built with Debug configuration even though I chose Release in Visual Studio. The reason was that I was running a post-build event that called msbuild on target WebPublish, but it didn't explicitly specify Release configuration for that, so it decided to use Debug.