TypeLoadException when using GetTypes()

D

Dan.Handevik

Hi,
I get an exception when I reflect a type that is a generic type and
inherits from ContextObject.

The generic context type

public class MyContext<T> : System.ContextBoundObject {}

and the test (in the same assembly)

[Test]
public void Test() {
Type[] types = null;
try {
types = GetType().Assembly.GetTypes();
} catch ( ReflectionTypeLoadException e ) {
Assert.Fail(e.ToString());
}
Assert.IsNotNull(types);
}

The following exception is thrown when the test is run ...

TestCase 'M:GenericContextObjectAndReflection.TestClass1.Test' failed:
Generic context-bound objects are not supported.
System.TypeLoadException: Generic context-bound objects are not
supported.
at System.Reflection.Assembly.GetExportedTypes()
at NUnit.Core.AddinManager.Register(Assembly assembly)
at NUnit.Core.Addins.Register(Assembly assembly)
at NUnit.Core.Builders.TestAssemblyBuilder.Load(String assemblyName)
at NUnit.Core.Builders.TestAssemblyBuilder.Build()
at NUnit.AddInRunner.NUnitTestRunner.run(ITestListener testListener,
Assembly assembly, IFilter filter)
at NUnit.AddInRunner.NUnitTestRunner.RunMember(ITestListener
testListener, Assembly assembly, MemberInfo member)
at TestDriven.TestRunner.AdaptorTestRunner.Run(ITestListener
testListener, ITraceListener traceListener, String assemblyPath, String
testPath)
at TestDriven.TestRunner.ThreadTestRunner.Runner.Run()

Shouldn't it be possible to get reflection information about this or is
the implementation not done yet?
Is there a workaround to get reflection information about this type?

Best regards
/Dan
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top