jeudi 11 mai 2017

C# Assembly reflection and generics

I am attempting to create an instance of a class that is in another assembly, however this class instance is an internal generic class of the assembly. This is purely for debug purposes. Assembly A (Network.dll)

namespace Core {
    internal class AsyncCall<TRequest, TResponse> : AsyncCallBase<TRequest,TResponse>
}

From my assembly I have tried using

Assembly assembly = Assembly.LoadFrom("Network.dll");
object mc = assembly.CreateInstance("Core.AsyncCall", true);
System.Type t = mc.GetType();

This clearly doesn't work since I need to specify the generic type arguments. Does anyone know how I can do about creating an instance of this class ?





Aucun commentaire:

Enregistrer un commentaire