gpt4 book ai didi

com - 在 native 中托管 CLR - COM 接口(interface),未解析的外部符号 _CStdStubBuffer_Release@4

转载 作者:行者123 更新时间:2023-12-04 06:06:34 25 4
gpt4 key购买 nike

我正在尝试托管 CLR(暂时不尝试使用单声道,尽管我可能会尝试)。基本上,我正在关注这个:

http://www.lenholgate.com/blog/2010/07/clr-hosting---a-flexible-managed-plugin-system-part-1.html

但是,我在使用 COM 本身时遇到了一些问题,因为在那篇文章中没有对它进行彻底的解释,而且我边走边学(以前没有玩过 COM)。

我定义了一个接口(interface):

import "unknwn.idl";
[
object,
uuid(55d96f88-9633-4ad7-b9de-1a546ea73307),
helpstring("INative interface"),
pointer_default(unique)
]
interface INative : IUnknown
{
HRESULT Write(BSTR s);
}
[
object,
uuid(74eeeaaa-d73c-436e-b52d-5c8a972ce60a),
helpstring("ITestManager Interface"),
pointer_default(unique)
]
interface IManagedHost : IUnknown
{
HRESULT Init(INative* native);
}

并将生成的文件包含在我的 native 项目中。但是,我无法构建可执行文件,因为链接器无法解析: _CStdStubBuffer_Release@4 . RpcRT4.lib已链接,但我已运行 dumpbin rpcrt4.lib /all | grep _CStdStubBuffer_Release并且没有像该库导出的那样,有 CStdStubBuffer_DebugServerRelease .那么,问题是,如果它不应该存在,究竟是什么引用了该方法?

做了更多调查,我发现这个方法是通过 IDL 工具生成的 .c 文件引用的:
const CInterfaceStubVtbl _INativeStubVtbl =
{
&IID_INative,
&INative_ServerInfo,
4,
0, /* pure interpreted */
CStdStubBuffer_METHODS
};

和 CStdStubBuffer_METHODS 在 RpcProxy.h 中定义Windows SDK v7.0A :
#define CStdStubBuffer_METHODS \
CStdStubBuffer_QueryInterface,\
CStdStubBuffer_AddRef, \
CStdStubBuffer_Release, \
CStdStubBuffer_Connect, \
CStdStubBuffer_Disconnect, \
CStdStubBuffer_Invoke, \
CStdStubBuffer_IsIIDSupported, \
CStdStubBuffer_CountRefs, \
CStdStubBuffer_DebugServerQueryInterface, \
CStdStubBuffer_DebugServerRelease

它确实需要 CStdStubBuffer_Release 方法,尽管它有点不同: http://msdn.microsoft.com/en-us/library/windows/desktop/ms764247%28v=VS.85%29.aspx .

那我应该链接什么其他图书馆?

最佳答案

CStdStubBuffer_Release() 由 midl.exe 自动生成的另一个文件 dlldata.c 实现。 DLLDATA_ROUTINES 宏生成它。

此问题指向项目配置错误,听起来您将代理 .c 文件添加到主项目中,而不是在代理/ stub 项目中使用它。这也消耗了 dlldata.c。我很确定自定义 CLR 主机中不需要代理/ stub ,因此只需删除 .c 文件。

关于com - 在 native 中托管 CLR - COM 接口(interface),未解析的外部符号 _CStdStubBuffer_Release@4,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8278722/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com