我有一个项目,在那个项目中我动态加载了一个 dll。看起来像:
AssemblyPart assemblyPart = new AssemblyPart();
WebClient downloader = new WebClient();
string path = string.Format("../ClientBin/{0}.xap", "AgileTax");
downloader.OpenReadCompleted += (e, sa) =>
{
getdllinStream = GetStream(sa.Result, _CurReturnType.PackageName + "ERC", true);
_formsAssembly = assemblyPart.Load(getdllinStream);
foreach (var item in _formsAssembly.GetTypes())
{
if (item.FullName == _CurReturnType.PackageName + "ERC.State.StateMain")
{
ATSpgm = item;
}
}
var class_instance = _formsAssembly1.CreateInstance(PackageName + "ERC.State.StateMain");
if (class_instance != null)
{
MethodInfo[] infomem = ATSpgm.GetMethods();
MethodInfo SetVarDllNG1 = ATSpgm.GetMethod("ProcessERC");
SetVarDllNG1.Invoke(class_instance, parametersArray);
}
}
downloader.OpenReadAsync(new Uri(path, UriKind.Relative));
现在我的问题是在.dll中我有如下代码:
public event ERCErrorHandling OnERCErrorHandler;
public delegate string ERCErrorHandling(Exception ex);
现在我的问题是如何调用这个 ERCErrorHandling 事件,上面我调用了类似 ProcessERC 的方法。