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


C# AppDomain.SetData方法代码示例

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


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

示例1: Load

        static void Load()
        {
            if (AppDomain.CurrentDomain.FriendlyName != "OnlineVideosSiteUtilDlls")
            {
                if (_useSeperateDomain)
                {
                    _domain = AppDomain.CreateDomain("OnlineVideosSiteUtilDlls", null, null, null, true);

                    // we need to subscribe to AssemblyResolve on the MP2 AppDomain because OnlineVideos.dll is loaded in the LoadFrom Context
                    // and when unwrapping transparent proxy from our AppDomain, resolving types will fail because it looks only in the default Load context
                    // we simply help .Net by returning the already loaded assembly from the LoadFrom context
                    AppDomain.CurrentDomain.AssemblyResolve += AssemblyResolve;

                    _pluginLoader = (PluginLoader)_domain.CreateInstanceFromAndUnwrap(
                      Assembly.GetExecutingAssembly().Location,
                      typeof(PluginLoader).FullName);

                    AppDomain.CurrentDomain.AssemblyResolve -= AssemblyResolve;

                    _domain.SetData(typeof(PluginLoader).FullName, _pluginLoader);
                }
                else
                {
                    _domain = AppDomain.CurrentDomain;
                    _pluginLoader = new PluginLoader();
                }
            }
            else
            {
                _domain = AppDomain.CurrentDomain;
                _pluginLoader = (PluginLoader)AppDomain.CurrentDomain.GetData(typeof(PluginLoader).FullName);
            }
        }
开发者ID:offbyoneBB,项目名称:mp-onlinevideos2,代码行数:33,代码来源:OnlineVideosAppDomain.cs

示例2: CreateRemoteHost

		protected override HostedService CreateRemoteHost(AppDomain appDomain)
		{
			appDomain.SetData("ConnectionString",_connectionString);
			appDomain.DoCallBack(SetConnectionStringInAppDomain);
			var service = base.CreateRemoteHost(appDomain);
			return service;
		}
开发者ID:Teleopti,项目名称:Rhino.ServiceBus.SqlQueues,代码行数:7,代码来源:SqlRemoteAppDomainHost.cs

示例3: SetShadowPathForNativeDll

 public static void SetShadowPathForNativeDll(AppDomain appDomain, string dllFileName, string dllPath)
 {
     if (dllFileName == null) throw new ArgumentNullException("dllFileName");
     if (dllPath == null) throw new ArgumentNullException("dllPath");
     var key = AppDomainCustomDllPathKey + dllFileName.ToLowerInvariant();
     appDomain.SetData(key, dllPath);
 }
开发者ID:rock6tsai,项目名称:paradox,代码行数:7,代码来源:NativeLibraryInternal.cs

示例4: simpleButton1_Click

        private void simpleButton1_Click(object sender, EventArgs e)
        {
            OpenFileDialog configform = new OpenFileDialog();
            configform.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory);
            configform.Filter = "程序集文件(*.dll,*.exe)|*.dll;*.exe";
            configform.FilterIndex = 1;
            configform.RestoreDirectory = true;
            if (configform.ShowDialog() == DialogResult.OK)
            {
                try
                {
                    if (currentDomain != null)
                        AppDomain.Unload(currentDomain);
                    currentDomain = AppDomain.CreateDomain("temp");
                    string configfile = configform.FileName + ".config";
                    string filedic = Path.GetDirectoryName(configform.FileName);
                    var m = typeof(AppDomainSetup).GetMethod("UpdateContextProperty", BindingFlags.NonPublic | BindingFlags.Static);
                    var funsion = typeof(AppDomain).GetMethod("GetFusionContext", BindingFlags.NonPublic | BindingFlags.Instance);
                    if(File.Exists(configfile))
                        currentDomain.SetData("APP_CONFIG_FILE", configfile);
                    var test = currentDomain.SetupInformation;
                    exDataAccess = (ExDataAccess)currentDomain.CreateInstanceAndUnwrap(typeof(ExDataAccess).Assembly.FullName, typeof(ExDataAccess).FullName);
                    currentDomain.SetData("APPBASE", filedic);
                    m.Invoke(null, new object[] { funsion.Invoke(currentDomain, null), "APPBASE", filedic });
                    this.textEdit1.Text = configform.FileName;
                    var results = exDataAccess.FindAttributes(configform.FileName);
                    if (results.Count > 0)
                    {
                        this.treeList1.ClearNodes();
                        foreach (var result in results)
                        {
                            this.treeList1.Nodes.Add(result[0], result[1], result[2]);
                        }
                    }

                    currentDomain.SetupInformation.ConfigurationFile =configform.FileName+".config";
                }
                catch(Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
            }
        }
开发者ID:noelhx,项目名称:MultiParamProcessOptimization,代码行数:43,代码来源:ExDataAccessConfigForm.cs

示例5: Run

        //private static void domain_DomainUnload(object sender, EventArgs e)
        //{
        //    Trace.WriteLine("domain_DomainUnload()");
        //}

        static void Run(object runSourceRestartParameters)
        {
            __domain = AppDomain.CreateDomain(__runsourceDomainName);
            if (runSourceRestartParameters != null)
            {
                __domain.SetData(__domainRestartParametersName, runSourceRestartParameters);
                runSourceRestartParameters = null;
            }
            __domain.ExecuteAssembly(Path.Combine(zapp.GetAppDirectory(), __runsourceExeName));
        }
开发者ID:labeuze,项目名称:source,代码行数:15,代码来源:runsource.launch.cs

示例6: ConfigureNewDomain

		public void ConfigureNewDomain(AppDomain domain)
		{
			if (!string.IsNullOrWhiteSpace(AssemblyFolder))
				domain.SetData("Folder", AssemblyFolder);

			if (domain == AppDomain.CurrentDomain)
				ResolveCustomAssemblies();
			else
				domain.DoCallBack(new CrossAppDomainDelegate(ResolveCustomAssemblies));
		}
开发者ID:zhangz,项目名称:Toolbox,代码行数:10,代码来源:AppDomainCreator.cs

示例7: AssemblyStarter

 //ncrunch: no coverage start
 public AssemblyStarter(string assemblyFilePath, bool copyToLocalFolderForExecution)
 {
     if (!File.Exists(assemblyFilePath))
         throw new FileNotFoundException("Assembly not found, unable to start it", assemblyFilePath);
     rememberedDirectory = Directory.GetCurrentDirectory();
     var assemblyFullPath = GetFullPathFromRelativeOrAbsoluteFilePath(assemblyFilePath);
     if (copyToLocalFolderForExecution)
         CopyAssemblyFileAndAllDependencies(assemblyFullPath);
     else if (!string.IsNullOrEmpty(assemblyFullPath))
         Directory.SetCurrentDirectory(assemblyFullPath);
     domain = AppDomain.CreateDomain(DomainName, null, CreateDomainSetup(assemblyFullPath));
     domain.SetData("EntryAssembly", Path.GetFullPath(assemblyFilePath));
 }
开发者ID:remy22,项目名称:DeltaEngine,代码行数:14,代码来源:AssemblyStarter.cs

示例8: CreateAndStartServerInstance

        protected override IManagedAppBase CreateAndStartServerInstance()
        {
            IManagedApp appServer;

            try
            {
                m_HostDomain = CreateHostAppDomain();

                m_HostDomain.SetData(typeof(IsolationMode).Name, IsolationMode.AppDomain);

                var marshalServerType = typeof(MarshalManagedApp);

                appServer = (IManagedApp)m_HostDomain.CreateInstanceAndUnwrap(marshalServerType.Assembly.FullName,
                    marshalServerType.FullName,
                    true,
                    BindingFlags.CreateInstance,
                    null,
                    new object[] { GetMetadata().AppType },
                    null,
                    new object[0]);

                if (!appServer.Setup(Bootstrap, Config))
                {
                    OnExceptionThrown(new Exception("Failed to setup MarshalManagedApp"));
                    return null;
                }

                if (!appServer.Start())
                {
                    OnExceptionThrown(new Exception("Failed to start MarshalManagedApp"));
                    return null;
                }

                m_HostDomain.DomainUnload += new EventHandler(m_HostDomain_DomainUnload);

                return appServer;
            }
            catch (Exception e)
            {
                if (m_HostDomain != null)
                {
                    AppDomain.Unload(m_HostDomain);
                    m_HostDomain = null;
                }

                OnExceptionThrown(e);
                return null;
            }
        }
开发者ID:kerryjiang,项目名称:NRack,代码行数:49,代码来源:AppDomainApp.cs

示例9: Start

        /// <summary>
        /// Starts this server instance.
        /// </summary>
        /// <returns>
        /// return true if start successfull, else false
        /// </returns>
        protected override IWorkItemBase Start()
        {
            IWorkItem appServer;

            try
            {
                m_HostDomain = CreateHostAppDomain();

                m_HostDomain.SetData(typeof(IsolationMode).Name, IsolationMode.AppDomain);

                var marshalServerType = typeof(MarshalAppServer);

                appServer = (IWorkItem)m_HostDomain.CreateInstanceAndUnwrap(marshalServerType.Assembly.FullName,
                        marshalServerType.FullName,
                        true,
                        BindingFlags.CreateInstance,
                        null,
                        new object[] { ServerTypeName },
                        null,
                        new object[0]);

                if (!appServer.Setup(Bootstrap, ServerConfig, Factories))
                {
                    OnExceptionThrown(new Exception("Failed to setup MarshalAppServer"));
                    return null;
                }

                if (!appServer.Start())
                {
                    OnExceptionThrown(new Exception("Failed to start MarshalAppServer"));
                    return null;
                }

                m_HostDomain.DomainUnload += new EventHandler(m_HostDomain_DomainUnload);

                return appServer;
            }
            catch (Exception e)
            {
                if (m_HostDomain != null)
                {
                    AppDomain.Unload(m_HostDomain);
                    m_HostDomain = null;
                }

                OnExceptionThrown(e);
                return null;
            }
        }
开发者ID:huodianyan,项目名称:SuperSocket,代码行数:55,代码来源:AppDomainAppServer.cs

示例10: CreateInstance

 public static RemoteLoader CreateInstance(AppDomain remoteDomain, string csUnitRoot) {
    try {
       remoteDomain.SetData("csUnitRoot", csUnitRoot);
       var remoteLoader = (RemoteLoader) remoteDomain.CreateInstanceFromAndUnwrap(
             Path.Combine(csUnitRoot, "csUnit.Core.dll"),
             typeof(RemoteLoader).FullName);
       return remoteLoader;
    }
    catch (Exception ex) {
       Debug.WriteLine(string.Format("## Listing assemblies in domain '{0}'##", remoteDomain.FriendlyName));
       foreach (var assembly in remoteDomain.GetAssemblies()) {
          Debug.WriteLine(assembly.FullName);
       }
       Debug.WriteLine("## end of list ##");
       Debug.WriteLine("Could not instantiate remote loader. " + ex);
       return null;
    }
 }
开发者ID:ManfredLange,项目名称:csUnit,代码行数:18,代码来源:RemoteLoader.cs

示例11: ProjectExecutionContext

        public ProjectExecutionContext(Project project, IServiceProvider serviceProvider)
        {
            Debug.Assert(project != null, "project is null.");
            Debug.Assert(!VsUtils.IsMiscellaneousProject(project), "project is misc files project.");

            _domain = AppDomain.CreateDomain(
                "ProjectExecutionContextDomain",
                null,
                new AppDomainSetup
                    {
                        ApplicationBase = VsUtils.GetProjectTargetDir(project, serviceProvider),
                        ConfigurationFile = VsUtils.GetProjectConfigurationFile(project, serviceProvider),
                        ShadowCopyFiles = "true" // Prevents locking
                    });

            var dataDirectory = VsUtils.GetProjectDataDirectory(project, serviceProvider);
            if (dataDirectory != null)
            {
                _domain.SetData("DataDirectory", dataDirectory);
            }

            _executor = new ExecutorWrapper(_domain, VsUtils.GetProjectTargetFileName(project));
        }
开发者ID:Cireson,项目名称:EntityFramework6,代码行数:23,代码来源:ProjectExecutionContext.cs

示例12: InitializeAppDomain

 /// <summary>
 /// Initializes the application domain with the debugger proxy.
 /// </summary>
 /// <param name="scriptDomain">The script domain.</param>
 internal static void InitializeAppDomain(AppDomain scriptDomain)
 {
     scriptDomain.SetData(VSDebuggerProxy.AppDomainDataName, debuggerProxy);
 }
开发者ID:southpolenator,项目名称:WinDbgCs,代码行数:8,代码来源:VSContext.cs

示例13: AssociateWithAppDomain

 public void AssociateWithAppDomain(AppDomain domain) {
     Contract.RequiresNotNull(domain, "domain");
     domain.SetData(AppDomainDataKey, this);
 }
开发者ID:JamesTryand,项目名称:IronScheme,代码行数:4,代码来源:ScriptEnvironmentSetup.cs

示例14: LoadAllRunnersIntoAppDomain

        private void LoadAllRunnersIntoAppDomain()
        {
            domain = AppDomain.CreateDomain("Delta Engine Assembly Updater", null, CreateDomainSetup());
            domain.SetData("resolver", resolver);
            domain.SetData("domainInitializationCode", domainInitializationCode);
            domain.DoCallBack(InitializeInDomain);

            foreach (string assembly in AssemblyFilenames)
                LoadRunners(assembly);
        }
开发者ID:lilinghui,项目名称:DeltaEngine,代码行数:10,代码来源:AssemblyUpdater.cs

示例15: Init

        public void Init(bool fullBind)
        {
            string name = Path.GetRandomFileName();
            tempDir = Path.Combine(Path.GetTempPath(), name);
            string robocodeShadow = Path.Combine(tempDir, Path.GetFileName(robocodeAssembly.Location));
            string hostShadow = Path.Combine(tempDir, Path.GetFileName(hostAssembly.Location));
            string controlShadow = Path.Combine(tempDir, Path.GetFileName(controlAssembly.Location));
            string jniShadow = Path.Combine(tempDir, Path.GetFileName(jniAssembly.Location));

            Directory.CreateDirectory(tempDir);
            File.Copy(robocodeAssembly.Location, robocodeShadow);
            File.Copy(controlAssembly.Location, controlShadow);
            File.Copy(hostAssembly.Location, hostShadow);
            File.Copy(jniAssembly.Location, jniShadow);

            var trustAssemblies = new[]
                                      {
                                          Reflection.GetStrongName(robocodeAssembly),
                                          Reflection.GetStrongName(controlAssembly),
                                          Reflection.GetStrongName(hostAssembly),
                                          Reflection.GetStrongName(jniAssembly),
                                      };
            var domainSetup = new AppDomainSetup();
            Evidence securityInfo = AppDomain.CurrentDomain.Evidence;
            var permissionSet = new PermissionSet(PermissionState.None);
            permissionSet.AddPermission(
                new SecurityPermission(SecurityPermissionFlag.Execution | SecurityPermissionFlag.Assertion));
            permissionSet.AddPermission(new FileIOPermission(FileIOPermissionAccess.Read, tempDir));
            permissionSet.AddPermission(new UIPermission(PermissionState.None));
            //permissionSet.AddPermission(HostProtection);

            domainSetup.ApplicationBase = tempDir;

            domainSetup.ApplicationName = name;
            //domainSetup.SandboxInterop = true;
            domainSetup.DisallowBindingRedirects = true;
            domainSetup.DisallowCodeDownload = true;
            domainSetup.DisallowPublisherPolicy = true;
            domainSetup.AppDomainInitializer = AppDomainSeed.Load;
            

            domain = AppDomain.CreateDomain(name, securityInfo, domainSetup, permissionSet, trustAssemblies);
            domain.SetData("fullBind", fullBind);
            domain.SetData("JavaHome", Bridge.Setup.JavaHome);
            domain.DoCallBack(AppDomainSeed.Bind);
        }
开发者ID:khangnguyen,项目名称:robocode,代码行数:46,代码来源:AppDomainShell.cs


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