so in the class that retrieves the events i changed the code to this to cast the class to an object.
try
{
this.displaysAssembly = Assembly.LoadFrom(Path.Combine(Directory.GetApplicationDirectory(), "Framework.DisplayDrivers.dll"));
string assembly = string.Format("Framework.DisplayDrivers.{0}", type);
Type cswitcher = displaysAssembly.GetType(assembly);
fullClass = displaysAssembly.GetType(assembly);
Dictionary<string, EventInfo> ekvp = new Dictionary<string, EventInfo>();
List<EventInfo> eventInfos = cswitcher.GetEvents().Where(e => HasInformationAttribute(e)).ToList();
foreach (var e in eventInfos)
{
if (!ekvp.ContainsKey(label))
{
ekvp.Add(e.Name, e);
}
}
return (ekvp);
}
then in the method trying to create the subscriptions i changed it to :
foreach (var d in DisplayCollection.displayList)
{
foreach(var evnt in d._projectors._events)
{
EventInfo ev = evnt.Value;
try
{
if (evnt.Key == "OnPowerStateRecieved")
{
ev.AddEventHandler(d._projectors.fullClass, new EventHandler(DisplayChangeEvents.DisplayPowerChangedEvent));
}
else if (evnt.Key == "OnMuteStateRecieved")
{
ev.AddEventHandler(d._projectors.fullClass, new EventHandler(DisplayChangeEvents.DisplayMuteChangedEvent));
}
however i get a exception of: Error creating event handers : Specified cast is not valid.