0
我有一個項目,並在該項目中我動態加載了一個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 。
@Baboon:爲了公平起見,幾乎沒有他的開放性問題有任何答案接受。 –
請看這裏:http://stackoverflow.com/questions/6010555/how-to-call-delegate-from-string-in-c –