adoconnection / RazorEngineCore

.NET6 Razor Template Engine
MIT License
583 stars 88 forks source link

type can't be null #102

Closed snowchenlei closed 2 months ago

snowchenlei commented 2 years ago
IRazorEngine razorEngine = new RazorEngine();
IRazorEngineCompiledTemplate template = razorEngine.Compile("Hello @Model.Name");

string result = template.Run(new
{
    Name = "Alexander"
});

catch error:type can't be null

   in System.Activator.CreateInstance(Type type, Boolean nonPublic)
   in System.Activator.CreateInstance(Type type)
   in RazorEngineCore.RazorEngineCompiledTemplate`1.<RunAsync>d__12.MoveNext()
   in System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   in System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   in RazorEngineCore.RazorEngineCompiledTemplate`1.Run(Action`1 initializer)
adoconnection commented 2 years ago

this is basic example known to be working, there is something on your side.

snowchenlei commented 2 years ago

please try:

  1. create new VSIX Project use VS
  2. import RazorEngineCore.nuget
  3. add new file ==>Extensibility==>Command
  4. add test code in Execute(object sender, EventArgs e)
  5. run. you will get error.
adoconnection commented 2 years ago

Hi @snowchenlei unfortunately I had no time to try VSIX 😅 did you succeeded?