c# - Razor 引擎库在 azure 函数上引发错误

标签 c# azure azure-functions razorengine

我正在使用RazorEngine当我调用编译函数时,库会在 azure 函数应用程序中引发错误

service.Compile(name: "TemplateMaster", modelType: modelType);

异常

Message: The given path's format is not supported.
     at System.Security.Util.StringExpressionSet.CanonicalizePath(String path, Boolean needFullPath)
       at System.Security.Util.StringExpressionSet.CreateListFromExpressions(String[] str, Boolean needFullPath)
       at System.Security.Permissions.FileIOPermission.AddPathList(FileIOPermissionAccess access, AccessControlActions control, String[] pathListOrig, Boolean checkForDuplicates, Boolean needFullPath, Boolean copyPathList)
       at System.Security.Permissions.FileIOPermission..ctor(FileIOPermissionAccess access, String path)
       at System.Reflection.RuntimeAssembly.get_Location()
       at RazorEngine.Compilation.ReferenceResolver.UseCurrentAssembliesReferenceResolver.<>c.<GetReferences>b__0_0(Assembly a)
       at System.Linq.Enumerable.WhereArrayIterator`1.MoveNext()
       at System.Linq.Lookup`2.Create[TSource](IEnumerable`1 source, Func`2 keySelector, Func`2 elementSelector, IEqualityComparer`1 comparer)
       at System.Linq.GroupedEnumerable`3.GetEnumerator()
       at System.Linq.Enumerable.WhereSelectEnumerableIterator`2.MoveNext()
       at System.Linq.Enumerable.<ConcatIterator>d__59`1.MoveNext()
       at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)
       at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
       at RazorEngine.Compilation.CompilerServiceBase.GetAllReferences(TypeContext context)
       at RazorEngine.Compilation.DirectCompilerServiceBase.Compile(TypeContext context)
       at RazorEngine.Compilation.DirectCompilerServiceBase.CompileTypeImpl(TypeContext context)
       at RazorEngine.Compilation.DirectCompilerServiceBase.CompileType_Windows(TypeContext context)
       at RazorEngine.Compilation.DirectCompilerServiceBase.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.Compile(ITemplateKey key, Type modelType)
       at RazorEngine.Templating.DynamicWrapperService.Compile(ITemplateKey key, Type modelType)
       at RazorEngine.Templating.RazorEngineServiceExtensions.Compile(IRazorEngineService service, String name, Type modelType)

最佳答案

错误消息是不言自明的。传入的路径不正确。如果它是在运行时编译的动态 View ,请向我们提供您正在使用的 View 的路径副本,以便我们帮助您识别问题。

关于c# - Razor 引擎库在 azure 函数上引发错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52017632/

相关文章:

Azure 网站和事件日志

c# - 是否可以在 Azure 函数中保留环境设置?

c# - Azure函数: Is there optimal way to upload file without storing it in process memory?

Azure函数: Is it possible to subscribe to multiple topics?

c# - Entity Framework 代码优先 - 具有连接/链接表的一对多

c# - 替换是/否/取消 MessageBox (C#)

azure - 是否可以将自定义 DNS 条目添加到 Service Fabric DNS 服务

c# - Persistent AuthCookie 已设置但被重定向到登录

c# - WPF 弹出窗口

azure - 我的 Azure 应用服务是否可以使用不同的身份验证提供程序?