toddams / RazorLight

Template engine based on Microsoft's Razor parsing engine for .NET Core
Apache License 2.0
1.5k stars 259 forks source link

Could not load type Microsoft.Extensions.Primitives.InplaceStringBuilder when using UseFileSystemProject #503

Closed comparin19 closed 1 year ago

comparin19 commented 1 year ago

When I create a RazorLIghtEngineBuilder using the UseFileSystemProject method, I cannot call CompileRenderAsync without getting this error: Could not load type 'Microsoft.Extensions.Primitives.InplaceStringBuilder' from assembly 'Microsoft.Extensions.Primitives, Version=6.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'.

To Reproduce

var engine = new RazorLightEngineBuilder() .UseFileSystemProject("myFilePath")) .Build();

            string html = await engine.CompileRenderAsync("myFile.cshtml", model);

Expected behavior The html is materialized using the given model.

Information (please complete the following information):

Additional context We are using Microsoft.Extensions.Primitives version 6.0 elsewhere in our application so we cannot install an earlier version. Everything works fine when using the UseEmbeddedResourceProject option, so the .cshtml files and the model are correct.

jzabroski commented 1 year ago

We are using Microsoft.Extensions.Primitives version 6.0 elsewhere in our application so we cannot install an earlier version.

Well, what do you suggest?

RazorLight version 3.02

There is no RazorLight version 3.02

Basic servicing fix was done in https://github.com/toddams/RazorLight/issues/365

comparin19 commented 1 year ago

Very sorry. I was using your RazorLight.NetCore3 package (thus the version 3.0.2). When I switched to the RazorLight (version 2.3.0) package everything works fine.