I have some tests that load types by name using Type.ReflectionOnlyGetType. When NCrunch runs them, I get this exception:
System.IO.FileLoadException : ReflectionOnlyAssemblyResolve handlers must return Assemblies loaded for reflection only.
at System.RuntimeTypeHandle.GetTypeByName(String name, Boolean throwOnError, Boolean ignoreCase, Boolean reflectionOnly, StackCrawlMarkHandle stackMark, IntPtr pPrivHostBinder, Boolean loadTypeFromPartialName, ObjectHandleOnStack type)
at System.RuntimeTypeHandle.GetTypeByName(String name, Boolean throwOnError, Boolean ignoreCase, Boolean reflectionOnly, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean loadTypeFromPartialName)
at System.RuntimeType.GetType(String typeName, Boolean throwOnError, Boolean ignoreCase, Boolean reflectionOnly, StackCrawlMark& stackMark)
at System.Type.ReflectionOnlyGetType(String typeName, Boolean throwIfNotFound, Boolean ignoreCase)
Remco NCrunch Developer
#1228
28 Feb 2012 20:19 UTC
Hi Chris,
This method is incompatible with the way NCrunch constructs its testing application domain. As a workaround, you can use the NCRUNCH compiler condition to make a call to Type.GetType instead. This would mean your code will use Type.GetType when executed by NCrunch, and Type.ReflectionOnlyGetType when executed normally. For example:
#if NCRUNCH
Type.GetType(myTypeName);
#else
Type.ReflectionOnlyGetType(myTypeName);
#endif
To help me understand if I can add proper support for this, can you give me any information about how your normally load the target assembly into your application domain? Is this done at run time in your own code?
Thanks!
Remco
This method is incompatible with the way NCrunch constructs its testing application domain. As a workaround, you can use the NCRUNCH compiler condition to make a call to Type.GetType instead. This would mean your code will use Type.GetType when executed by NCrunch, and Type.ReflectionOnlyGetType when executed normally. For example:
#if NCRUNCH
Type.GetType(myTypeName);
#else
Type.ReflectionOnlyGetType(myTypeName);
#endif
To help me understand if I can add proper support for this, can you give me any information about how your normally load the target assembly into your application domain? Is this done at run time in your own code?
Thanks!
Remco
Post a reply
Log in to reply.