Home All Groups Group Topic Archive Search About

TypeLoadException when using GetTypes()

Author
7 Jun 2006 9:53 AM
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

AddThis Social Bookmark Button