Example #1
0
        private ICustomConfigAssemblyInspector CreateAppDomain()
        {
            AppDomainSetup setup = new AppDomainSetup();


#if DEBUG
            setup.ApplicationBase = @"E:\db4object\db4o\Trunk\omn\OMADDIN\bin\";
#else 
            setup.ApplicationBase = CommonForAppDomain.GetPath() + "\\";
#endif


            setup.ShadowCopyDirectories = Path.GetTempPath();
            setup.ShadowCopyFiles = "true";
            workerAppDomain = AppDomain.CreateDomain("CustomConfigWorkerAppDomain", null, setup);
            AppDomain.CurrentDomain.AssemblyResolve += new ResolveEventHandler(CurrentDomain_AssemblyResolve);
            object anObject = workerAppDomain.CreateInstanceAndUnwrap("OMCustomConfigImplementation",
                                                                      "OMCustomConfigImplementation.CustomConfigAssemblyInfo.CustomConfigAssemblyInspector");
            ICustomConfigAssemblyInspector customConfigAssemblyInspector = anObject as ICustomConfigAssemblyInspector;

            object anObject1 = workerAppDomain.CreateInstanceAndUnwrap("OMCustomConfigImplementation",
                                                                        "OMCustomConfigImplementation.UserCustomConfig.UserConfig");
            IUserConfig conn = anObject1 as IUserConfig;
            CustomConfigInspectorObject.CustomUserConfig = conn;
           
            return customConfigAssemblyInspector;
        }
Example #2
0
        public void Run(RunnerInvocation invocation, Action<RunnerInvocation> action, string dll)
        {
            this.dll = dll;

            var setup = new AppDomainSetup();

            setup.ConfigurationFile = Path.GetFullPath(config);

            setup.ApplicationBase = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);

            domain = AppDomain.CreateDomain("NSpecDomain.Run", null, setup);

            var type = typeof(Wrapper);

            var assemblyName = type.Assembly.GetName().Name;

            var typeName = type.FullName;

            domain.AssemblyResolve += Resolve;

            var wrapper = (Wrapper)domain.CreateInstanceAndUnwrap(assemblyName, typeName);

            wrapper.Execute(invocation, action);

            AppDomain.Unload(domain);
        }
Example #3
0
        /// <summary>
        /// Creates a new instance of the test runner in the given app domain.
        /// </summary>
        /// <param name="domain">The app domain to create the runner into.</param>
        /// <param name="package">The test package to execute.</param>
        /// <returns></returns>
        public static TestRunner CreateRunner(System.AppDomain domain, TestPackage package)
        {
            Contract.Requires(domain != null);
            var runnerType = typeof(TestRunner);

            return(domain.CreateInstanceAndUnwrap(runnerType.Assembly.FullName, runnerType.FullName, false, 0, null, new object[] { package }, null, null) as TestRunner);
        }
Example #4
0
        private System.AppDomain CreateDomain(string domainName, string containerName)
        {
            System.AppDomain appDomain = null;
            try
            {
                // Create the AppDomain for each container and initialize the container with AppDomain

                appDomain = System.AppDomain.CreateDomain(containerName);

                // Create an instance of the container in that domain and initialize it.

                string fullName = typeof(ContainerManager).Assembly.FullName;
                string typeName = typeof(ContainerManager).FullName;

                ContainerManager manager = (ContainerManager)appDomain.CreateInstanceAndUnwrap(fullName, typeName);

                if (manager != null)
                {
                    appDomain.SetData("ContainerManager", manager);
                    manager.Initialize(domainName, containerName);
                }
            }
            catch (System.Exception ex)
            {
                string errorString = GenerateErrorString(ex);
                if (appDomain != null)
                {
                    System.AppDomain.Unload(appDomain);
                    appDomain = null;
                }
            }
            return(appDomain);
        }
Example #5
0
        void Init(string fileNname, string domainName)
        {
            //difference comparing to InitLagacy:
            // CreateInstanceAndUnwrap instead of CreateInstanceFromAndUnwrap
            //
            // setup.ApplicationBase = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
            // instead of setup.ApplicationBase = Path.GetDirectoryName(assemblyFileName); 
            //
            // In 2016 just discovered that InitLegacy doesn't longer work. May be because some changes in .NET versions...  
            // This is a low impact change as AssemblyExecutor is only used for cached vs. non-cached execution in stand alone 
            // hosting mode.

            assemblyFileName = fileNname;

            AppDomainSetup setup = new AppDomainSetup();
            setup.ApplicationBase = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
            setup.PrivateBinPath = AppDomain.CurrentDomain.BaseDirectory;
            setup.ApplicationName = Utils.GetAssemblyFileName(Assembly.GetExecutingAssembly());
            setup.ShadowCopyFiles = "true";
            setup.ShadowCopyDirectories = Path.GetDirectoryName(assemblyFileName);

            appDomain = AppDomain.CreateDomain(domainName, null, setup);
            remoteExecutor = (RemoteExecutor)appDomain.CreateInstanceAndUnwrap(Assembly.GetExecutingAssembly().FullName, typeof(RemoteExecutor).ToString());
            remoteExecutor.searchDirs = ExecuteOptions.options.searchDirs;
        }
        internal static void AssertAppDomainHasAssemblyResolveEventSubscribers(int expected, AppDomain appDomain)
        {
            var proxy = (AppDomainInfoProvider)appDomain.CreateInstanceAndUnwrap(Assembly.GetExecutingAssembly().FullName, typeof(AppDomainInfoProvider).FullName);
            var subscriberCount = proxy.GetAssemblyResolveEventSubscriberCount();

            Assert.Equal(expected, subscriberCount);
        }
Example #7
0
        private void StartInternal()
        {
            ConfigurationManipulation.RemoveAzureTraceListenerFromConfiguration(_configurationFilePath);
            CopyStubAssemblyToRoleDirectory(_appDomainSetup.ApplicationBase, _role);
            _appDomain = AppDomain.CreateDomain("LightBlue", null, _appDomainSetup);
            _hostStub = (HostStub)_appDomain.CreateInstanceAndUnwrap(typeof(HostStub).Assembly.FullName, typeof(HostStub).FullName);

            var shipper = new EventTraceShipper();
            Action<string> twh = m => _role.TraceWrite(Identifier, m);
            Action<string> twlh = m => _role.TraceWriteLine(Identifier, m);
            shipper.TraceWrite += twh;
            shipper.TraceWriteLine += twlh;
            _hostStub.ConfigureTracing(shipper);

            // TODO: decide how this is going to work.
            _appDomain.UnhandledException += StubExceptionHandler.Handler;

            try
            {
                _started.SetResult(new object());
                _role.TraceWriteLine(Identifier, "Role started in app domain: " + _appDomain.Id + " by " + Thread.CurrentThread.Name);
                _hostStub.Run(_assemblyFilePath, _configurationFilePath, _serviceDefinitionFilePath, _roleName, false);
            }
            catch (Exception ex)
            {
                _role.TraceWriteLine(Identifier, ex.ToString());
            }
            finally
            {
                shipper.TraceWrite -= twh;
                shipper.TraceWriteLine -= twlh;
                _completed.SetResult(new object());
            }
        }
 protected override HostedService CreateRemoteHost(AppDomain appDomain)
 {
     object instance = appDomain.CreateInstanceAndUnwrap("Rhino.ServiceBus",
                                                         "Rhino.ServiceBus.LoadBalancer.LoadBalancerHost");
     var hoster = (LoadBalancerHost)instance;
     return new HostedService(hoster, "Rhino.ServiceBus", appDomain);
 }
 public static bool Invoke(AppDomain domain, ScriptEnvironmentSetup setup, out RemoteScriptEnvironment environment) {
     RemoteDelegate rd = (RemoteDelegate)domain.CreateInstanceAndUnwrap(typeof(RemoteDelegate).Assembly.FullName,
         typeof(RemoteDelegate).FullName, false, BindingFlags.Default, null, new object[] { setup }, null, null, null);
     
     environment = rd.Environment;
     return rd.NewCreated;
 }
Example #10
0
        public ContextWrapper Run(string tagOrClassName, RunnerInvocation invocation, Func<RunnerInvocation, ContextWrapper> action, string dll)
        {
            this.dll = dll;

            var setup = new AppDomainSetup();

            setup.ConfigurationFile = Path.GetFullPath(config);

            setup.ApplicationBase = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);

            domain = AppDomain.CreateDomain("NSpecRunnerDomain.Run", null, setup);

            var type = typeof(Wrapper);

            var assemblyName = type.Assembly.GetName().Name;

            var typeName = type.FullName;

            domain.AssemblyResolve += Resolve;

            var wrapper = (Wrapper)domain.CreateInstanceAndUnwrap(assemblyName, typeName);

            var results = wrapper.Execute(invocation, action);// RunContexts(tagOrClassName);

            AppDomain.Unload(domain);

            return results;
        }
 /// <summary>
 /// Creates a new CustomWindowsFormsHost instance that allows hosting controls
 /// from the specified AppDomain.
 /// </summary>
 public CustomWindowsFormsHost(AppDomain childDomain)
 {
     var type = typeof(HostedControlContainer);
     this._container =
         (HostedControlContainer)childDomain.CreateInstanceAndUnwrap(type.Assembly.FullName, type.FullName);
     Init();
 }
Example #12
0
        private void InitliazeValidationAppDomain()
        {
            m_ValidationAppDomain = AppDomain.CreateDomain("ValidationDomain", AppDomain.CurrentDomain.Evidence, AppDomain.CurrentDomain.BaseDirectory, string.Empty, false);

            var validatorType = typeof(TypeValidator);
            m_Validator = (TypeValidator)m_ValidationAppDomain.CreateInstanceAndUnwrap(validatorType.Assembly.FullName, validatorType.FullName);
        }
Example #13
0
        public DiaSessionWrapper(string assemblyFilename)
        {
            session = new DiaSession(assemblyFilename);

            var setup = new AppDomainSetup
            {
                ApplicationBase = Path.GetDirectoryName(new Uri(typeof(DiaSessionWrapperHelper).Assembly.CodeBase).LocalPath),
                ApplicationName = Guid.NewGuid().ToString(),
                LoaderOptimization = LoaderOptimization.MultiDomainHost,
                ShadowCopyFiles = "true",
            };

            setup.ShadowCopyDirectories = setup.ApplicationBase;
            setup.CachePath = Path.Combine(Path.GetTempPath(), setup.ApplicationName);

            appDomain = AppDomain.CreateDomain(setup.ApplicationName, null, setup, new PermissionSet(PermissionState.Unrestricted));

            helper = (DiaSessionWrapperHelper)appDomain.CreateInstanceAndUnwrap(
                assemblyName: typeof(DiaSessionWrapperHelper).Assembly.FullName,
                typeName: typeof(DiaSessionWrapperHelper).FullName,
                ignoreCase: false,
                bindingAttr: 0,
                binder: null,
                args: new[] { assemblyFilename },
                culture: null,
                activationAttributes: null,
                securityAttributes: null
            );
        }
        private static System.AppDomain CreateAndRunAppDomain(int index, PermissionSet grantSet)
        {
            // Construct and initialize settings for a second AppDomain.
            AppDomainSetup ads = new AppDomainSetup();

            ads.ApplicationBase = System.AppDomain.CurrentDomain.BaseDirectory;

            ads.DisallowBindingRedirects = false;
            ads.DisallowCodeDownload     = true;
            ads.ConfigurationFile        =
                System.AppDomain.CurrentDomain.SetupInformation.ConfigurationFile;

            string name = "AppDomain" + index;

            System.AppDomain appDomain1 = System.AppDomain.CreateDomain(
                name,
                System.AppDomain.CurrentDomain.Evidence,
                ads,
                grantSet);
            AppDomainInstanceProgram programInstance1 = (AppDomainInstanceProgram)appDomain1.CreateInstanceAndUnwrap(
                typeof(AppDomainInstanceProgram).Assembly.FullName,
                typeof(AppDomainInstanceProgram).FullName);
            var argsToPass = new string[] { name, index.ToString() };

            programInstance1.Main(argsToPass);

            Console.WriteLine("**********************************************");
            Console.WriteLine($"Finished executing in AppDomain {name}");
            Console.WriteLine("**********************************************");
            return(appDomain1);
        }
Example #15
0
 private void RunScriptCore(byte[] inMemoryAssembly, byte[] inMemorySymbolStore, TextWriter outputTextWriter, TextWriter errorTextWriter)
 {
     RemoteScriptRun scriptRun;
     lock (fieldsLock)
     {
         if (inMemoryAssembly != loadedAssembly)
         {
             if (scriptAppDomain != null)
             {
                 AppDomain.Unload(scriptAppDomain);
             }
             scriptAppDomain = AppDomain.CreateDomain("ScriptAppDomain");
             remoteScriptRun = (RemoteScriptRun)scriptAppDomain.CreateInstanceAndUnwrap(typeof(RemoteScriptRun).Assembly.FullName, typeof(RemoteScriptRun).FullName);
             remoteScriptRun.Load(inMemoryAssembly, inMemorySymbolStore, outputTextWriter, errorTextWriter);
             loadedAssembly = inMemoryAssembly;
         }
         scriptRun = remoteScriptRun;
     }
     
     try
     {
         scriptRun?.Run();
     }
     catch (AppDomainUnloadedException)
     {
     }
 }
        public void LoadFrom(string path)
        {
            if (_domain != null)
            {
                _scanner.Teardown();
                AppDomain.Unload(_domain);
            }

            var name = Path.GetFileNameWithoutExtension(path);
            var dirPath = Path.GetFullPath(Path.GetDirectoryName(path));

            var setup = new AppDomainSetup
            {
                ApplicationBase = AppDomain.CurrentDomain.BaseDirectory,
                PrivateBinPath = dirPath,
                ShadowCopyFiles = "true",
                ShadowCopyDirectories = dirPath,
            };

            _domain = AppDomain.CreateDomain(name + "Domain", AppDomain.CurrentDomain.Evidence, setup);

            var scannerType = typeof(Scanner);
            _scanner = (Scanner)_domain.CreateInstanceAndUnwrap(scannerType.Assembly.FullName, scannerType.FullName);
            _scanner.Load(name);
            _scanner.Setup();
        }
        public RemoteDebugger()
        {
            // Create a new debugger session
            mSessionId = Guid.NewGuid().ToString();

            Evidence evidence = new Evidence(AppDomain.CurrentDomain.Evidence);
            AppDomainSetup appDomainSetup = AppDomain.CurrentDomain.SetupInformation;

            mAppDomain = AppDomain.CreateDomain(String.Format("Debugger-{0}", mSessionId), evidence, appDomainSetup);

            /*
            Type assemblyLoaderType = typeof(AssemblyLoader);
            AssemblyLoader loader = mAppDomain.CreateInstanceAndUnwrap(assemblyLoaderType.Assembly.GetName().Name, assemblyLoaderType.FullName) as AssemblyLoader;

            foreach (String assemblyPath in Directory.GetFiles(DebuggerConfig.ApplicationPath, "Tridion*.dll"))
            {
                loader.LoadAssembly(assemblyPath);
            }
            */
            Type debuggerHostType = typeof(DebugEngineServer);

            mDebuggerHost = mAppDomain.CreateInstanceAndUnwrap(
                debuggerHostType.Assembly.GetName().Name,
                debuggerHostType.FullName,
                true,
                BindingFlags.Default,
                null,
                new Object[] { mSessionId },
                null,
                null) as DebugEngineServer;
        }
Example #18
0
        /// <summary>
        /// Starts this instance.
        /// </summary>
        /// <exception cref="System.InvalidOperationException">Job already started.</exception>
        public static void Start()
        {
            if (_job != null)
                throw new InvalidOperationException("Job already started.");

            var evidence = new Evidence(AppDomain.CurrentDomain.Evidence);
            var setup = new AppDomainSetup
            {
                ApplicationBase = AppDomain.CurrentDomain.SetupInformation.ApplicationBase,
                ShadowCopyFiles = "false"
            };

            _appDomain = AppDomain.CreateDomain("eSync-" + Guid.NewGuid(), evidence, setup);
            try
            {
                var assembly = _appDomain.Load(typeof(SyncServiceJob).Assembly.GetName());
                var jobTypeName = typeof(SyncServiceJob).FullName;

                _job = (IJob)_appDomain.CreateInstanceAndUnwrap(assembly.FullName, jobTypeName);
                _job.Start();
            }
            catch
            {
                _job = null;
                AppDomain.Unload(_appDomain);
                _appDomain = null;

                throw;
            }
        }
Example #19
0
 private static ApplicationProxy CreateProxy(AppDomain domain)
 {
   Type activator = typeof(ApplicationProxy);
   ApplicationProxy proxy = domain.CreateInstanceAndUnwrap(
         Assembly.GetAssembly(activator).FullName,
         activator.ToString()) as ApplicationProxy;
   return proxy;
 }
        public IRemoteDomainBridge ForAppDomain(AppDomain domain)
        {
            var t = _ioc.Get<IRemoteDomainBridge>().GetType();

            return (IRemoteDomainBridge)domain.CreateInstanceAndUnwrap(
                t.Assembly.FullName,
                t.FullName);
        }
Example #21
0
 public IIoDeviceWrapper Create()
 {
     _appDomain = AppDomain.CreateDomain(_domainName, null, null);
     var type = typeof (IoDeviceWrapper);
     var assembly = Assembly.GetAssembly(type);
     Debug.Assert(type.FullName != null, "type.FullName != null");
     return (IIoDeviceWrapper)_appDomain.CreateInstanceAndUnwrap(assembly.FullName, type.FullName);
 }
Example #22
0
        private HeartBeat _heartBeater; //TODO pass heartbeater and pass back current users

        #endregion Fields

        #region Constructors

        public LillyPad()
        {
            InputOutput.InitLogTypes();
            /*
             * The LillyPad System simply takes each subsystem and starts it
             * in its own thread, doing this allows us to desync the entire
             * system and restart subsystems without restarting the whole
             * server.
             *
             */

            _historyAppDomain = AppDomain.CreateDomain("History_AppDomain");
            Type t = typeof (HistoryController);
            if (t.FullName != null)
                _historyController = (HistoryController) _historyAppDomain.CreateInstanceAndUnwrap("MineFrog", t.FullName);

            _databaseAppDomain = AppDomain.CreateDomain("Database_AppDomain");
            t = typeof (DatabaseController);
            if (t.FullName != null)
                _databaseController =
                    (DatabaseController)_databaseAppDomain.CreateInstanceAndUnwrap("MineFrog", t.FullName);

            _heartBeatDomain = AppDomain.CreateDomain("HeartBeat_AppDomain");
            t = typeof (HeartBeat);
            if (t.FullName != null)
                _heartBeater = (HeartBeat)_historyAppDomain.CreateInstanceAndUnwrap("MineFrog", t.FullName);

            Server.Log("Starting Server SybSystems...", LogTypesEnum.System);

            #region TODO Move server to auto-restarter!

            _serverDomain = AppDomain.CreateDomain("Server_AppDomain");
            t = typeof (Server);
            if (t.FullName != null)
                _server = (Server) _serverDomain.CreateInstanceAndUnwrap("MineFrog", t.FullName);

            _server.DONOTUSEMEHistoryControllerNS = _historyController;
            _server.DONOTUSEMEDatabaseControllerNS = _databaseController;
            _server.DONOTUSEMEHeartBeatNS = _heartBeater;
            _server.Start();

            //Server.StartInput();

            #endregion
        }
Example #23
0
 public ScriptContainer(string binPathes, string name)
 {
     AppDomainSetup setup = new AppDomainSetup();
     setup.ApplicationBase = AppDomain.CurrentDomain.BaseDirectory;
     setup.PrivateBinPath = binPathes;
     scriptDomain = AppDomain.CreateDomain("script", null, setup);
     Type helperType = typeof(ScriptCompilerHelper);
     helper = scriptDomain.CreateInstanceAndUnwrap(helperType.Assembly.FullName, helperType.FullName) as ScriptCompilerHelper;
 }
		public static MvcTextTemplateHost Create (AppDomain domain)
		{
			if (domain == null)
				return new MvcTextTemplateHost ();
			
			return (MvcTextTemplateHost) domain.CreateInstanceAndUnwrap (
				typeof (MvcTextTemplateHost).Assembly.FullName,
				typeof (MvcTextTemplateHost).FullName);
		}
Example #25
0
 public Shell(string[] commandLineArguments)
 {
     var appDomainSetup = new AppDomainSetup { ApplicationBase = AppDomain.CurrentDomain.BaseDirectory };
     testDomain = AppDomain.CreateDomain("fitSharp.Machine", null, appDomainSetup);
     runner = (Runner) testDomain.CreateInstanceAndUnwrap(
                                       Assembly.GetExecutingAssembly().GetName().Name,
                                       typeof (Runner).FullName);
     runner.SetUp(commandLineArguments);
 }
Example #26
0
 //--- Constructors ---
 public IsolatedTypeInspector() {
     _log.Debug("set up appdomain");
     var appDomainSetup = new AppDomainSetup();
     string currentBase = Path.GetFullPath(AppDomain.CurrentDomain.BaseDirectory);
     appDomainSetup.ApplicationBase = currentBase;
     _assemblyInspectorDomain = AppDomain.CreateDomain("assembly-inspector", null, appDomainSetup);
     _typeInspector = (ITypeInspector)_assemblyInspectorDomain.CreateInstanceAndUnwrap("mindtouch.reflection", "MindTouch.Reflection.TypeInspector");
     _log.Debug("app domain created");
 }
        public ContextSwitchTests()
        {
            otherDomain = AppDomain.CreateDomain("other domain", null,
                AppDomain.CurrentDomain.BaseDirectory, null, false);

            contextSwitcher = (ContextSwitcher)otherDomain.CreateInstanceAndUnwrap(
                Assembly.GetExecutingAssembly().GetName().Name,
                typeof(ContextSwitcher).FullName);
        }
Example #28
0
		static BatchCompiler NewBatchCompiler () {
			if (current != null)
				AppDomain.Unload (current);

			current = AppDomain.CreateDomain ("test");
			BatchCompiler compiler = (BatchCompiler) current.CreateInstanceAndUnwrap(
				Assembly.GetExecutingAssembly().FullName,
				"Verifier.BatchCompiler");
			return compiler;
		}
        public static void Main()
        {
            int one = 1;

            System.Diagnostics.Debugger.Break();
            System.AppDomain appDomain = System.AppDomain.CreateDomain("myDomain");
            RemoteObj        printer   = (RemoteObj)appDomain.CreateInstanceAndUnwrap(typeof(RemoteObj).Assembly.FullName, typeof(RemoteObj).FullName);

            printer.Foo();
        }
Example #30
0
 public Remoter()
 {
     //Create an AppDomain in which to run our DLL code
     AppDomainSetup appDomainSetup = new AppDomainSetup();
     appDomainSetup.ApplicationBase = AppDomain.CurrentDomain.BaseDirectory;  //Environment.CurrentDirectory
     disposableAppDomain = AppDomain.CreateDomain("DisposableAppDomain" + Guid.NewGuid().ToString(), null, appDomainSetup);
     //disposableAppDomain.AssemblyResolve += new ResolveEventHandler(CurrentDomain_AssemblyResolve);
     //Create the remoteLoaderFactory class in the secondary app-domain
     //remoteLoaderFactory = (RemoteLoaderFactory)disposableAppDomain.CreateInstanceAndUnwrap("RemoteLoader", "RemoteLoader.RemoteLoaderFactory");
     remoteContainer = (RemoteContainer)disposableAppDomain.CreateInstanceAndUnwrap("RemoteContainer", "RemoteLoader.RemoteContainer");
 }
        public void Start()
        {
            if (Id == null)
                throw new InvalidOperationException("Run Configure() first.");

            _appDomain = AppDomain.CreateDomain(_appName, null, _appDomainSetup);
            _domainManager =
                (AppInitializeRunner)
                    _appDomain.CreateInstanceAndUnwrap("Griffin.Core", typeof (AppInitializeRunner).FullName);
            _domainManager.Start(Id, _startType.AssemblyQualifiedName);
        }
Example #32
0
 static void Load()
 {
     if (pluginDomain != null)
     {
         Unload();
     }
     pluginDomain = AppDomain.CreateDomain("PluginDomain" + Guid.NewGuid());
     var t = typeof (PluginLoader);
     loader = (PluginLoader) pluginDomain.CreateInstanceAndUnwrap(t.Assembly.FullName, t.FullName);
     loader.Load("Plugin1.dll");
 }
Example #33
0
        public TestObjectMarshall CreateObject(TestObjectMarshall testObject, AppDomain appDomain, string exeAssembly)
        {
            // Create an instance of MarshalbyRefType in the second AppDomain.
                // A proxy to the object is returned.
                testObject = (TestObjectMarshall)appDomain.CreateInstanceAndUnwrap(
                    exeAssembly,
                    typeof(TestObjectMarshall).FullName
                                             );

            return testObject;
        }
Example #34
0
		private TestRunner MakeRemoteTestRunner( AppDomain runnerDomain )
		{
			Type runnerType = typeof( RemoteTestRunner );
			object obj = runnerDomain.CreateInstanceAndUnwrap(
				runnerType.Assembly.FullName, 
				runnerType.FullName,
				false, BindingFlags.Default,null,new object[] { this.ID },null,null,null);
			
			RemoteTestRunner runner = (RemoteTestRunner) obj;

			return runner;
		}
Example #35
0
        public T CreateProxy <T> (Type proxyType, params object[] proxyArgs)
        {
            var instance = _appDomain.CreateInstanceAndUnwrap(
                proxyType.Assembly.GetName().Name,
                proxyType.FullName,
                ignoreCase: false,
                bindingAttr: c_bindingFlags,
                binder: null,
                args: proxyArgs,
                culture: CultureInfo.InvariantCulture,
                activationAttributes: null);

            return((T)instance);
        }
Example #36
0
        public static T CreateProxy <T> (this System.AppDomain appDomain, Type proxyType, params object[] proxyArgs)
        {
            Debug.Assert(proxyType.IsSubclassOf(typeof(MarshalByRefObject)), "proxyType.IsSubclassOf(typeof(MarshalByRefObject))");

            var instance = appDomain.CreateInstanceAndUnwrap(
                proxyType.Assembly.GetName().Name,
                proxyType.FullName,
                ignoreCase: false,
                bindingAttr: c_bindingFlags,
                binder: null,
                args: proxyArgs,
                culture: CultureInfo.InvariantCulture,
                activationAttributes: null);

            return((T)instance);
        }
        private void Initialize()
        {
            if (_info.GeneratorFolder == null)
            {
                throw new InvalidOperationException(
                          "The RemoteAppDomainTestGeneratorFactory has to be configured with the Setup() method before initialization.");
            }


            var appDomainSetup = new AppDomainSetup
            {
                ShadowCopyFiles = "true",
            };

            _appDomain = System.AppDomain.CreateDomain("AppDomainForTestGeneration", null, appDomainSetup);

            var testGeneratorFactoryTypeFullName = typeof(TestGeneratorFactory).FullName;

            Debug.Assert(testGeneratorFactoryTypeFullName != null);

            _tracer.Trace(string.Format("TestGeneratorFactory: {0}", testGeneratorFactoryTypeFullName), LogCategory);

            _tracer.Trace("AssemblyResolve Event added", LogCategory);
            System.AppDomain.CurrentDomain.AssemblyResolve += CurrentDomainOnAssemblyResolve;


            var remoteAppDomainAssembly = _remoteAppDomainResolverType.Assembly;

            _remoteAppDomainResolver = (RemoteAppDomainResolver)_appDomain.CreateInstanceFromAndUnwrap(remoteAppDomainAssembly.Location, _remoteAppDomainResolverType.FullName, true, BindingFlags.Default, null, null, null, null);
            _remoteAppDomainResolver.Init(_info.GeneratorFolder);

            var generatorFactoryObject = _appDomain.CreateInstanceAndUnwrap(_info.RemoteGeneratorAssemblyName, testGeneratorFactoryTypeFullName);

            _remoteTestGeneratorFactory = generatorFactoryObject as ITestGeneratorFactory;

            if (_remoteTestGeneratorFactory == null)
            {
                throw new InvalidOperationException("Could not load test generator factory.");
            }

            _usageCounter = new UsageCounter(LoseReferences);
            _tracer.Trace("AppDomain for generator created", LogCategory);
        }
        private T LoadProxy <T>() where T : MarshalByRefObject
        {
            var type = typeof(T);

            return((T)_domain.CreateInstanceAndUnwrap(type.Assembly.FullName, type.FullName));
        }
 public ContinuousDatabaseAppDomainProxy()
 {
     _domain      = System.AppDomain.CreateDomain("ContinuousDatabaseActivity");
     _remoteClass = _domain.CreateInstanceAndUnwrap(Assembly.GetExecutingAssembly().FullName, typeof(ContinuousDatabaseAppDomain).FullName) as ContinuousDatabaseAppDomain;
 }