-
-
Notifications
You must be signed in to change notification settings - Fork 480
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
windows service部署导出word异常 #555
Comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Expected behaviour
windows service部署导出word异常
Actual behaviour
Exception:
System.UnauthorizedAccessException: Access to the path 'C:\WINDOWS\system32\config\systemprofile\AppData\Local\Microsoft\Windows\INetCache\Content.IE5' is denied.
at System.IO.Enumeration.FileSystemEnumerator
1.CreateRelativeDirectoryHandle(ReadOnlySpan
1 relativePath, String fullPath)at System.IO.Enumeration.FileSystemEnumerator
1.MoveNext() at System.Linq.Enumerable.ConcatIterator
1.MoveNext()at System.Linq.Enumerable.SelectEnumerableIterator
2.MoveNext() at System.Linq.Enumerable.TryGetFirst[TSource](IEnumerable
1 source, Boolean& found)at System.Linq.Enumerable.FirstOrDefault[TSource](IEnumerable
1 source) at RazorEngine.Compilation.CompilerServiceBase.GetGeneratorResult(IEnumerable
1 namespaces, TypeContext context)at RazorEngine.Compilation.CompilerServiceBase.GetCodeCompileUnit(TypeContext context)
at RazorEngine.Roslyn.CSharp.RoslynCompilerServiceBase.CompileType(TypeContext context)
at RazorEngine.Templating.RazorEngineCore.CreateTemplateType(ITemplateSource razorTemplate, Type modelType)
at RazorEngine.Templating.RazorEngineCore.Compile(ITemplateKey key, Type modelType)
at RazorEngine.Templating.RazorEngineService.CompileAndCacheInternal(ITemplateKey key, Type modelType)
at RazorEngine.Templating.RazorEngineService.GetCompiledTemplate(ITemplateKey key, Type modelType, Boolean compileOnCacheMiss)
at RazorEngine.Templating.RazorEngineService.RunCompile(ITemplateKey key, TextWriter writer, Type modelType, Object model, DynamicViewBag viewBag)
at RazorEngine.Templating.DynamicWrapperService.RunCompile(ITemplateKey key, TextWriter writer, Type modelType, Object model, DynamicViewBag viewBag)
at RazorEngine.Templating.RazorEngineServiceExtensions.RunCompile(IRazorEngineService service, String name, TextWriter writer, Type modelType, Object model, DynamicViewBag viewBag)
at RazorEngine.Templating.RazorEngineServiceExtensions.<>c__DisplayClass16_0.b__0(TextWriter writer)
at RazorEngine.Templating.RazorEngineServiceExtensions.WithWriter(Action
1 withWriter) at RazorEngine.Templating.RazorEngineServiceExtensions.RunCompile(IRazorEngineService service, String name, Type modelType, Object model, DynamicViewBag viewBag) at RazorEngine.Templating.RazorEngineServiceExtensions.RunCompile(IRazorEngineService service, String templateSource, String name, Type modelType, Object model, DynamicViewBag viewBag) at Magicodes.ExporterAndImporter.Html.HtmlExporter.RunCompileTpl(Object model, String htmlTemplate) at Magicodes.ExporterAndImporter.Html.HtmlExporter.ExportListByTemplate[T](ICollection
1 dataItems, String htmlTemplate)at Magicodes.ExporterAndImporter.Word.WordExporter.ExportListByTemplate[T](String fileName, ICollection
1 dataItems, String htmlTemplate) at MagicodesDemo.Controllers.WeatherForecastController.Get() in E:\Demo\vs2022\MagicodesDemo\MagicodesDemo\Controllers\WeatherForecastController.cs:line 36 at lambda_method4(Closure , Object ) at Microsoft.AspNetCore.Mvc.Infrastructure.ActionMethodExecutor.AwaitableObjectResultExecutor.Execute(IActionResultTypeMapper mapper, ObjectMethodExecutor executor, Object controller, Object[] arguments) at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.<InvokeActionMethodAsync>g__Awaited|12_0(ControllerActionInvoker invoker, ValueTask
1 actionResultValueTask)at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.g__Awaited|10_0(ControllerActionInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Rethrow(ActionExecutedContextSealed context)
at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.InvokeInnerFilterAsync()
--- End of stack trace from previous location ---
at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.g__Awaited|20_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.g__Awaited|17_0(ResourceInvoker invoker, Task task, IDisposable scope)
at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.g__Awaited|17_0(ResourceInvoker invoker, Task task, IDisposable scope)
at Microsoft.AspNetCore.Routing.EndpointMiddleware.g__AwaitRequestTask|6_0(Endpoint endpoint, Task requestTask, ILogger logger)
at Microsoft.AspNetCore.Authorization.AuthorizationMiddleware.Invoke(HttpContext context)
at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.HttpProtocol.ProcessRequests[TContext](IHttpApplication`1 application)
package versions
Example: Magicodes.IE.Word 2.7.5.1
####主要代码
var tplPath = Path.Combine(AppContext.BaseDirectory, "TestFiles", "tpl1.cshtml");
var tpl = System.IO.File.ReadAllText(tplPath);
var exporter = new WordExporter();
//await exporter.ExportListByTemplate(null, GenFu.GenFu.ListOf(), tpl);
var filePath = Path.Combine(AppContext.BaseDirectory, "Temp", "123.docx");
if (System.IO.File.Exists(filePath)) System.IO.File.Delete(filePath);
//此处使用默认模板导出
var result = await exporter.ExportListByTemplate(filePath,
GenFu.GenFu.ListOf(), tpl);
The text was updated successfully, but these errors were encountered: