在C#中使用C com对象 [英] Using C com object in C#

查看:71
本文介绍了在C#中使用C com对象的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已按照本教程简明C中的COM [ ^ ]

并创建并注册了一个com对象,现在我需要在c#中使用这个com对象。我已经尝试过TLBImp来生成一个互操作lib但是得到错误'不是一个有效的lib',我试图使用regsvr32注册.dll(Iexample.dll)但是然后出现错误'找不到DLLRegistryServer入口点'。



现在我应该怎么做才能在我的c#项目中使用它。

i不想使用P / Invoke和C ++ / CLI这种情况。

I have followed this tutorial COM in plain C[^]
and created and registered a com object and now i need to use this com object in c#. i have tried TLBImp to generate a interop lib but getting error 'not a valid lib', i tried to register the .dll (Iexample.dll) using regsvr32 but then error came ' the DLLRegistryServer entry point is not found'.

now what should i do to be able to use it in my c# project.
i do not want to use P/Invoke and C++/CLI for this case.

推荐答案

作为 CPallini [ ^ ]在问题的评论中提到,你必须解决它。试试这个:如何使用Regsvr32工具并解决Regsvr32错误消息 - Regsvr32错误的常见解决方案 [< a href =https://support.microsoft.com/en-us/kb/249873target =_ blanktitle =New Window> ^ ]。



如果需要更改COM组件,这可能会有所帮助:将本机暴露给托管 - C ++ / CLI与P / Invoke [ ^ ]
As CPallini[^] mentioned in the comment to the question, you have to fix it. Try this: How to use the Regsvr32 tool and troubleshoot Regsvr32 error messages - Common solutions for Regsvr32 errors[^].

This might be helpful in case of necessity of changes in COM component: Exposing native to managed - C++/CLI vs. P/Invoke[^]


参见 COM简介 - 它是什么以及如何使用它。 [ ^ 及其后续文章。
See Introduction to COM - What It Is and How to Use It.[^] and its follow on article.


这篇关于在C#中使用C com对象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆