作者热门文章
- iOS/Objective-C 元类和类别
- objective-c - -1001 错误,当 NSURLSession 通过 httpproxy 和/etc/hosts
- java - 使用网络类获取 url 地址
- ios - 推送通知中不播放声音
我有一个注册为 COM Interop 的 C# Dll:
[Guid("B41C2229-DBBD-4614-AE28-BFAE82B10F20")]
[InterfaceType(ComInterfaceType.InterfaceIsDual)]
public interface ITestCls
{
[DispId(1)]
string test(string input);
}
[Guid("5E88B6B8-AE17-40A0-917A-51DEBD818145")]
[ClassInterface(ClassInterfaceType.None)]
[ProgId("TestNm.TestCls")]
public class TestCls : ITestCls
{
public string test(string input)
{
Console.WriteLine("INSIDE CS :: ");
return "CS :: ARE YOU TESTING WITH THIS INPUT " + input;
}
}
我试图从我的 C++ 代码中调用相同的方法:
CoInitialize(NULL);
std::cout << data << '\n';
_bstr_t bstrt(data);
BSTR lResult;
CComQIPtr<IWPrint> iWrapClass;
HRESULT hresult;
hresult = iWrapClass.CoCreateInstance(L"TestNm.TestCls");
printf("0x%08lx", hresult);
if (SUCCEEDED (hresult))
{
iWrapClass->test(bstrt,&lResult);
wprintf(L"Response %s\n", lResult);
}
CoUninitialize();
return lResult;
当我从其他机器运行相同的 HRESULT 时,我的开发机器一切正常:
0x800401f3
我是否遗漏了一些注册信息?
谢谢
最佳答案
故障排除时要尝试的几件事:
RegAsm.exe/codebase
在目标机器上注册它(为此需要一个强大的程序集名称)。关于c# - 0x800401f3 COMInterop Dll 类字符串无效,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17673418/
我有一个注册为 COM Interop 的 C# Dll: [Guid("B41C2229-DBBD-4614-AE28-BFAE82B10F20")] [InterfaceType(ComI
我正在构建一个 C# UI 来与 COM 服务 (.exe) 交互。 VS2005 COM 项目输出一个有效的类型库 (TLB),它被 C# 项目引用。然而,VS2005 C# 项目坚持要注册服务才能
我有一个用于一些简单数学实用程序的 COM 对象。其中,它导出 2 个接口(interface) - IDL 如下: interface IUnivariateFunction : IDispatch
我有一个非托管 DLL,我目前正在使用 COM 类包装器从 C# 调用它。 [ComImport(), Guid("75E81043-CAD5-11D3-800D-00105A5E2FA0")] pu
我是一名优秀的程序员,十分优秀!