Antaris / RazorEngine

Open source templating engine based on Microsoft's Razor parsing engine
http://antaris.github.io/RazorEngine
Other
2.14k stars 577 forks source link

Razor Engine Library throws error on azure function #530

Open talkwaqar opened 6 years ago

talkwaqar commented 6 years ago

I am using RazorEngine Library and it throws error in azure function app when I call compile function

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

Exception

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)
talkwaqar commented 6 years ago

I think this code does not work on azure function https://github.com/Antaris/RazorEngine/blob/aa5dd2661fe040ce39020949ebd33d98a530ebe4/src/source/RazorEngine.Core/Compilation/ReferenceResolver/UseCurrentAssembliesReferenceResolver.cs#L23

csimone86 commented 6 years ago

You are right... I have already solved that... if you look for in the issues you can find my solution... I think someone also implemented it in the last version of razorEngine...

I've found it: https://github.com/Antaris/RazorEngine/issues/528