当前位置: 首页>>代码示例>>C#>>正文


C# AppDomain.Load方法代码示例

本文整理汇总了C#中System.AppDomain.Load方法的典型用法代码示例。如果您正苦于以下问题:C# AppDomain.Load方法的具体用法?C# AppDomain.Load怎么用?C# AppDomain.Load使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.AppDomain的用法示例。


在下文中一共展示了AppDomain.Load方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Main

 static void Main()
 {
     //включаем визуальные стили для прилжения, поскольку оно является оконным
     Application.EnableVisualStyles();
     /*создаём необходимые домены приложений с дружественными именами и 
      * сохраняем ссылки на них в соответствующие переменные*/
     Drawer = AppDomain.CreateDomain("Drawer");
     TextWindow = AppDomain.CreateDomain("TextWindow");
     /*загружаем сборки с оконными приложениями в соответствующие домены приложений*/
     DrawerAsm = Drawer.Load(AssemblyName.GetAssemblyName("TextDrawer.exe"));
     TextWindowAsm = Drawer.Load(AssemblyName.GetAssemblyName("TextWindow.exe"));
     /*создаём объекты окон на сонове оконных типов данных из загруженных сборок*/
     DrawerWindow = Activator.CreateInstance(DrawerAsm.GetType("TextDrawer.Form1")) as Form;
     TextWindowWnd = Activator.CreateInstance(
         TextWindowAsm.GetType("TextWindow.Form1"), 
         new object[]
             {
                 DrawerAsm.GetModule("TextDrawer.exe"),
                 DrawerWindow
             }) as Form;
     /*запускаем потоки*/
     (new Thread(new ThreadStart(RunVisualizer))).Start();
     (new Thread(new ThreadStart(RunDrawer))).Start();
     /*добавляем обработчик события DomainUnload*/
     Drawer.DomainUnload += new EventHandler(Drawer_DomainUnload);
 }
开发者ID:xs2ranjeet,项目名称:13ns9-1spr,代码行数:26,代码来源:Program.cs

示例2: DynamicAssemblyProxy

        public DynamicAssemblyProxy(string luceneIndexFolder)
        {
            _currentDomain = AppDomain.CurrentDomain;

            const string asemblyName = "dynamicProcessLib";
            const string systemAsemblyName = "dynamicProcessLibSys";
            //const string asemblyName = "dynamicProcessLib, Version=1.1.166.5, Culture=neutral, PublicKeyToken=null";
            //const string systemAsemblyName = "dynamicProcessLibSys, Version=1.1.166.5, Culture=neutral, PublicKeyToken=null";

            try
            {
                systemAssembly = _currentDomain.Load(systemAsemblyName);
                userAssembly = _currentDomain.Load(asemblyName);
            }
            catch (Exception ex)
            {
                throw new ApplicationException(
                    string.Format(CultureInfo.InvariantCulture,
                        "Global Search Exception : AppDomain/ problem on loading (AssemblyName : {1}) /{0}/",
                        luceneIndexFolder,
                        asemblyName),
                    ex);
            }

            _luceneIndexFolder = luceneIndexFolder;

            InitializeService();
        }
开发者ID:mparsin,项目名称:Elements,代码行数:28,代码来源:DynamicAssemblyProxy.cs

示例3: DomTester

 /// <summary>
 /// Initializes a new instance of the NamespaceDeclaration class.
 /// </summary>
 /// <param name="nsdecl">The namespace being compiled.</param>
 public DomTester(NamespaceDeclaration nsdecl)
 {
     _nsdecl = nsdecl;
     _appDomain = AppDomain.CreateDomain("testdomain");
     this.Compile();
     _appDomain.Load("System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089");
     _appDomain.Load(_compiled.GetName());
 }
开发者ID:chrcar01,项目名称:HyperActive,代码行数:12,代码来源:DomTester.cs

示例4: Start

        /// <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;
            }
        }
开发者ID:mparsin,项目名称:Elements,代码行数:34,代码来源:ESyncJob.cs

示例5: RegisterWithBuilderFromPath

        public static void RegisterWithBuilderFromPath(ContainerBuilder builder, AppDomain currentDomain, EnumRegistrationType enumRegistrationType)
        {
            List<Assembly> vuelingAssembliesList = new List<Assembly>();
            Assembly[] vuelingAssembliesArray;

            customRegistration(builder);

            List<Assembly> assemblies = currentDomain.GetAssemblies().ToList<Assembly>();

            var loadedAssemblies = currentDomain.GetAssemblies().ToList();
            var loadedPaths = loadedAssemblies.Select(a => a.Location).ToArray();

            var referencedPaths = Directory.GetFiles(currentDomain.BaseDirectory, "*.dll");
            var toLoad = referencedPaths.Where(r => !loadedPaths.Contains(r, StringComparer.InvariantCultureIgnoreCase)).ToList();
            toLoad.ForEach(path => loadedAssemblies.Add(currentDomain.Load(AssemblyName.GetAssemblyName(path))));

            foreach (var referencedAssembly in toLoad)
            {

                assemblies.Add(Assembly.LoadFrom(referencedAssembly));

            }

            foreach (var assembly in assemblies.Distinct())
            {

                if (assembly.GetName().Name.ToLower().Contains("vueling")) vuelingAssembliesList.Add(Assembly.Load(assembly.GetName().Name));

            }
            vuelingAssembliesArray = vuelingAssembliesList.ToArray<Assembly>();

            if (enumRegistrationType == EnumRegistrationType.justWithDecoratedClasses) RegisterAssemblyTypesWithDecoratedClasses(builder, vuelingAssembliesArray);
            else RegisterAssemblyTypes(builder, vuelingAssembliesArray);
        }
开发者ID:jcgonzalezalzate,项目名称:HerbProject,代码行数:34,代码来源:DIGlobalRegister.cs

示例6: SetUp

		public void SetUp()
		{
			string path = new Uri(Assembly.GetExecutingAssembly().EscapedCodeBase).LocalPath;

			_localDomain = AppDomain.CreateDomain("NewDomain");
			_localDomain.Load(typeof(DataAccessor).Assembly.GetName());
			_localTest = (DataAccessorBuilderTest)_localDomain.CreateInstanceFromAndUnwrap(path, GetType().FullName);
		}
开发者ID:MajidSafari,项目名称:bltoolkit,代码行数:8,代码来源:DataAccessorBuilderTest.cs

示例7: LoadAssembly

 private static void LoadAssembly(AppDomain newAppDomain, string assemblyName)
 {
     try
     {
         newAppDomain.Load(assemblyName);
     }
     catch (FileNotFoundException ex)
     {
         Console.WriteLine(ex.Message);
     }
 }
开发者ID:caloggins,项目名称:DOT-NET-on-Linux,代码行数:11,代码来源:Program.cs

示例8: Init

        public void Init()
        {
            AppDomainSetup testDomainSetup = new AppDomainSetup()
            {
                ApplicationBase = AppDomain.CurrentDomain.SetupInformation.ApplicationBase
            };

            _TestDomain = AppDomain.CreateDomain("SampleServiceDomain",
                null,
                testDomainSetup);
            _TestDomain.Load("SampleService");
        }
开发者ID:mattmhersh,项目名称:WCFRestDemo,代码行数:12,代码来源:ApiDeclarationTests.cs

示例9: Init

		public void Init()
		{
			_EmptyDomain = AppDomain.CreateDomain("EmptyDomain");
			//_EmptyDomain = AppDomain.CurrentDomain;

			//this doesn't seem to work as expected - if this is run concurrently with the EmptyResourceList test using CurrentDomain, things break
			AppDomainSetup testDomainSetup = new AppDomainSetup();
			testDomainSetup.ApplicationBase = AppDomain.CurrentDomain.SetupInformation.ApplicationBase;
			_TestDomain = AppDomain.CreateDomain("SampleServiceDomain",
				null,
				testDomainSetup);
			_TestDomain.Load("SampleService");
		}
开发者ID:Robin--,项目名称:swaggerwcf,代码行数:13,代码来源:ResourceListingTests.cs

示例10: LoadAssembliesForVersion

        private void LoadAssembliesForVersion()
        {
            _appDomain = AppDomain.CreateDomain("NHibernateContext");

            var nhibernatePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, string.Format(@"DataContext\{0}", _version));
            var assembliesToLoad = Directory.GetFiles(nhibernatePath, "*.dll");
            foreach (var assemblyFile in assembliesToLoad)
            {
                var assemblyFileName = new FileInfo(assemblyFile).Name;
                var assemblyFileToCreate = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, assemblyFileName);
                File.Copy(assemblyFile, assemblyFileToCreate, true);
                _appDomain.Load(AssemblyName.GetAssemblyName(assemblyFileToCreate));
            }
        }
开发者ID:nagor,项目名称:Glimpse,代码行数:14,代码来源:NHibernateContext.cs

示例11: CreateAppdomain

        public void CreateAppdomain()
        {
            var appdomainSetup = new AppDomainSetup();
            //string appBase = Environment.CurrentDirectory;
            //string appBase = HttpContext.Current.Request.ApplicationPath;
            appdomainSetup.ApplicationBase = CodeTemplateProjectInfo.BLASSEMBLYLOCATIONPATHONLY;
            //System.Diagnostics.Debug.WriteLine(AppDomain.CurrentDomain.SetupInformation.ApplicationBase);
            appdomainSetup.DisallowBindingRedirects = false;
            appdomainSetup.DisallowCodeDownload = true;
            appdomainSetup.ConfigurationFile = AppDomain.CurrentDomain.SetupInformation.ConfigurationFile;

            appDomain = AppDomain.CreateDomain("compilerAppdomain", null, appdomainSetup);
            appDomain.Load(AssemblyName.GetAssemblyName(CodeTemplateProjectInfo.BLASSEMBLYLOCATION));
        }
开发者ID:pbrianmackey,项目名称:csFiddle,代码行数:14,代码来源:AppdomainHelper.cs

示例12: Launch

        public void Launch(string pluginPath, AppDomain appDomain, Uri pluginApiUri, int clientPort, string tokenValue)
        {
            var token = Token.With(tokenValue);
            var assembly = appDomain.Load(AssemblyName.GetAssemblyName(pluginPath));
            var pluginDirectory = Path.GetDirectoryName(pluginPath);
            appDomain.AssemblyResolve += (sender, args) =>
                {
                    var ad = sender as AppDomain;
                    var path = Path.Combine(pluginDirectory, args.Name.Split(',')[0] + ".dll");
                    return ad.Load(path);
                };
            var pluginBootstrapperType = assembly.GetTypes().Single(t => typeof (IPluginBootstrapper).IsAssignableFrom(t));
            var pluginBootstrapper = (IPluginBootstrapper) Activator.CreateInstance(pluginBootstrapperType);

            var uri = new Uri($"http://127.0.0.1:{clientPort}");

            var pluginRegistration = new PluginRegistration(
                uri,
                token,
                new CommandApi(pluginApiUri, token),
                new MessageApi(pluginApiUri, token),
                new HttpApi(),
                new Apis.PluginApi(pluginApiUri, token),
                new ConfigApi(pluginApiUri, token),
                new SettingApi(pluginApiUri, token));

            pluginBootstrapper.Start(r =>
                {
                    r(pluginRegistration);
                    if (pluginRegistration.PluginInformation == null)
                    {
                        throw new InvalidOperationException("You must call SetPluginInformation(...)");
                    }

                    using (var a = AsyncHelper.Wait)
                    {
                        a.Run(pluginRegistration.CommandApi.RegisterAsync(
                            pluginRegistration.CommandDescriptions,
                            CancellationToken.None));
                    }
                });
            
            _apiHost = new ApiHost();
            _apiHost.Start(uri, pluginRegistration);
        }
开发者ID:rasmus,项目名称:TheBorg,代码行数:45,代码来源:PluginHostClient.cs

示例13: StartServers

        public static void StartServers(TestContext ctx)
        {
            #region TCP Duplex

            // Setup TCP Duplex Server AppDomain
            AppDomainSetup tcpDuplexAppDomainSetup = new AppDomainSetup() { ApplicationBase = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) };
            _tcpDuplexServerAppDomain = AppDomain.CreateDomain("RecreateClientConnectionTests_Server", null, tcpDuplexAppDomainSetup);
            _tcpDuplexServerAppDomain.Load(typeof(ZyanConnection).Assembly.GetName());

            // Start Zyan host inside the TCP Duplex Server AppDomain
            var tcpDuplexServerWork = new CrossAppDomainDelegate(() =>
            {
                var server = TcpDuplexServerHostEnvironment.Instance;

                if (server != null)
                {
                    Console.WriteLine("TCP Duplex Server running.");
                }
            });
            _tcpDuplexServerAppDomain.DoCallBack(tcpDuplexServerWork);

            #endregion

            #region TCP Simplex

            // Setup TCP Simplex Server AppDomain
            AppDomainSetup tcpSimplexAppDomainSetup = new AppDomainSetup() { ApplicationBase = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) };
            _tcpSimplexServerAppDomain = AppDomain.CreateDomain("RecreateClientConnectionTests_Server", null, tcpSimplexAppDomainSetup);
            _tcpSimplexServerAppDomain.Load(typeof(ZyanConnection).Assembly.GetName());

            // Start Zyan host inside the TCP Simplex Server AppDomain
            var tcpSimplexServerWork = new CrossAppDomainDelegate(() =>
            {
                var server = TcpSimplexServerHostEnvironment.Instance;

                if (server != null)
                {
                    Console.WriteLine("TCP Simplex Server running.");
                }
            });
            _tcpSimplexServerAppDomain.DoCallBack(tcpSimplexServerWork);

            #endregion
        }
开发者ID:yallie,项目名称:zyan,代码行数:44,代码来源:RecreateClientConnectionTests.cs

示例14: CreateReflectionAssembly

		public static SR.Assembly CreateReflectionAssembly (AssemblyDefinition asm, AppDomain domain)
		{
			using (MemoryBinaryWriter writer = new MemoryBinaryWriter ()) {

				WriteAssembly (asm, writer);
				return domain.Load (writer.ToArray ());
			}
		}
开发者ID:transformersprimeabcxyz,项目名称:monodevelop-1,代码行数:8,代码来源:AssemblyFactory.cs

示例15: Main

        public static int Main(string[] args)
        {
            AppDomainSetup setup = new AppDomainSetup();
            setup.ApplicationBase = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);

            _serverAppDomain = AppDomain.CreateDomain("Server", null, setup);
            _serverAppDomain.Load(typeof(ZyanConnection).Assembly.GetName());

            CrossAppDomainDelegate serverWork = new CrossAppDomainDelegate(() =>
            {
                var server = EventServer.Instance;
                if (server != null)
                {
                    Console.WriteLine("Event server started.");
                }
            });
            _serverAppDomain.DoCallBack(serverWork);

            // Test IPC Binary
            int ipcBinaryTestResult = IpcBinaryTest.RunTest();
            Console.WriteLine("Passed: {0}", ipcBinaryTestResult == 0);

            // Test TCP Binary
            int tcpBinaryTestResult = TcpBinaryTest.RunTest();
            Console.WriteLine("Passed: {0}", tcpBinaryTestResult == 0);

            // Test TCP Custom
            int tcpCustomTestResult = TcpCustomTest.RunTest();
            Console.WriteLine("Passed: {0}", tcpCustomTestResult == 0);

            // Test TCP Duplex
            int tcpDuplexTestResult = TcpDuplexTest.RunTest();
            Console.WriteLine("Passed: {0}", tcpDuplexTestResult == 0);

            // Test HTTP Custom
            int httpCustomTestResult = HttpCustomTest.RunTest();
            Console.WriteLine("Passed: {0}", httpCustomTestResult == 0);

            // Test NULL Channel
            const string nullChannelResultSlot = "NullChannelResult";
            _serverAppDomain.DoCallBack(new CrossAppDomainDelegate(() =>
            {
                int result = NullChannelTest.RunTest();
                AppDomain.CurrentDomain.SetData(nullChannelResultSlot, result);
            }));
            var nullChannelTestResult = Convert.ToInt32(_serverAppDomain.GetData(nullChannelResultSlot));
            Console.WriteLine("Passed: {0}", nullChannelTestResult == 0);

            // Stop the event server
            EventServerLocator locator = _serverAppDomain.CreateInstanceAndUnwrap(Assembly.GetExecutingAssembly().FullName, "IntegrationTest_DistributedEvents.EventServerLocator") as EventServerLocator;
            locator.GetEventServer().Dispose();
            Console.WriteLine("Event server stopped.");

            if (!MonoCheck.IsRunningOnMono || MonoCheck.IsUnixOS)
            {
                // Mono/Windows bug:
                // AppDomain.Unload freezes in Mono under Windows if tests for
                // System.Runtime.Remoting.Channels.Tcp.TcpChannel were executed.
                AppDomain.Unload(_serverAppDomain);
                Console.WriteLine("Server AppDomain unloaded.");
            }

            if (ipcBinaryTestResult + tcpBinaryTestResult + tcpCustomTestResult + tcpDuplexTestResult + httpCustomTestResult + nullChannelTestResult == 0)
            {
                Console.WriteLine("All tests passed.");
                return 0;
            }

            return 1;
        }
开发者ID:yallie,项目名称:zyan,代码行数:70,代码来源:Program.cs


注:本文中的System.AppDomain.Load方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。