private void Load(string path, string className) { if (!File.Exists(path)) { throw new ArgumentException("Simulation file does not exist."); } try { // var ads = new AppDomainSetup // { // ApplicationBase = AppDomain.CurrentDomain.BaseDirectory, // DisallowBindingRedirects = false, // DisallowCodeDownload = true, // ConfigurationFile = // AppDomain.CurrentDomain.SetupInformation.ConfigurationFile // }; // _domain = AppDomain.CreateDomain("SimulationDomain", null, ads); _domain = AppDomain.CreateDomain("SimulationDomain"); _proxy = (SimulationProxy)_domain.CreateInstanceAndUnwrap( typeof(SimulationProxy).Assembly.FullName, typeof(SimulationProxy).FullName); _proxy.Load(path, className); } catch (ArgumentException) { if (_domain != null) { AppDomain.Unload(_domain); } throw new ArgumentException( "Class \"" + className + "\" does not exists in dll."); } }
public SimInstance(SimulationProxy proxy) { Proxy = proxy; Id = proxy.Spawn(); }