gpt4 book ai didi

c# - 如何设置 JsReport .NET 以使用当前应用程序文件夹

转载 作者:行者123 更新时间:2023-12-05 03:03:05 25 4
gpt4 key购买 nike

有没有办法设置 JsReport 使用当前应用程序文件夹来存储临时文件。不使用公共(public)文件夹 C:\Windows\Temp\jsreport?如果在普通 IIS 上运行多个应用程序,则会产生错误。

Error rendering report: A critical error occurred while trying to execute the render command: An error occurred while trying to start daemonized process: An error has occurred when trying to initialize jsreport (2). EBUSY: resource busy or locked, open 'C:\WINDOWS\TEMP\jsreport\compile\jsreport-2.2.0-r17qQMiI7\chrome\chrome.dll' (1). caused by error (2) -> stack = Error: at instance.init.then.catch ([eval]:43623:29) at tryCatcher (jsreportRuntime.js:146030:23) at Promise._settlePromiseFromHandler (jsreportRuntime.js:145723:31) at Promise._settlePromise (jsreportRuntime.js:145780:18) at Promise._settlePromise0 (jsreportRuntime.js:145825:10) at Promise._settlePromises (jsreportRuntime.js:145900:18) at Async._drainQueue (jsreportRuntime.js:41845:16) at Async._drainQueues (jsreportRuntime.js:41855:10) at Immediate.Async.drainQueues (jsreportRuntime.js:41729:14) at runCallback (timers.js:794:20) at tryOnImmediate (timers.js:752:5) at processImmediate [as _immediateCallback] (timers.js:729:5)caused by error (1) -> meta = {"errno":-4082,"code":"EBUSY","syscall":"open","path":"C:\WINDOWS\TEMP\jsreport\compile\jsreport-2.2.0-r17qQMiI7\chrome\chrome.dll"}, stack = Error: (1). caused by error (1) -> stack = Error: at exports.NsSocket.socket.dataOnce ([eval]:44008:13) at exports.NsSocket.listener ([eval]:16744:10) at exports.NsSocket.EventEmitter.emit ([eval]:16832:22) at exports.NsSocket._onData ([eval]:86359:8) at Lazy. ([eval]:51602:13) at Lazy. ([eval]:51584:19) at emitTwo (events.js:126:13) at Lazy.emit (events.js:214:7) at Lazy. ([eval]:51585:22) at emitOne (events.js:116:13) at Lazy.emit (events.js:211:7) at yieldTo ([eval]:51692:18) at Function. ([eval]:51730:27) at Lazy. ([eval]:51698:21) at emitOne (events.js:116:13) at Lazy.emit (events.js:211:7)

最佳答案

需要在RegisterGlobalFilters的FilterConfig中配置,所以会在当前app文件夹下创建jsreport文件夹,这样jsreport.exe不会干扰其他实例。关键属性是 TempDirectory,它定义了临时文件夹的位置。此 TempDirectory 中的所有文件都是自动创建的。

public static void RegisterGlobalFilters(GlobalFilterCollection filters)
{
filters.Add(new HandleErrorAttribute());

var tempPath = Path.Combine(HttpRuntime.AppDomainAppPath, "jsreport");

filters.Add(new JsReportFilterAttribute(new LocalReporting()
.Configure(cfg =>
{
cfg.BaseUrlAsWorkingDirectory();
cfg.TempDirectory = tempPath;
return cfg;
})
.UseBinary(JsReportBinary.GetBinary())
.AsUtility()
.Create()));
}

关于c# - 如何设置 JsReport .NET 以使用当前应用程序文件夹,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54201338/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com