My unit tests fails when they get here:
var y = AppDomain.CurrentDomain
.GetAssemblies()
.Where(a => !a.GlobalAssemblyCache)
.SelectMany(a => a.GetExportedTypes()
.Where(t => t.IsClass && typeof(ITypeRenderer).IsAssignableFrom(t)))
.ToArray();
But when I run the test with the debugger attached, it does not fail.
I guess it has to do something with reflection permissions and all that jazz, any idea?
The exception is:
Initialization method MyUnitTestProject.UnitTest.Init threw exception. System.NotSupportedException: System.NotSupportedException: The invoked member is not supported in a dynamic assembly..
The exception happens at:
System.Reflection.Emit.InternalAssemblyBuilder.GetExportedTypes()
Thanks.
Well, the error message does say "The invoked member is not supported in a dynamic assembly". Obviously, when you're running the tests outside of the debugger, something is causing a dynamic assembly to be created in the same AppDomain as where the tests are running.
Equally (hopefully) obviously, a check for IsDynamic to exclude such assemblies (in the same way that you exclude GAC assemblies) should avoid the error.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With