C# 试图查看已完成事件时拒绝访问

C# 试图查看已完成事件时拒绝访问,c#,com,access-denied,rightfax,C#,Com,Access Denied,Rightfax,我们目前正在使用RightFax v9.3.2.89和rfcomlib API。目前,我们只是在每个人的计算机上安装RightFax,因为生成这些传真的应用程序位于桌面上。由于我们正在转向web解决方案,因此我们将只在服务器上安装RightFax。问题是,用户将无法看到传真是否成功发送。看看API,我可以做如下事情: faxServer.Events.WatchCompleteEvents = BoolType.True; faxServer.OnCompleteEvent += faxServ

我们目前正在使用RightFax v9.3.2.89和rfcomlib API。目前,我们只是在每个人的计算机上安装RightFax,因为生成这些传真的应用程序位于桌面上。由于我们正在转向web解决方案,因此我们将只在服务器上安装RightFax。问题是,用户将无法看到传真是否成功发送。看看API,我可以做如下事情:

faxServer.Events.WatchCompleteEvents = BoolType.True;
faxServer.OnCompleteEvent += faxServer_OnCompleteEvent;
问题是,当我订阅观看已完成的活动时,我得到了

Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED))
浏览网页时,我发现这个错误可能来自一百万个来源。这很奇怪,因为我对我的电脑有管理权

有什么想法吗


不幸的是,RightFax站点毫无用处,而且几乎没有可用的资源。

我注意到,当使用Ben的上述方法时,状态描述从未更新。下面的示例将永远休眠,显示“等待转换”状态,即使在FaxUtil中传真已明确发送且状态为“确定”


我要强调的是,RightFax API没有文档,很难使用。我希望这有助于原始海报。

轮询fax.StatusDescription将使程序陷入无限循环。您需要做的是重复轮询有问题的传真对象。以下示例获取特定文件夹中的所有传真对象,标识所需的一个传真对象,并查询该对象的状态描述

string status = "";
string description = "";
int handle = fax.Handle; // this identifies the fax object you're polling for
while (status != "fsDoneOK") // keep polling fax object until status is "OK"
{    
    foreach (Fax obj_fax in obj_user.Folders["Main"].Faxes) // look in the "Main" folder for fax objects
    {
        if (handle == obj_fax.Handle) // check to see if this object is yours
        {
            status = obj_fax.FaxStatus.ToString();
            description = obj_fax.StatusDescription;
            System.Diagnostics.Debug.WriteLine("Fax Status: " + obj_fax.StatusDescription);
        }
        if (status == "fsDoneError" || status == "fsError") // check for fax error
            break;
    }
    if (status == "fsDoneError" || status == "fsError") // check for fax error
        break;  
    Thread.Sleep(3000); // sleep for 3 seconds and then poll again
}

这看起来像是DCOM配置错误。我的主要建议是每5-10秒进行一次状态调查,而不是订阅活动,因为它在面对不可靠的网络时会更加强大。哇。这要容易得多。我只需获取由其句柄发送的传真,然后查看
StatusDescription
是什么。如果你把你的评论作为回答,我会欣然接受。非常感谢。
string status = "";
string description = "";
int handle = fax.Handle; // this identifies the fax object you're polling for
while (status != "fsDoneOK") // keep polling fax object until status is "OK"
{    
    foreach (Fax obj_fax in obj_user.Folders["Main"].Faxes) // look in the "Main" folder for fax objects
    {
        if (handle == obj_fax.Handle) // check to see if this object is yours
        {
            status = obj_fax.FaxStatus.ToString();
            description = obj_fax.StatusDescription;
            System.Diagnostics.Debug.WriteLine("Fax Status: " + obj_fax.StatusDescription);
        }
        if (status == "fsDoneError" || status == "fsError") // check for fax error
            break;
    }
    if (status == "fsDoneError" || status == "fsError") // check for fax error
        break;  
    Thread.Sleep(3000); // sleep for 3 seconds and then poll again
}