• <small id='TcIKJ'></small><noframes id='TcIKJ'>

    <tfoot id='TcIKJ'></tfoot>
    <i id='TcIKJ'><tr id='TcIKJ'><dt id='TcIKJ'><q id='TcIKJ'><span id='TcIKJ'><b id='TcIKJ'><form id='TcIKJ'><ins id='TcIKJ'></ins><ul id='TcIKJ'></ul><sub id='TcIKJ'></sub></form><legend id='TcIKJ'></legend><bdo id='TcIKJ'><pre id='TcIKJ'><center id='TcIKJ'></center></pre></bdo></b><th id='TcIKJ'></th></span></q></dt></tr></i><div id='TcIKJ'><tfoot id='TcIKJ'></tfoot><dl id='TcIKJ'><fieldset id='TcIKJ'></fieldset></dl></div>

        <bdo id='TcIKJ'></bdo><ul id='TcIKJ'></ul>
      <legend id='TcIKJ'><style id='TcIKJ'><dir id='TcIKJ'><q id='TcIKJ'></q></dir></style></legend>

      1. 带有 COM 接口的 MFC Dll

        时间:2023-05-21
        <legend id='0wyRd'><style id='0wyRd'><dir id='0wyRd'><q id='0wyRd'></q></dir></style></legend>
        <i id='0wyRd'><tr id='0wyRd'><dt id='0wyRd'><q id='0wyRd'><span id='0wyRd'><b id='0wyRd'><form id='0wyRd'><ins id='0wyRd'></ins><ul id='0wyRd'></ul><sub id='0wyRd'></sub></form><legend id='0wyRd'></legend><bdo id='0wyRd'><pre id='0wyRd'><center id='0wyRd'></center></pre></bdo></b><th id='0wyRd'></th></span></q></dt></tr></i><div id='0wyRd'><tfoot id='0wyRd'></tfoot><dl id='0wyRd'><fieldset id='0wyRd'></fieldset></dl></div>

        <small id='0wyRd'></small><noframes id='0wyRd'>

            <tbody id='0wyRd'></tbody>
            <bdo id='0wyRd'></bdo><ul id='0wyRd'></ul>

                <tfoot id='0wyRd'></tfoot>

                • 本文介绍了带有 COM 接口的 MFC Dll的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  限时送ChatGPT账号..

                  我对托管/非托管互操作性和 COM 概念非常陌生.

                  I am pretty new to managed/unmanaged interoperability and COM concepts.

                  我收到了使用 COM Interop 的建议,以便在 C# 中使用我现有的 MFC 代码.但对我来说问题是,我有一个不是有效 COM 组件的 MFC Dll.如何使这个 MFC DLL 具有可在 .NET 中使用的 COM 可访问接口?

                  I received a suggestion of using COM Interop, for using my existing MFC code in C#. But the problem for me is, i have a MFC Dll which is not a valid COM component. How can I make this MFC DLLs to have COM-accessible interfaces ready for use in .NET?

                  推荐答案

                  从线程 在 C# 中加载 MFC DLLWindows 应用程序

                  要从 C# 访问本机代码,您有几个选择.

                  To access native code from C# you have a few choices.

                  最直接的是,您可以使用 DllImportAttribute 以 C# 术语描述 DLL 的入口点,以便可以通过 P/Invoke 调用它们.它们看起来像 C# 程序的静态方法.

                  Most directly, you can use DllImportAttribute to describe your DLL's entry points in C# terms so that they can be called via P/Invoke. They'll look like static methods to your C# program.

                  不太直接,您可以创建一个托管 C++ 程序集,将您的 DLL 包装在一个或多个托管对象中.托管 C++ DLL 可以通过添加引用从 C# 访问(因为它是具有 .dll 扩展名的托管程序集),并且还应该能够通过使用 #include 来访问您的 MFC dll 以包含 MFC dll 的头文件.

                  Less directly, you can create a Managed C++ assembly that wraps your DLL in one or more managed objects. The Managed C++ DLL can be accessed from C# via Add Reference (because it is a managed assembly with a .dll extension) and should also be able to access your MFC dll by using #include to include the MFC dll's header file.

                  第三种选择是将您的 dll 转换为 COM 对象,以便您的 C# 程序可以通过这种方式访问它.

                  A third option would be to turn your dll into a COM object so that your C# program can access it that way.

                  这篇关于带有 COM 接口的 MFC Dll的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:混合模式 C++/CLI 应用程序未正确关闭 CLR 下一篇:从 C++ 启动 C# 应用程序并在该应用程序上执行任务

                  相关文章

                  <small id='XWQkU'></small><noframes id='XWQkU'>

                      <i id='XWQkU'><tr id='XWQkU'><dt id='XWQkU'><q id='XWQkU'><span id='XWQkU'><b id='XWQkU'><form id='XWQkU'><ins id='XWQkU'></ins><ul id='XWQkU'></ul><sub id='XWQkU'></sub></form><legend id='XWQkU'></legend><bdo id='XWQkU'><pre id='XWQkU'><center id='XWQkU'></center></pre></bdo></b><th id='XWQkU'></th></span></q></dt></tr></i><div id='XWQkU'><tfoot id='XWQkU'></tfoot><dl id='XWQkU'><fieldset id='XWQkU'></fieldset></dl></div>
                    1. <tfoot id='XWQkU'></tfoot>
                        <bdo id='XWQkU'></bdo><ul id='XWQkU'></ul>

                      <legend id='XWQkU'><style id='XWQkU'><dir id='XWQkU'><q id='XWQkU'></q></dir></style></legend>