如何为类型库转换制作合适的.DLL
How To Make A Suitable .DLL for type-library conversion
我的 COM 类型库.tlb
(由.NET v4+
regasm
生成)中存在不完整的类型,我不确定这是因为cppc.exe
派生了错误的标头,还是这只是它的症状。 我知道这是不完整的,因为所有生成的类都以 a. 作为struct
s 和 b. 的空接口主体(未定义方法)。
我敢肯定,在使我的.dll适合加油时,我做错了什么;我已经更改了程序集信息,并为所有类型的构造函数制作了默认构造函数。我是否打算做其他事情?
如果将程序集标记为 COM 可见,则在dispinterface
的帮助下,所有具有默认构造函数的公共类都会公开。此接口类型专为后期绑定客户端(如脚本语言)而设计,这些客户端通过调度标识符 (DISPID) 调用方法和属性。随附的类型库不包含接口的任何条目。
为了绑定到固定布局,您需要切换到dual
或IUnknown
界面。只需按如下方式编辑您的AssemblyInfo.cs
:
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(true)]
[assembly: ClassInterface(ClassInterfaceType.AutoDual)]
现在,接口的方法在类型库和智能感知中可见。
但请注意,对于AutoDual
公开的类,在更新程序集时需要小心。有关详细信息,请参阅此链接。
相关文章:
- 从DLL导出函数,LoadLibrary()需要用TEXT转换的字符串才能编译而不会出错
- "reinterpret_cast":无法通过速推从'overloaded-function'转换为'intptr_t'.dll
- 如何将我的程序转换为.dll文件并使用rundll32.exe在cmd中运行它?
- 随机字符,从强制转换 Arduino 字符串到 Excel BSTR 通过 c++ DLL
- 将标头和 lib 转换为 dll 以将其与 c# 一起使用
- Unity 如何使用本机 dll 或转换为托管
- 将std ::向量转换为阵列和当时的p/调用它会导致访问违规例外,在编组期间mscorlib.dll
- 将静态库转换为 DLL 会导致在 main 之前出现访问冲突
- 如何使用Cmake为SimuroSot模拟器构建(从DevCpp转换)Win32 DLL
- 如何为类型库转换制作合适的.DLL
- 尝试生成C++ .DLL的视觉对象类型/转换错误
- 如何将软件转换为 DLL
- 使用ITK或OpenCV库将现有的VC++项目转换为DLL是可能的吗
- DLL到EXE的转换?[C++]
- 如何将 C 函数签名转换为 C# 并在本机 DLL 中调用该函数
- 使用从导入库(.lib)转换的库文件(.a),使用gcc构建dll
- 引用VC++代码或转换为DLL
- 匆忙将"MFC Extension DLL"转换为"Regular DLL with MFC statically linked"
- 如何将DLL转换成c++代码
- 如何将资源仅DLL转换为十六进制格式*.cpp文件