lundi 23 février 2015

CreateDelegate type cannot be null

I have a C# desktop app.


It uses reflection to late bind to a DLL


This is my code:



class myClass
{
//module declarations:

public static event delMotionDiscovered evMotionDiscovered;
public delegate void delMotionDiscovered(int camIndex);
public static Type Core = null;

void myfunction()
{
Assembly program = Assembly.Load(bytes);
Core = program.GetType("InformedMotion.Engine.Core");
var flags = BindingFlags.Static | BindingFlags.Public;

evMotionDiscoveredDynamic = Core.GetEvent("evMotionDiscovered", flags);
delMotionDiscoveredDynamic = Delegate.CreateDelegate(evMotionDiscoveredDynamic.EventHandlerType, null, "evMotionDiscovered");
evMotionDiscoveredDynamic.AddEventHandler(null, delMotionDiscoveredDynamic);
}
}


It errors on 'CreateDelegate with Target value cannot be null.


I did this work at some stage as well...






Aucun commentaire:

Enregistrer un commentaire