private static IEmbeddedUI InstantiateUI(Session session, string uiClass) { int assemblySplit = uiClass.IndexOf('!'); if (assemblySplit < 0) { session.Log("Error: invalid embedded UI assembly and class:" + uiClass); return(null); } string assemblyName = uiClass.Substring(0, assemblySplit); EmbeddedUIProxy.uiClass = uiClass.Substring(assemblySplit + 1); Assembly uiAssembly; try { var context = new CustomLoadContext(); //uiAssembly = AppDomain.CurrentDomain.Load(assemblyName); uiAssembly = context.LoadFromFile(assemblyName); // This calls out to CustomActionProxy.DebugBreakEnabled() directly instead // of calling EmbeddedUIProxy.DebugBreakEnabled() because we don't compose a // class.method name for this breakpoint. if (CustomActionProxy.DebugBreakEnabled(new string[] { "EmbeddedUI" })) { System.Diagnostics.Debugger.Launch(); } var type = uiAssembly.GetType(EmbeddedUIProxy.uiClass); //return (IEmbeddedUI) uiAssembly.CreateInstance(EmbeddedUIProxy.uiClass); return((IEmbeddedUI)Activator.CreateInstance(type)); } catch (Exception ex) { session.Log("Error: could not load embedded UI class " + EmbeddedUIProxy.uiClass + " from assembly: " + assemblyName); session.Log(ex.ToString()); return(null); } }
private static bool DebugBreakEnabled(string method) { return(CustomActionProxy.DebugBreakEnabled(new string[] { method, EmbeddedUIProxy.uiClass + "." + method })); }