0

I'm trying to use RazorEngine to generate a FlowDocument in a WPF Application.

Including, and using, RazorEngine in the application seems to work fine, but as soon as I try to use it in a testproject, I get the following exception:

System.Security.VerificationException: Operation could destabilize the runtime.

Stacktrace:

System.Web.Razor.CSharpRazorCodeLanguage..ctor()
RazorEngine.Compilation.CSharp.CSharpRazorCodeLanguage..ctor(Boolean strictMode)
RazorEngine.Compilation.CSharp.CSharpDirectCompilerService..ctor(Boolean strictMode, Func`1 markupParserFactory)
RazorEngine.Compilation.DefaultCompilerServiceFactory.CreateCompilerService(Language language)
RazorEngine.Templating.TemplateService.CreateTemplateType(String razorTemplate, Type modelType)
RazorEngine.Templating.TemplateService.CreateTemplateType(String razorTemplate)
RazorEngine.Templating.TemplateService.CreateTemplate(String razorTemplate)
RazorEngine.Templating.TemplateService.Parse(String razorTemplate)
RazorEngine.Razor.Parse(String razorTemplate)
TestProject1.UnitTest1.TestMethod1() in c:\users\vvi\documents\visual studio 2010\Projects\RazorEngineSpike\TestProject1\UnitTest1.cs: line 17

I have tried to look at potential solutions to VerificationException problems described elsewhere without any luck.

Does anyone have any clue of why this exception is thrown, and what I can do to prevent it?

Update: Running the test with TestDriven.Net works ok, but the standard VS and R# testrunners fail. I also tried to create a similar project at home, and there it seems to work ok, so something in the developer environment seems to be the cause. This question seems very similar, but unfortunately I have no IntelliTrace to disable...

Community
  • 1
  • 1
Vegar
  • 12,828
  • 16
  • 85
  • 151

1 Answers1

0

Turned out is was TypeMock that caused this error. By disabling TypeMock, the test runs without failure.

Vegar
  • 12,828
  • 16
  • 85
  • 151