首页 新闻 会员 周边

webservice 调用 fastreport 打印拒绝访问,超时问题。

0
悬赏园豆:100 [已解决问题] 解决于 2013-08-06 17:29

我的webservice程序在本地调试使用fastereport的print()打印,可以正常打印。但是把程序发布到IIs,就出现操作超时的错误。部署到服务器的IIS 还出现 如下错误提示的错误,请问有人知道是什么原因吗?权限问题?怎么改?

System.TypeInitializationException: “FastReport.Report”的类型初始值设定项引发异常。
---> System.UnauthorizedAccessException:
对路径“C:\Documents and Settings\Default User\Local Settings\Application Data\FastReport\”的访问被拒绝。
在 System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
在 System.IO.Directory.InternalCreateDirectory(String fullPath, String path, DirectorySecurity dirSecurity)
在 System.IO.Directory.CreateDirectory(String path, DirectorySecurity directorySecurity)
在 FastReport.Utils.Config.PUS0qCT14()
在 FastReport.Utils.Config.TW3y49nvh()
在 FastReport.Report..cctor()

……

xixi8820的主页 xixi8820 | 初学一级 | 园豆:112
提问于:2013-08-05 16:48
< >
分享
最佳答案
0

System.UnauthorizedAccessException

权限问题,简单的测试下,在你的应用程序池上,将应用程序标识修改为 LocalSystem 或 NetworkService 测试下。然后还原。

再然后,在目录 C:\Documents and Settings\Default User\Local Settings\Application Data\FastReport 上添加你的应用程序池标识用户(ApplicationPoolIdentity)(一个比较长的复杂字符串),然后把对应的读写权限勾上。

收获园豆:100
Launcher | 高人七级 |园豆:45045 | 2013-08-05 16:54

我在 C:\Documents and Settings\Default User\Local Settings\Application Data下找不到FastReport 

xixi8820 | 园豆:112 (初学一级) | 2013-08-05 17:00

@xixi8820: 自己建一个 C:\Documents and Settings\Default User\Local Settings\Application Data\FastReport

Launcher | 园豆:45045 (高人七级) | 2013-08-05 17:02

不好意思啊,没大看懂你的这个解决方法,没找到在哪里修改应用程序标识localSystem...还有“应用程序池标识用户(ApplicationPoolIdentity)(一个比较长的复杂字符串)”这个在哪里啊?可以再详细一点吗

xixi8820 | 园豆:112 (初学一级) | 2013-08-05 17:32

@Launcher: 谢谢啊,我现在先在我本地的IIS上测试,我把应用程序标识改为“本地系统”或者“网络服务”浏览器左下角总是“正在等待losthost的响应……”这是怎么回事啊?

xixi8820 | 园豆:112 (初学一级) | 2013-08-06 14:17

@xixi8820: 有可能是等待服务器查找打印机。

Launcher | 园豆:45045 (高人七级) | 2013-08-06 14:28

@Launcher: 可是一直没有能打印出来,如果我用程序调试的话,完全没有问题,一下子就打印出来了,一发布到IIS就是等待。。我的是 IIS6。对了,我本地IIS没有提示什么拒绝访问的错误,只是一直等待,超时。这个也是因为权限问题吗?

xixi8820 | 园豆:112 (初学一级) | 2013-08-06 14:37

@xixi8820: 是的,权限问题。如果是 IIS6 的话,你把你的网站部署到 C:\inetpub\wwwroot 下试试

Launcher | 园豆:45045 (高人七级) | 2013-08-06 14:39

@Launcher: 好的,我试试。谢谢你

xixi8820 | 园豆:112 (初学一级) | 2013-08-06 14:43

@Launcher: 唉。。还是不行呀

xixi8820 | 园豆:112 (初学一级) | 2013-08-06 15:44

@xixi8820: 权限问题,你要是能写一个 html 页面直接调用客户端打印机的,我可以帮你调试。

Launcher | 园豆:45045 (高人七级) | 2013-08-06 15:52

@Launcher:太谢谢了, 你邮箱多少呢?我写一个发给你。

xixi8820 | 园豆:112 (初学一级) | 2013-08-06 16:02

@xixi8820: 你直接把代码贴这里就行

Launcher | 园豆:45045 (高人七级) | 2013-08-06 16:03

@Launcher: 我是asp.net 程序写的,我把测试代码贴给你看看行不行,这里面需要一个fastReport.dll

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.IO;

using FastReport;

namespace TestWebApplication
{
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
Print("12345678");
}

public void Print(string code)
{
Report report = new Report();
string MFile = Server.MapPath(".") + @"\Reports\barcode.frx";

if (File.Exists(MFile))
{
report.Load(MFile);
}

DataTable _dt = new DataTable();
_dt.Columns.Add("bx");
DataRow row = _dt.NewRow();
row[0] = "123";
_dt.Rows.Add(row);

report.RegisterData(_dt, "tbMain");
report.SetParameterValue("PCode", code);//给参数赋值(条码)
report.PrintSettings.ShowDialog = false;//不弹出打印设置框

//打印
report.Print();
report.Dispose();
}
}
}

xixi8820 | 园豆:112 (初学一级) | 2013-08-06 16:18

@xixi8820: 我没有fastReport.dll,这样吧。你把你这个页面的内容都注释掉,改为这样:

Directory.Create(C:\Documents and Settings\Default User\Local Settings\Application Data\FastReport);

异常表明,System.IO.Directory.CreateDirectory(String path, DirectorySecurity directorySecurity) 方法未授权,所以先简化问题,直接在你的测试页面中去创建这个目录。如果产生同样的错误,我们再来说如果给 IIS 权限写磁盘。

注意,这里的 Create 动作是发生在服务器上的,也就是部署IIS的机器。

Launcher | 园豆:45045 (高人七级) | 2013-08-06 16:22

@Launcher: 改成:Directory.CreateDirectory(@"C:\Documents and Settings\Default User\Local Settings\Application Data\FastReport"); 没有报错,可以正常创建

xixi8820 | 园豆:112 (初学一级) | 2013-08-06 16:33

@xixi8820: 那你再运行你原来的页面呢?

Launcher | 园豆:45045 (高人七级) | 2013-08-06 16:43

@Launcher: 浏览器一直是“正在等待losthost响应”

xixi8820 | 园豆:112 (初学一级) | 2013-08-06 16:58
Launcher | 园豆:45045 (高人七级) | 2013-08-06 17:03

@Launcher: 虽然还没解决,两天了,我还是结贴吧,如果方便的话,我把测试代码发给你,告诉我邮箱地址。你帮我测试看看是什么问题。谢谢了

xixi8820 | 园豆:112 (初学一级) | 2013-08-06 17:27

@xixi8820: wl@txsec.com

Launcher | 园豆:45045 (高人七级) | 2013-08-06 17:34

@xixi8820: 你的测试代码我咋没收到呢?

Launcher | 园豆:45045 (高人七级) | 2013-08-07 09:59
其他回答(1)
0

你的版本太旧了,建议使用FastReport最新版

cpu占用率过高 | 园豆:203 (菜鸟二级) | 2013-08-29 16:36
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册