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

Cannot call Engine.Razor.RunCompile twice in application #573

Open ssharmagithub opened 4 years ago

ssharmagithub commented 4 years ago

i am getting error when i call Engine.Razor.RunCompile twice with two different sql source.

string sql = Engine.Razor.RunCompile(sqlTmplt, Guid.NewGuid().ToString(), null, request);

Error:

Errors while compiling a Template. Please try the following to solve the situation:

The generated source code is: ------------- START ----------- //

pragma warning disable 1591

namespace CompiledRazorTemplates.Dynamic {

line hidden

using System.Threading.Tasks;
using System;
using System.Collections.Generic;
using System.Linq;
internal class RazorEngine_fbe26ed1a83842f9af305e68c4bee0c5 : RazorEngine.Templating.TemplateBase<System.Collections.Generic.IDictionary<System.String, System.Object>>
{
    #pragma warning disable 1998
    public async override global::System.Threading.Tasks.Task ExecuteAsync()
    {
        WriteLiteral("select * from TABLE_NAME  Where OrderID = ");
        WriteLiteral("@0");
    }
    #pragma warning restore 1998
}

}

pragma warning restore 1591

------------- END -----------

List of loaded Assemblies: C:\Program Files\dotnet\shared\Microsoft.NETCore.App\3.1.7\System.Private.CoreLib.dll Loaded Assembly: D:\Users\SHARM22.dotnet\tools.store\amazon.lambda.testtool-3.1\0.10.1\amazon.lambda.testtool-3.1\0.10.1\tools\netcoreapp3.1\any\Amazon.Lambda.TestTool.WebTester31.dll Loaded Assembly: C:\Program Files\dotnet\shared\Microsoft.NETCore.App\3.1.7\System.Runtime.dll Loaded Assembly: D:\Users\SHARM22.dotnet\tools.store\amazon.lambda.testtool-3.1\0.10.1\amazon.lambda.testtool-3.1\0.10.1\tools\netcoreapp3.1\any\Amazon.Lambda.TestTool.dll Loaded Assembly: C:\Program Files\dotnet\shared\Microsoft.NETCore.App\3.1.7\System.Runtime.Extensions.dll Loaded Assembly: C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App\3.1.7\Microsoft.AspNetCore.Mvc.Core.dll Loaded Assembly: C:\Program Files\dotnet\shared\Microsoft.NETCore.App\3.1.7\System.Console.dll Loaded Assembly: C:\Program Files\dotnet\shared\Microsoft.NETCore.App\3.1.7\System.Threading.dll Loaded Assembly: C:\Program Files\dotnet\shared\Microsoft.NETCore.App\3.1.7\System.Text.Encoding.Extensions.dll Loaded Assembly: C:\Program Files\dotnet\shared\Microsoft.NETCore.App\3.1.7\System.IO.FileSystem.dll Loaded Assembly: C:\Program Files\dotnet\shared\Microsoft.NETCore.App\3.1.7\System.Diagnostics.Debug.dll Loaded Assembly: C:\Program Files\dotnet\shared\Microsoft.NETCore.App\3.1.7\System.Linq.dll Loaded Assembly: C:\Program Files\dotnet\shared\Microsoft.NETCore.App\3.1.7\System.Memory.dll Loaded Assembly: C:\Program Files\dotnet\shared\Microsoft.NETCore.App\3.1.7\System.Runtime.InteropServices.dll Loaded Assembly: C:\Program Files\dotnet\shared\Microsoft.NETCore.App\3.1.7\System.Collections.dll Loaded Assembly: C:\Program Files\dotnet\shared\Microsoft.NETCore.App\3.1.7\System.Runtime.Loader.dll .......................................

mageshn18 commented 5 months ago

Did you find what caused the issue. I am running into a similar issue now in Prod.

mageshn18 commented 5 months ago

error: (9, 89) The type 'TemplateBase' exists in both 'RazorEngine.NetCore, Version=0.0.0.0, Culture=neutral, PublicKeyToken=9ee697374c7e744a' and 'RazorEngine, Version=3.2.0.0, Culture=neutral, PublicKeyToken=9ee697374c7e744a' error: (12, 66) 'RazorEngine_fbe26ed1a83842f9af305e68c4bee0c5.ExecuteAsync()': no suitable method found to override

We found the issue , we had both the dlls present in the deployed folder. causing the issue.

image