3

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
Deduplicator
  • 44,692
  • 7
  • 66
  • 118
user145400
  • 1,076
  • 1
  • 12
  • 27
  • 1
    dependency walker? http://www.dependencywalker.com/ – Dmitri Sosnik Oct 20 '14 at 22:32
  • You have C or C++ code that was built with VS2008 in the Debug configuration. That happens if you don't really know where .lib files you link came from. We don't either of course. You can look at the .lib file(s) with a hex viewer and search for the string to narrow it down. – Hans Passant Oct 20 '14 at 22:36
  • @DmitriSosnik I updated the question with the output of depends. – user145400 Oct 20 '14 at 22:40
  • @HansPassant, yes I thought something like that was happening. Just wasn't sure at all how to proceed in fixing this. I will follow your suggestion I suppose. – user145400 Oct 20 '14 at 22:41
  • @user145400 Looks like either MyAssembly.dll or one of the dependencies just got built with Debug configuration, not Release. – Dmitri Sosnik Oct 20 '14 at 22:51
  • 1
    In dependency walker, look in the module list, find MSVCR90D.dll, right click and choose `Highlight Matching Module in Tree". This should allow you to see what exe or dll required this module. – The Dark Oct 20 '14 at 23:18

1 Answers1

1

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.

user145400
  • 1,076
  • 1
  • 12
  • 27