Reputation: 3706
This problem occurs locally only, on a WCF based web api project running in IISExpress. It happens fairly randomly.
"An unhandled exception of type 'System.ExecutionEngineException' occurred in SimpleInjector.dll"
This occurs when I do container.Verify()
Any ideas what might cause this, or how to debug it?
Upvotes: 3
Views: 325
Reputation: 172826
The ExecutionEngineException
is usually caused by profiling tools such as:
But I've seen this been caused by Microsoft's test runner (MSTest) as well.
Limitations (or flaws) in those tools, cause them to be unable to cope with dynamic assembly compilation. Dynamic assembly compilation is what Simple Injector uses to optimize performance.
The most effective way to deal with this (without having to change anything to the profiling or testing tools that you use) is to disable Simple Injector's dynamic assembly compilation as follows:
container.Options.EnableDynamicAssemblyCompilation = false;
This means that the delegates that Simple Injector will compile will be created using Lightweight Code Generation (which is slightly slower, but nothing to worry about) instead of creating a new in-memory assembly.
Another option is to disable tools like IntelliTrace or dotTrace, but this isn't always an option of course. In case of MSTest, you can also disable its 'Keep Test Execution Engine Running' functionality.
Side note: There's an old issue on the old Codeplex site that describes the problem and the solution. Unfortunately, due to many mistakes by the Codeplex team, this issue can't be found by Googling, and the issue has become unreadable over time.
Upvotes: 3