I have a c# .net 4 app , using vs 2010. Im trying to import a c++ dll (built on vs 2005).
[DllImport("Card.dll")]
I get the failure:
Unable to load DLL 'Card.dll': 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. (Exception from HRESULT: 0x800736B1)
using sxstrace.exe I get:
ERROR: Cannot resolve reference Microsoft.VC80.DebugMFC,processorArchitecture="x86"
I also found out that:
MFC80D.DLL and MSVCR80D.DLL are missing
Notice this is not DebugCRT, as this problem was caused by using a Debug compiled DLL instead of Release. I now use the Release compiled dll and the problem is DebugMFC.
I've tried anything I could find online. In order to save time I will introduce what I tried, so I won't get this advises again:
1- I have installed Microsoft Visual C++ 2010 Redistributable Package + SP1 + Security updates
2- I have installed Microsoft Visual C++ 2008 Redistributable Package
3 - I have installed Microsoft Visual C++ 2005 Redistributable Package
4 - I tried running this app as "Release" and not as "Debug"
5 - I tried to set entryPoint to the DllImport
Non helped. I still get the same error. I didn't see any other advise online instead of the one listed above. Can anyone help me?
Because it says "Cannot resolve reference Microsoft.VC80.DebugCRT,processorArchitecture="x86", that means you are missing a dependency on the debug crt runtimes for VC 8.0. This means you need to build a release, NOT debug, version of card.dll. Microsoft doesn't ship a redistributable package for debug CRT runtimes. Those only comes with visual studio. Therefore build a release version of card.dll, and that should help your situation.
Do you have control over building Card.dll
? If yes, have a look at how it is built. It must be built with proper version of VC++ (the one delivered with VS 2005) with manifest enabled. Then, installing the 2005 Redist. package must solve the problem. In case you cannot build Card.dll
yourself, you will have to analyse the embedded manifest (if any) and contact the authors to remedy the problem cooperatively.
A static library by default links to the dynamic runtime.
If you re-build the dll in VS2005, change your Configuration Properties | C/C++ | Code Generation | Runtime Library setting to static runtime to avoid that problem.
You can use Dependency Walker to try to figure out what dependencies your dll pulls. If it says it wants *d.dll
, then it looks like it is not a release version. Ask your colleague to check build configuration.
To use debug version you can try the following:
c:\Program Files\Microsoft Visual Studio 9.0\VC\redist\Debug_NonRedist\x86\
(this is for Visual Studio 2008, x86, adjust the path according to your system).Microsoft.VC90.DebugCRT
and Microsoft.VC90.DebugMFC
directories to the directory with your executable.<assemblyIdentity type="win32" name="Microsoft.VC90.DebugCRT" version="9.0.30729.6161" processorArchitecture="x86" publicKeyToken="1fc8b3b9a1e18e3b"></assemblyIdentity>
, change the 9.0.30729.6161
according to what your dll needs.The needed assembly version can be found in the output of sxstrace or in the in the *.intermediate.manifest
file alongside the dll in its build directory. Sorry, I do not have Visual Studio 2005 and can not give the exact number.
User contributions licensed under CC BY-SA 3.0