c++托管和非托管静态库
我有一些带有简单代码的托管 C++ 程序集。
该程序集具有混合(托管/非托管)代码。如果我将非托管代码放入单独的非托管静态库并将其与托管代码链接,则会收到如下注册错误:“无法加载 'xxxxxx.dll',因为它不是有效的 .NET 程序集” .
如果我将所有代码放入一个项目并将其构建在一起,那么一切都会正常工作。我已经在VS2008 + .NET3.5 + RegAsm .Net2.0上尝试过了。我的集会已签署。
我想保存非托管静态库和托管程序集的代码分离。
我需要做什么?
提前致谢。
I have a some managed C++ assembly with simple code.
This assembly has mixed (managed/unmanaged) code. If I put unmanaged code to the separate unmanaged static library and link it with managed code then I get registration error like this: "Failed to load 'xxxxxx.dll' because it is not a valid .NET assembly".
If I put all code to one project and build it together then all works finely. I have tried it on VS2008 + .NET3.5 + RegAsm .Net2.0. My assembly is signed.
I would like to save my code separation for unmanaged static library and managed assembly.
What I need to do?
Thanks in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您的库必须构建为动态使用 C++ 运行时(从 .NET 2.0 开始)。
在项目属性中,打开 C/C++,然后转到代码生成。查找“运行时库”,并设置为“多线程DLL”用于发布,“多线程调试DLL”用于调试。
Your lib must be built to use the C++ runtime dynamically (as of .NET 2.0).
In project properties, open C/C++, and go to Code Generation. Look for Runtime Library, and set to Multi-threaded DLL for release, and Multi-threaded Debug DLL for debug.