private void cboImplementations_SelectedIndexChanged(object sender, EventArgs e) { ModuleProc PROC = new ModuleProc("", "Method"); try { if (cboImplementations.SelectedIndex != -1) { if (lvwProcesses.SelectedItems.Count > 0) { ComboItem item = lvwProcesses.SelectedItems[0].Tag as ComboItem; ComboItem2 configStoreImpl = cboImplementations.SelectedItem as ComboItem2; //_store = _domain.CreateInstanceAndUnwrap(item.AsmName.FullName, configStoreImpl) as ConfigStore; _store = Activator.CreateInstance(configStoreImpl.Value, true) as ConfigStore; ConfigStoreManager.PullValues(_store); propData.SelectedObject = _store; btnSave.Enabled = true; } } } catch (Exception ex) { Log.Exception(PROC, ex); } }
private void LoadProcess() { ModuleProc PROC = new ModuleProc("", "Method"); propData.SelectedObject = null; cboImplementations.DataSource = null; try { if (lvwProcesses.SelectedItems.Count > 0) { ComboItem item = lvwProcesses.SelectedItems[0].Tag as ComboItem; if (item.AsmName == null) { this.ShowErrorMessageBox("Not a valid .NET Executable."); return; } if (_domain != null) { AppDomain.Unload(_domain); _domain = null; } if (_store != null) { //_store.Dispose(); _store = null; } AppDomain domain = AppDomain.CurrentDomain; Assembly asm = Assembly.LoadFile(item.Process2.ExecutablePath); if (asm != null) { Type[] stores = this.GetInstances(asm); if (stores == null || stores.Length == 0) { stores = this.GetInstancesFromReferencedAssemblies(asm.GetReferencedAssemblies()); } if (stores != null) { _implementations.Clear(); foreach (var store in stores) { _implementations.Add(new ComboItem2() { Text = store.FullName, Value = store }); } } cboImplementations.DisplayMember = "Text"; cboImplementations.ValueMember = "Value"; cboImplementations.DataSource = _implementations; } } if (cboImplementations.DataSource != null) { cboImplementations.SelectedIndex = 0; } } catch (Exception ex) { Log.Exception(PROC, ex); } }