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

    <tfoot id='MfhRl'></tfoot>

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

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

        C# 包装器接口错误:E_NOINTERFACE

        C# wrapper interface error: E_NOINTERFACE(C# 包装器接口错误:E_NOINTERFACE)
          <i id='mxmuh'><tr id='mxmuh'><dt id='mxmuh'><q id='mxmuh'><span id='mxmuh'><b id='mxmuh'><form id='mxmuh'><ins id='mxmuh'></ins><ul id='mxmuh'></ul><sub id='mxmuh'></sub></form><legend id='mxmuh'></legend><bdo id='mxmuh'><pre id='mxmuh'><center id='mxmuh'></center></pre></bdo></b><th id='mxmuh'></th></span></q></dt></tr></i><div id='mxmuh'><tfoot id='mxmuh'></tfoot><dl id='mxmuh'><fieldset id='mxmuh'></fieldset></dl></div>
          1. <tfoot id='mxmuh'></tfoot>
              <legend id='mxmuh'><style id='mxmuh'><dir id='mxmuh'><q id='mxmuh'></q></dir></style></legend>
                <tbody id='mxmuh'></tbody>
            • <small id='mxmuh'></small><noframes id='mxmuh'>

                • <bdo id='mxmuh'></bdo><ul id='mxmuh'></ul>
                  本文介绍了C# 包装器接口错误:E_NOINTERFACE的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我正在尝试为我拥有的 COM 对象(名为 SC_COM.dll)生成 C# 包装器,但在将其与 Visual Studio 2008(运行 Vista)链接时遇到了一些问题.我需要使用 COM DLL 进行无需注册的操作——我正在使用清单文件让 Visual Studio 知道 SC_COM.dll,这似乎可以正常工作.我使用 TblImp.exe 生成了我在 Visual Studio 2008 中引用的类型库 (SC_COMtlb.dll),因此我可以与我需要的 DLL 进行早期绑定.DLL 都与清单和可执行文件位于同一目录中.

                  I am trying to produce a C# wrapper for a COM object that I have (named SC_COM.dll), but am having some issues linking it with Visual Studio 2008 (running Vista). I need to do this registration-free with the COM DLL--I'm using a manifest file to let Visual Studio know about SC_COM.dll, and that appears to be working. I used TblImp.exe to generate a type library (SC_COMtlb.dll) that I'm referencing in Visual Studio 2008 so I can do early binding with the DLL that I need. The DLLs are both in the same directory as the manifest and the executable.

                  问题是:当我实例化对象并尝试在 C# 中调用其方法之一时,它会引发以下错误:

                  Here's the issue: When I instantiate the object and try and call one of its methods in C#, it throws the following error:

                  检测到错误:无法将SC_COMtlb.SCAccessObjClass"类型的 COM 对象转换为接口类型SC_COMtlb.ISCUploader".此操作失败,因为 IID 为{C677308A-AC0F-427D-889A-47E5DC990138}"的接口的 COM 组件上的 QueryInterface 调用因以下错误而失败:不支持此类接口(来自 HRESULT 的异常:0x80004002 (E_NOINTERFACE)).

                  Error detected: Unable to cast COM object of type 'SC_COMtlb.SCAccessObjClass' to interface type 'SC_COMtlb.ISCUploader'. This operation failed because the QueryInterface call on the COM component for the interface with IID '{C677308A-AC0F-427D-889A-47E5DC990138}' failed due to the following error: No such interface supported (Exception from HRESULT: 0x80004002 (E_NOINTERFACE)).

                  我不完全确定这个错误是什么意思——我已经对错误代码进行了搜索,它似乎是一个相对普遍的 C# 错误.那么我是要在这里以错误的方式链接 COM 对象,还是我可能遗漏了其他一些重要步骤?

                  I'm not entirely certain what this error means--I've done a search on the error code, and it appears to be a relatively general C# error. So am I going about linking the COM object the wrong way here, or is there some other important step I may be missing?

                  我可能应该注意到,我不完全确定我生成的类型库 (SC_COMtlb.dll) 如何知道实际的 COM DLL 在哪里,因为它没有在系统中注册——我假设它只是看起来在同一目录中.这可能是问题所在吗?如果是,我怎样才能更好地将两者联系起来?

                  I should probably note that I'm not entirely sure how the type library (SC_COMtlb.dll) that I produced knows where the actual COM DLL is, since it's not registered with the system--I assume it just looks in the same directory. Could this potentially be the issue, and if so, how can I better link the two?

                  推荐答案

                  尝试将此添加到您的 App.exe.manifest:

                  Try adding this to your App.exe.manifest:

                  <comInterfaceExternalProxyStub 
                    name="ISCUploader" 
                    iid="{C677308A-AC0F-427D-889A-47E5DC990138}"
                    proxyStubClsid32="{00020424-0000-0000-C000-000000000046}"
                    baseInterface="{00000000-0000-0000-C000-000000000046}"
                    tlbid = "{PUT-YOUR-TLB-GUID-HERE}" />
                  

                  可以从 Visual Studio 生成的 Native.Namespace.Assembly.Name.manifest 中找到 TLBID,如下所示:

                  Where TLBID can be found from your Visual Studio generated Native.Namespace.Assembly.Name.manifest, looking like this:

                  <typelib tlbid="{A-GUID-IS-HERE--USE-IT}"
                    version="1.0" helpdir="" resourceid="0" flags="HASDISKIMAGE" />
                  

                  我为此纠结了很长时间,但我找到了这些有用的参考资料并将其拼凑在一起,它对我有用:

                  I was banging my head against this for quite some time, but I found these helpful references and pieced it together and it's working for me:

                  • 为什么我在创建支持它的对象时会得到 E_NOINTERFACE界面?
                  • 免注册 Skype4Com 和多线程单元
                  • COM 组件的免注册激活:演练李>

                  这篇关于C# 包装器接口错误:E_NOINTERFACE的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  Performance overhead of using attributes in .NET(在 .NET 中使用属性的性能开销)
                  Accessing attribute info from DTE(从 DTE 访问属性信息)
                  c# Hide a property in datagridview with datasource(c#使用数据源隐藏datagridview中的属性)
                  Extract Display name and description Attribute from within a HTML helper(从 HTML 帮助器中提取显示名称和描述属性)
                  C# Attributes and their uses(C# 属性及其用途)
                  C# - Getting all enums value by attribute(C# - 按属性获取所有枚举值)
                  <i id='91f8H'><tr id='91f8H'><dt id='91f8H'><q id='91f8H'><span id='91f8H'><b id='91f8H'><form id='91f8H'><ins id='91f8H'></ins><ul id='91f8H'></ul><sub id='91f8H'></sub></form><legend id='91f8H'></legend><bdo id='91f8H'><pre id='91f8H'><center id='91f8H'></center></pre></bdo></b><th id='91f8H'></th></span></q></dt></tr></i><div id='91f8H'><tfoot id='91f8H'></tfoot><dl id='91f8H'><fieldset id='91f8H'></fieldset></dl></div>

                      <tbody id='91f8H'></tbody>
                    <legend id='91f8H'><style id='91f8H'><dir id='91f8H'><q id='91f8H'></q></dir></style></legend>

                      • <bdo id='91f8H'></bdo><ul id='91f8H'></ul>

                        <small id='91f8H'></small><noframes id='91f8H'>

                            <tfoot id='91f8H'></tfoot>