Closed kiran198910 closed 3 years ago
@kiran198910 Are you really using RazorLight 1.1?
Yes, I am using Razorlight 1.1.0
Use the 2.0.0-beta10 release please. We're getting very close to an official non-beta release.
On Thu, Sep 24, 2020 at 6:37 PM kiran198910 notifications@github.com wrote:
Yes, I am using Razorlight 1.1.0 [image: Screenshot 2020-09-25 040542] https://user-images.githubusercontent.com/51714857/94207114-8bd1c300-fee4-11ea-813b-bb2b8c9d442a.png
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/toddams/RazorLight/issues/376#issuecomment-698623602, or unsubscribe https://github.com/notifications/unsubscribe-auth/AADNH7K4KMH4A26QDKL4GNLSHPCZXANCNFSM4RYZELOA .
Now I have upgraded RazorLight version to 2.0.0-beta10. I am trying to parse HTML template to string. Here is my code
var engine = new RazorLightEngineBuilder().UseFileSystemProject(HostingEnvironment.MapPath("~/Templates")) .UseMemoryCachingProvider() .Build(); var model = new { Name = "John Doe" }; string result = await engine.CompileRenderAsync("View.cshtml", model);
But Now I am getting error "Value cannot be null.Parameter name: operatingAssembly ". Please advice
On the builder, there is an extension method SetOperatingAssembly
. You can set to to Assembly.GetEntryAssembly()
if that is where you locate your RazorLight assemblies.
I am getting bellow error, do we have any fix of this issue
Method not found: 'System.Collections.Generic.IList`1
@devssharma What version of RazorLight are you using?
@jzabroski i am using RazorLight 2.0.0-beta9 in .net core 3.1 project.
@devssharma In looking at this more carefully, the issue seems to be that in ASP.NET Core 2.x, they removed this interface, and then put it back but marked it as obsolete before the final release.
Compare:
@devssharma Can you provide your full stack trace? We don't directly call this method directly, so it seems like you're referencing Microsoft.Extensions.Caching 2.2 in a .netcoreapp3.1 TFM somehow.
See also: https://github.com/toddams/RazorLight/issues/69#issuecomment-604134253 -- previously another user ran into this library and reported their Nuget Package Manager went haywire and it was not RazorLight that caused the issue. I think that's LIKELY the case here. But you need to get much, much better at providing repro details. You're giving me partial stack traces and no PackageReference or TargetFramework xml.
@jzabroski I tried razor parsing in temporary .net core 3.1 console app, it successfully parsing the razor template. but in actual lambda function (.net core 3.1) not working.
Error:
Method not found: 'System.Collections.Generic.IList`1
Information OS: Windows 10 Platform .NET Core 3.1 RazorLight version : 2.0.0 beta-9 Visual Studio version : VS2019 [16.7.2]
this is what i have written in my project for razor template parsing.
Create a function for parsing the razor template.
async Task
string sqlTmplt = tmpl;
string sql = await razorEngine.CompileRenderStringAsync("templateKey", sqlTmplt, new { OrderID = "123" });
return sql;
}
and i am calling above function from actual lambda function. looks like.
public JObject Process(JObject input, ILambdaContext context) { context.Logger.LogLine("Get Request\n"); string sql = string.Empty;
string tmpl = "select* from OrderTable Where OrderID = @Model.OrderID";
context.Logger.LogLine(tmpl);
Task.Run(async () => { sql = await RazorParsingString(tmpl); }).Wait();
context.Logger.LogLine(sql);
.......
my requirement is just parse the razor template in .NET core 3.1 version. please help me on this
Hi - I don't think I have the time to debug why this won't work on AWS Lambda. Maybe you can open a support request with AWS as to why when you convert a console app to a lambda app, all of a sudden it stops working? This doesn't sounds like a RazorLight problem, and AWS support is pretty good. If they do give you good feedback, I would appreciate it if you could share what they tell you so others benefit.
That said, you probably shouldn't use the ReadyToRun flag with RazorLight, as it dynamically loads dependencies.
@devssharma Did you ever get any help from AWS Support on this?
@jzabroski My problem was resolved with existing library so I didn't contacted them.
Thank you so much for help on this.
Apologies poking the sleeping dog here, but this is literally the only Google result for this issue:
I am now receiving this same error as a regression bug in my project...
Except in my case it's in an Azure Function (.Net Core 3.1 using RazorLight 2.0.0-rc.2) that was previously working properly. I have the following code (which again, was working for months up to a short-time ago):
public static void Init(Assembly entryAssembly, Assembly viewAssembly, string rootNamespace)
{
Engine = new RazorLightEngineBuilder()
.SetOperatingAssembly(entryAssembly)
.UseEmbeddedResourcesProject(viewAssembly, rootNamespace)
.UseMemoryCachingProvider()
.Build();
}
public async Task<string> RenderAsync<TModel>(string viewName, TModel model)
{
string result = await Engine.CompileRenderAsync(viewName, model);
return result;
}
I would welcome any insight. I will likely go into jumping through past versions now and if I find a solution, I will post it here in the hopes that future generations with not suffer the same fate.
Getting error while parsing template as string. There is a bug happened for CreatePhysical. And Error message is Method not found: 'Void Microsoft.Extensions.Caching.Memory.MemoryCacheOptions.set_CompactOnMemoryPressure(Boolean)'.
IRazorLightEngine mail_engine = EngineFactory.CreatePhysical(HostingEnvironment.MapPath("~/Templates"));
I have no idea the reason and how to resolve it.
Information