积极答复者
急啊,传真问题

问题
-
public bool SendFax(string faxFile, string faxNumber, string hostName)
{
FileInfo f = new FileInfo(faxFile);
if (f.Exists)
{
FAXCOMLib.FaxServer faxsvr = null;
FAXCOMLib.FaxDoc faxdoc = null;
try
{
faxsvr = new FAXCOMLib.FaxServer();
faxdoc = (FAXCOMLib.FaxDoc)faxsvr.CreateDocument(f.FullName);
faxsvr.Connect(hostName);
faxdoc.FaxNumber = faxNumber;
int send = faxdoc.Send();
return true;
}
catch
{
return false;
}}
else
{
return false;
}
}
}
---------------------------------------------------------------------------------------------
拒绝访问。 (异常来自 HRESULT:0x80070005 (E_ACCESSDENIED))
说明: 执行当前 Web 请求期间,出现未处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息。异常详细信息: System.UnauthorizedAccessException: 拒绝访问。 (异常来自 HRESULT:0x80070005 (E_ACCESSDENIED))
ASP.NET 未被授权访问所请求的资源。请考虑授予 ASP.NET 请求标识访问此资源的权限。ASP.NET 有一个在应用程序没有模拟时使用的基进程标识(通常,在 IIS 5 上为 {MACHINE}\ASPNET,在 IIS 6 上为网络服务)。如果应用程序正在通过 <identity impersonate="true"/> 模拟,则标识将为匿名用户(通常为 IUSR_MACHINENAME)或经过身份验证的请求用户。
要将 ASP.NET 访问权限授予某个文件,请在资源管理器中右击该文件,选择“属性”,然后选择“安全”选项卡。单击“添加”添加适当的用户或组。突出显示 ASP.NET 帐户,选中所需访问权限对应的框。
源错误:
执行当前 Web 请求期间生成了未处理的异常。可以使用下面的异常堆栈跟踪信息确定有关异常原因和发生位置的信息。
堆栈跟踪:
[UnauthorizedAccessException: 拒绝访问。 (异常来自 HRESULT:0x80070005 (E_ACCESSDENIED))]
FAXCOMLib.FaxServerClass.Connect(String ServerName) +0
DAL.FaxComService.ToSendFax(String faxFile, String faxNumber, String hostName) in G:\企业管理系统v1.0\DAL\FaxComService.cs:84
BLL.FaxComMessage.AddFax(String FaxFile, String FaxNumber) in G:\企业管理系统v1.0\BLL\FaxComMessage.cs:21
AddFaxCom.Button1_Click(Object sender, EventArgs e) +284
System.Web.UI.WebControls.Button.OnClick(EventArgs e) +104
System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +107
System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +7
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +11
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +33
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +5612
--------------------------------------------------------------------------------
版本信息: Microsoft .NET Framework 版本:2.0.50727.42; ASP.NET 版本:2.0.50727.42------------------------------------------------------------------------------------
答案
-
这个组件不是为在服务中运行而设计的,换用其他产品或者在用户登录之后启动一个代理进程进行传真。
The following is signature, not part of post
Please mark the post answered your question as the answer, and mark other helpful posts as helpful.
Visual C++ MVP- 已标记为答案 KeFang Chen 2010年3月8日 5:07
-
是你访问文件权限的问题
1.在配置文件中web.cofig的system.web加入<identity impersonate="true"/>
2. 文件夹 鼠标右键-》属性-》共享-》权限-》加入相应读写权限 (可以加入everyone用户试试)
努力+方法=成功- 已标记为答案 KeFang Chen 2010年3月8日 5:07
全部回复
-
这个组件不是为在服务中运行而设计的,换用其他产品或者在用户登录之后启动一个代理进程进行传真。
The following is signature, not part of post
Please mark the post answered your question as the answer, and mark other helpful posts as helpful.
Visual C++ MVP- 已标记为答案 KeFang Chen 2010年3月8日 5:07
-
是你访问文件权限的问题
1.在配置文件中web.cofig的system.web加入<identity impersonate="true"/>
2. 文件夹 鼠标右键-》属性-》共享-》权限-》加入相应读写权限 (可以加入everyone用户试试)
努力+方法=成功- 已标记为答案 KeFang Chen 2010年3月8日 5:07