<bdo id='uKSRl'></bdo><ul id='uKSRl'></ul>
    <tfoot id='uKSRl'></tfoot>

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

    1. <small id='uKSRl'></small><noframes id='uKSRl'>

      1. <legend id='uKSRl'><style id='uKSRl'><dir id='uKSRl'><q id='uKSRl'></q></dir></style></legend>

        如何在 Visual Studio 2012 中创建 HelloWorld COM 互操作

        时间:2023-07-27
        <legend id='NnwPa'><style id='NnwPa'><dir id='NnwPa'><q id='NnwPa'></q></dir></style></legend>
          <tbody id='NnwPa'></tbody>

          <tfoot id='NnwPa'></tfoot>

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

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

                • <bdo id='NnwPa'></bdo><ul id='NnwPa'></ul>
                  本文介绍了如何在 Visual Studio 2012 中创建 HelloWorld COM 互操作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  首先,我是 COM 新手,目前很困惑.我在 MSDN 和一般网络上阅读了很多关于 COM 的文档,但其中很多似乎已经过时且过于复杂.

                  First off, I am new to COM, and currently quite confused. I've read a lot of documentation on COM on MSDN and the general web, but a lot of it seems outdated and overly complex.

                  这是我认为让它发挥作用所必需的.它还没有,所以我确定我遗漏了一些东西,但是通过提供我的食谱,我希望有人能发现问题:

                  Here's what I believe to be necessary to get it to work. It doesn't yet, so I am sure I am missing something, but by giving my recipe, I hope someone can spot the problem:

                  1. 创建一个 C# 控制台应用项目.我把它命名为 CSharpApp
                  2. 创建一个 C++ ATL 项目.我称之为 ComLib.Interop.
                    • 添加类(模板:ATL Simple Object),我称之为InteropDemo"
                    • 在类视图中,右键单击 IInteropDemo 并添加方法 HelloWorld.
                  • 在编译好的 COM dll 上调用 regsrv32.exe,然后在添加引用..."的 COM 选项卡中选择 DLL

                  感谢答案,我更新了问题以反映综合解决方案.

                  Thanks to the answers, I updated the question to reflect the combined solution.

                  推荐答案

                  尝试以下步骤:

                  1. 确保两个项目(非托管 C++ 和托管 C#)具有相同的位数(x86 或 x64).为了清楚起见,假设它是 x86.
                  2. 打开 Admin 命令提示符并注册您的 COM DLL:C:WindowsSysWOW64 egsvr32.exe c:full-pathComLib.Interop.dll
                  3. 管理员身份运行 Visual Studio.执行步骤 1、2、4、5、6.不要做3.
                  1. Make sure both projects, unmanaged C++ and managed C# have the same bitness, either x86 or x64. Let's say it's x86, for clarity.
                  2. Open Admin Command Prompt and register your COM DLL: C:WindowsSysWOW64 egsvr32.exe c:full-pathComLib.Interop.dll
                  3. Run Visual Studio as Admin. Do steps 1,2,4,5,6. Don't do 3.

                  看看你能不能达到 7.我认为这应该可行.

                  See if you get to 7. I think that should work.

                  请注意,您只需要在开发机器上进行注册.独立的 COM 应该可以在其他任何地方工作.

                  Note you only need the registration on the Development machine. Isolated COM should work everywhere else.

                  这篇关于如何在 Visual Studio 2012 中创建 HelloWorld COM 互操作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:从 C# 调用 IDispatch COM 接口的成员 下一篇:从 C# 应用程序获取 WindowsExplorer 中的当前选择?

                  相关文章

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

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

                    1. <legend id='hyMNk'><style id='hyMNk'><dir id='hyMNk'><q id='hyMNk'></q></dir></style></legend>