We've investigated this some more, and it turns out that the
RuntimeBinderExceptionis absolutely not a concern. It is thrown and handled internally within the C# Runtime Binder.
In other words, the exception doesn't make it out of .NET code, and that's why your code continues to run. Your
AppDomain.FirstChanceExceptionhandler has nothing to do with it. From MSDN: "This event is only a notification. Handling this event does not handle the exception or affect subsequent exception handling in any way."
At first we thought we couldn't reproduce the exception because we didn't see it in the debugger, but that was because Visual Studio is configured to ignore
RuntimeBinderExceptionby default. Once we set up a logging handler similar to yours, we saw it.
The bottom line is that you can use the original simple form:
engine.Script.moduleLoader = new ModuleLoader(engine);
Activator.CreateInstance()and should perform much better.
Thanks for all your help!