Problem with FaxComExLib
本文关键字:FaxComExLib with Problem | 更新日期: 2023-09-27 18:09:45
我可以使用FAXCOMLib成功传真消息。现在我尝试使用FAXCOMEXLib,但我有问题:/
这是代码(来自MSDN VB示例):
try
{
FaxServer objFaxServer = new FaxServer();
FaxDocument objFaxDocument = new FaxDocument();
object JobID;
objFaxServer.Connect(Environment.MachineName);
objFaxDocument.Body = "test.bmp";
objFaxDocument.DocumentName = "Test name";
objFaxDocument.Recipients.Add("xxxxxxx", "Name");
objFaxDocument.AttachFaxToReceipt = true;
objFaxDocument.CoverPageType = FAXCOMEXLib.FAX_COVERPAGE_TYPE_ENUM.fcptSERVER;
objFaxDocument.CoverPage = "generic";
objFaxDocument.Note = "Here is the info you requested";
objFaxDocument.ReceiptAddress = "someone@example.com";
objFaxDocument.ReceiptType = FAXCOMEXLib.FAX_RECEIPT_TYPE_ENUM.frtMAIL;
objFaxDocument.ScheduleType = FAXCOMEXLib.FAX_SCHEDULE_TYPE_ENUM.fstNOW;
objFaxDocument.Subject = "Today's fax";
objFaxDocument.Sender.Title = "Mr.";
objFaxDocument.Sender.Name = "Bob";
objFaxDocument.Sender.City = "Cleveland Heights";
objFaxDocument.Sender.State = "Ohio";
objFaxDocument.Sender.Company = "Microsoft";
objFaxDocument.Sender.Country = "USA";
objFaxDocument.Sender.Email = "someone@microsoft.com";
objFaxDocument.Sender.FaxNumber = "12165555554";
objFaxDocument.Sender.HomePhone = "12165555555";
objFaxDocument.Sender.OfficeLocation = "Downtown";
objFaxDocument.Sender.OfficePhone = "12165555553";
objFaxDocument.Sender.StreetAddress = "123 Main Street";
objFaxDocument.Sender.TSID = "Office fax machine";
objFaxDocument.Sender.ZipCode = "44118";
objFaxDocument.Sender.BillingCode = "23A54";
objFaxDocument.Sender.Department = "Accts Payable";
JobID = objFaxDocument.ConnectedSubmit(objFaxServer);
MessageBox.Show(("The Job ID is :" + JobID.ToString()),"Finished");
objFaxServer.Disconnect();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message.ToString() + ". " + ex.ToString(), "Exception");
}
在该行抛出异常:FaxServer objFaxServer = new FaxServer();
无法强制转换'System '类型的COM对象。__ComObject'到接口类型'FAXCOMEXLib.FaxServer'。
当我这样做时: FaxServer objFaxServer = new FaxServerClass();
我甚至不能编译这一行。显示: Interop type 'FAXCOMEXLib.FaxServerClass' cannot be embedded. Use the applicable interface instead.
所以,我停在那一行:/
顺便说一句。基本上,我想实现一个类,它将发送传真并监视发送消息的状态。我将非常非常高兴,如果有人送一个完整的准备使用类。
请帮帮我,
当我这样做:FaxServer objFaxServer = new FaxServerClass();我甚至不能编译那行
COM对象的奇怪之处在于接口有时表现得好像它们有构造函数:
FaxServer objFaxServer = new FaxServer();
这是正确的行。我把它装在我的手机上,很好用。交互操作可能有问题
请执行以下步骤来解决此问题:
- 从解决方案资源管理器的参考中选择FAXCOMEXLib。<<li>打开属性/gh>
- 设置"启用互操作类型"为False。