Welcome Guest! To enable all features please Login or Register.

Notification

Icon
Error

Reflection type loading error
chris.mellon
#1 Posted : Tuesday, February 28, 2012 3:39:17 PM(UTC)
Rank: Newbie

Groups: Registered
Joined: 2/28/2012(UTC)
Posts: 1

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
#2 Posted : Tuesday, February 28, 2012 8:19:33 PM(UTC)
Rank: NCrunch Developer

Groups: Administrators
Joined: 4/16/2011(UTC)
Posts: 7,141

Thanks: 959 times
Was thanked: 1290 time(s) in 1196 post(s)
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
Users browsing this topic
Guest
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

YAF | YAF © 2003-2011, Yet Another Forum.NET
This page was generated in 0.069 seconds.
Trial NCrunch
Take NCrunch for a spin
Do your fingers a favour and supercharge your testing workflow
Free Download