RazorEngineCore icon indicating copy to clipboard operation
RazorEngineCore copied to clipboard

type can't be null

Open snowchenlei opened this issue 3 years ago • 3 comments

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)

snowchenlei avatar Mar 31 '22 13:03 snowchenlei

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

adoconnection avatar Apr 02 '22 11:04 adoconnection

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.

snowchenlei avatar Apr 04 '22 10:04 snowchenlei

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

adoconnection avatar Jul 12 '22 11:07 adoconnection