C#创建对象 [英] C# create object

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

问题描述

大家好,
我正在使用我们供应商之一的COM对象,这需要我调用createobject.这是他们文档中的源代码.

----文档中的VB代码
将rfFaxAPI昏暗为RFCOMAPILib.FaxServer
设置rfFaxAPI =新的FaxServer
将newFax调暗为RFCOMAPILib.Fax
设置newFax = rfFaxAPI.CreateObject(coFax)

任何人都可以建议我如何在C#中创建对象,但供应商的com对象没有在C#中提供此选项.

Hi guys,
I am using a COM object from one of our vendors which requires me to call createobject; here is the source code from their documentation.

----VB Code from documentation
Dim rfFaxAPI As RFCOMAPILib.FaxServer
Set rfFaxAPI = New FaxServer
Dim newFax As RFCOMAPILib.Fax
Set newFax = rfFaxAPI.CreateObject(coFax)

Can anyone advice how I could create object in C#, the com object from the vendor is not giving me this option in C#. Please help!!!

推荐答案

如果您已将库导入到C#中并且此选项被隐藏,则很有可能会出现问题.由于命名约定不佳,C#假定这是一个内部调用,不应公开.如果您不能直接在C#中创建此对象,则可能无法执行此操作.一种选择可能是编写一个C ++/CLI dll,该DLL会正确创建该对象并将其返回给C#,在此导入的COM dll将为您提供接收和使用它所需的类.
There''s a fair chance that if you''ve imported the library in to C# and this option is hidden, it''s because of their poor naming convention and C# is assuming this is an internal call that should not be exposed. If you can''t create this object directly in C#, you may not be able to do this. One option may be to write a C++/CLI dll which creates the object properly and returns it to C#, where your imported COM dll will give you the classes you need to receive and work with it.


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

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