要注意的是,如果你编译 C++ 托管程序集的时候使用的是 Debug 配置的话,生成的 DLL 需要调用的就是 CRT 对应的 debug 版本( msvcr80d.dll 及 msvcm80d.dll 等 )而不是(msvcm80.dll及 msvcp80.dll等)。了解生成的 DLL 到底是 Debug 还是 Release 版本最简单的方法是用文本编辑器打开该 DLL 文件,找到以下类似的内容(一般位于文件末尾处):
<assembly xmlns="urn:schemas-microsoft-com:asm.v1"
- manifestVersion="1.0">
- <dependency>
- <dependentAssembly>
- <assemblyIdentity type="win32"
- name="Microsoft.VC80.DebugCRT"
- version="8.0.50608.0"
- processorArchitecture="x86"
- publicKeyToken="1fc8b3b9a1e18e3b">
- </assemblyIdentity>
- </dependentAssembly>
- </dependency>
- </assembly>
如果看到 Microsoft.VC80.DebugCRT ,那说明该 dll Link的目标是 CRT的Debug版本,如果是Microsoft.VC80.CRT 则 link 到再分发版本。当我在 VS.net2005 的 IDE 中通过批生成来生成 C# exe 和 C++ dll 的时候,如果当前的活动解决方案配置是 Debug 的话,在 C# 项目的Release输出目录下拷贝的会是 C++ dll 的 Debug 版本文件而不是 Release 版本!所以在发布生成之后确认对应文件的版本还是相当有必要的。
下面是两种模式需要的文件及目录位置,根据模式将相应的文件拷入安装目录即可解决上述问题
状态 : Debug Mode
\Microsoft Visual Studio 8\VC\redist\Debug_NonRedist\x86
|
-> \Microsoft.VC80.DebugCRT
|
-> Microsoft.VC80.DebugCRT.manifest, msvcm80d.dll, msvcp80d.dll, msvcr80d.dll
状态 : Relsase Mode
\Microsoft Visual Studio 8\VC\redist\x86
|
-> \Microsoft.VC80.CRT
|
-> Microsoft.VC80.CRT.manifest, msvcm80.dll, msvcp80.dll, msvcr80.dll
如何生成Release 版本:
将运行按钮右边的解决方案配置改为Release模式,然后生成即可
来源:oschina
链接:https://my.oschina.net/u/69160/blog/29730