如何创建混合托管/本机 C++ VS2010中的dll?

发布于 2024-11-14 16:17:57 字数 326 浏览 6 评论 0原文

我想创建一个具有托管 C++ 接口的 dll,但实际工作的代码是本机 C++。

目前我们使用 COM (STA) 与托管代码进行交互,但现在我们想使用 ThreadPool 调用模块,这将不允许 STA 线程。我们希望避免为 MTA COM 重新编码模块。

我之前曾问过这个问题以及其他问题,但似乎这些回答并没有解决基本问题:如何建立项目。我正在使用 VS2010,希望列出步骤。我尝试从托管库(C++ 类库)开始,添加非托管类,以及 MFC DLL(我们使用一些 MFC 类,但希望最终解决它们)并添加托管类。我似乎永远无法编译它。

有人可以迁就我的无知并明确地从项目类型开始列出步骤吗?

I want to create a dll which has a managed C++ interface, but the actual code working underneath is native C++.

Currently we are using COM (STA) to interface with the managed code, but now we want to call the module with ThreadPool, which will not allow STA threads. We would like to avoid recoding the module for MTA COM.

I've asked this question before as well as others, and it seems the responses do not address the basic question: how to set up the project. I am using VS2010, and would like the steps laid out. I've tried starting with a managed library (C++ Class Library) and adding unmanaged classes, as well as MFC DLL (we utilize some MFC classes, but would like to work them out eventually) and adding managed classes. I can never seem to get it to compile.

Can someone please humor my ignorance and explicitly lay out the steps starting with the project type?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

风追烟花雨 2024-11-21 16:17:58

从 C++/CLI 开始,Visual Studio 在编译时不再生成混合模式程序集(如您所描述的)。 “本机”C++ 位被编译为不可验证的 CIL。

但是,可以将静态库嵌入到本机编译的程序集中,并且该本机库将原样合并。也就是说,如果您静态链接本机静态库,您将生成您正在寻找的混合模式程序集。

Starting with C++/CLI, Visual Studio no longer produces mixed mode assemblies (like you describe), when compiling. The "native" C++ bits are compiled into nonverifyable CIL.

However, it is possible to embed a static library into your assembly, which is natively compiled, and that native library will be merged in unchanged. That is, if you statically link against a native static library you'll produced the mixed-mode assembly you're looking for.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文