FAXCOMEXLib和返回类型 [英] FAXCOMEXLib and Return Types

查看:68
本文介绍了FAXCOMEXLib和返回类型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我很久以前在VB 6.0中构建了一个ActiveX控件来方便传真,现在我需要将这个控件有效地转换为C#类库。

I have an ActiveX control I built in VB 6.0 a long time ago to facilitate faxing and now I need to effectively translate this control into a C# class library.

I已经添加了对FAXCOMEXLib库的引用,并且Visual Studio在查看对象,属性和方法时没有任何问题,但是当我编译我的DLL时遇到两个问题。

I've added the reference to the FAXCOMEXLib library and Visual Studio has no problems seeing the objects, Properties, and Methods, but when I compile my DLL I run into two problems.

首先,类库似乎只包含我的库中实际使用的FAXCOMEXLib的属性和方法。这是一个问题,因为我通过只读属性公开COM对象。

Firstly, the class library only seems to contain the properties and methods from FAXCOMEXLib that are actually used within my library. This is a problem because I expose the COM objects through read-only properties.

public FaxServer   Server    {get { return m_Server;  }}
public FaxDocument Document  {get { return m_Document;}}

但如果你调用这些属性并尝试使用返回的对象,只能访问有限数量的方法和属性。我认为这可能是一个编译器选项,可以删除未使用的代码,但我找不到选项
来关闭它。

but if you call those properties and try to use the objects returned, you'll only have access to a limited number of methods and properties. I thought that this could have been a compiler option that cut out code that wasn't used, but I can't find the option to turn it off.

- -----------

-------------

我的第二个问题是FaxServer.Connect()方法根据文档返回一个HRESULT,但是Visual Studio将它视为一个无效回归。我不能拥有这个,因为我需要能够检查使用这个
库的代码中的返回值。

My second problem is that the FaxServer.Connect() method returns an HRESULT according to the documentation, but Visual studio is treating it like a void return. I can't have this because I need to be able to check the return value in the code that uses this library.

  m_Server = new FaxServer();
  if (m_Server.Connect("") == 0) // error CS0019 here
        throw new Exception("Could not connect to Server.");

生成错误CS0019"运算符'=='不能应用于'void'和'int'"

Generates error CS0019 "Operator '==' cannot be applied to operands of type 'void' and 'int'"

我不知道为什么它认为FaxServer.Connect()返回void。

I don't know why it thinks that FaxServer.Connect() returns void.

任何帮助都将非常感谢。

Any help would greatly be appreciated.

谢谢,

推荐答案

您好TheCTutor,

Hi TheCTutor,

感谢您发布此处。

您的问题与VB6有关。 0,您可以在
vb6论坛获得合适的支持。

For your question is related to VB6.0, you could post a new thread in vb6 forum for suitable support.

Visual C#论坛讨论并询问有关C#编程语言,IDE,库,示例和工具的问题。

The Visual C# forum discuss and ask questions about the C# programming language, IDE, libraries, samples, and tools.

最诚挚的问候,

Wendy


这篇关于FAXCOMEXLib和返回类型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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