當前位置: 首頁>>代碼示例>>C#>>正文


C# AppDomain類代碼示例

本文整理匯總了C#中AppDomain的典型用法代碼示例。如果您正苦於以下問題:C# AppDomain類的具體用法?C# AppDomain怎麽用?C# AppDomain使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


AppDomain類屬於命名空間,在下文中一共展示了AppDomain類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: StackFrame

		internal StackFrame(Thread thread, ICorDebugILFrame corILFrame, uint chainIndex, uint frameIndex)
		{
			this.process = thread.Process;
			this.thread = thread;
			this.appDomain = process.AppDomains[corILFrame.GetFunction().GetClass().GetModule().GetAssembly().GetAppDomain()];
			this.corILFrame = corILFrame;
			this.corILFramePauseSession = process.PauseSession;
			this.corFunction = corILFrame.GetFunction();
			this.chainIndex = chainIndex;
			this.frameIndex = frameIndex;
			
			MetaDataImport metaData = thread.Process.Modules[corFunction.GetClass().GetModule()].MetaData;
			int methodGenArgs = metaData.EnumGenericParams(corFunction.GetToken()).Length;
			// Class parameters are first, then the method ones
			List<ICorDebugType> corGenArgs = ((ICorDebugILFrame2)corILFrame).EnumerateTypeParameters().ToList();
			// Remove method parametrs at the end
			corGenArgs.RemoveRange(corGenArgs.Count - methodGenArgs, methodGenArgs);
			List<DebugType> genArgs = new List<DebugType>(corGenArgs.Count);
			foreach(ICorDebugType corGenArg in corGenArgs) {
				genArgs.Add(DebugType.CreateFromCorType(this.AppDomain, corGenArg));
			}
			
			DebugType debugType = DebugType.CreateFromCorClass(
				this.AppDomain,
				null,
				corFunction.GetClass(),
				genArgs.ToArray()
			);
			this.methodInfo = (DebugMethodInfo)debugType.GetMember(corFunction.GetToken());
		}
開發者ID:Bombadil77,項目名稱:SharpDevelop,代碼行數:30,代碼來源:StackFrame.cs

示例2: GetRemote

	public static Foo GetRemote (AppDomain domain)
	{
		Foo test = (Foo) domain.CreateInstanceAndUnwrap (
			typeof (Foo).Assembly.FullName,
			typeof (Foo).FullName, new object [0]);
		return test;
	}
開發者ID:nlhepler,項目名稱:mono,代碼行數:7,代碼來源:t46-lib.cs

示例3: ExecuteInOwnAppDomain

    void ExecuteInOwnAppDomain()
    {
        if (WeaversHistory.HasChanged(Weavers.Select(x => x.AssemblyPath)) || appDomain == null)
        {
            if (appDomain != null)
            {
                AppDomain.Unload(appDomain);
            }

            var appDomainSetup = new AppDomainSetup
                                     {
                                         ApplicationBase = AssemblyLocation.CurrentDirectory(),
                                     };
            appDomain = AppDomain.CreateDomain("Fody", null, appDomainSetup);
        }
        var innerWeaver = (IInnerWeaver) appDomain.CreateInstanceAndUnwrap("FodyIsolated", "InnerWeaver");
        innerWeaver.AssemblyPath = AssemblyPath;
        innerWeaver.References = References;
        innerWeaver.KeyFilePath = KeyFilePath;
        innerWeaver.Logger = Logger;
        innerWeaver.AssemblyPath = AssemblyPath;
        innerWeaver.Weavers = Weavers;
        innerWeaver.IntermediateDir = IntermediateDir;
        innerWeaver.Execute();
    }
開發者ID:yanglee,項目名稱:Fody,代碼行數:25,代碼來源:Processor.cs

示例4: BuildChildDomain

 private static AppDomain BuildChildDomain(AppDomain parentDomain)
 {
     var evidence = new Evidence(parentDomain.Evidence);
     AppDomainSetup setup = parentDomain.SetupInformation;
     return AppDomain.CreateDomain("DiscoveryRegion",
         evidence, setup);
 }
開發者ID:greengiant83,項目名稱:shellexplorer,代碼行數:7,代碼來源:Importer.cs

示例5: DisplayDADStats

 static void DisplayDADStats(AppDomain domain)
 {
     // Get access to the AppDomain for the current thread
     Console.WriteLine("Name of this domain: {0}", domain.FriendlyName);
     Console.WriteLine("ID of domain in this process: {0}", domain.Id);
     Console.WriteLine("Is this the default domain?: {0}", domain.IsDefaultAppDomain());
     Console.WriteLine("Base Directory of this domain: {0}", domain.BaseDirectory);
 }
開發者ID:walrus7521,項目名稱:code,代碼行數:8,代碼來源:Domain.cs

示例6: CreateCrossDomainTester

	static CrossDomainTester CreateCrossDomainTester (AppDomain domain)
	{
		Type testerType = typeof (CrossDomainTester);

		return (CrossDomainTester) domain.CreateInstanceAndUnwrap (
			testerType.Assembly.FullName, testerType.FullName, false,
			BindingFlags.Public | BindingFlags.Instance, null, new object [0],
			CultureInfo.InvariantCulture, new object [0], domain.Evidence);
	}
開發者ID:mono,項目名稱:gert,代碼行數:9,代碼來源:test.cs

示例7: Main

 private static void Main()
 {
     Class32.appDomain_0 = AppDomain.CreateDomain("NovoFatum R3", null);
     Class1.smethod_0();
     Application.EnableVisualStyles();
     Application.SetCompatibleTextRenderingDefault(false);
     Class0.main_0 = new Main();
     Application.Run(Class0.main_0);
 }
開發者ID:ZelkovaHabbo,項目名稱:NovoFatum_Raw_Cracked,代碼行數:9,代碼來源:Class32.cs

示例8: ListAllAssembliesInAppDomain

 static void ListAllAssembliesInAppDomain(AppDomain domain)
 {
     Assembly[] loadedAssemblies = domain.GetAssemblies();
     Console.WriteLine("**** Here are the assemblies loaded in {0} ******\n",
             domain.FriendlyName);
     foreach (Assembly a in loadedAssemblies) {
         Console.WriteLine("-> Name: {0}", a.GetName().Name);
         Console.WriteLine("-> Version: {0}", a.GetName().Version);
     }
 }
開發者ID:walrus7521,項目名稱:code,代碼行數:10,代碼來源:Domain.cs

示例9: Main

	static int Main ()
	{
		AppDomain.Unload (AppDomain.CreateDomain ("Warmup unload code"));
		Console.WriteLine (".");
		ad = AppDomain.CreateDomain ("NewDomain");
		ad.DoCallBack (Bla);
		var t = new Thread (UnloadIt);
		t.IsBackground = true;
		t.Start ();
		evt.WaitOne ();
		return 0;
	}
開發者ID:Zman0169,項目名稱:mono,代碼行數:12,代碼來源:unload-appdomain-on-shutdown.cs

示例10: ListAllAssembliesInAppDomain2

    static void ListAllAssembliesInAppDomain2(AppDomain domain)
    {
        var loadedAssemblies = from a in domain.GetAssemblies()
            orderby a.GetName().Name select a;

        Console.WriteLine("**** Here are the assemblies loaded in {0} ******\n",
                domain.FriendlyName);
        foreach (var a in loadedAssemblies) {
            Console.WriteLine("-> Name: {0}", a.GetName().Name);
            Console.WriteLine("-> Version: {0}", a.GetName().Version);
        }
    }
開發者ID:walrus7521,項目名稱:code,代碼行數:12,代碼來源:Domain.cs

示例11: DefineDynamicAssembly

	static Assembly DefineDynamicAssembly (AppDomain domain)
	{
		AssemblyName assemblyName = new AssemblyName ();
		assemblyName.Name = "MyDynamicAssembly";

		AssemblyBuilder assemblyBuilder = domain.DefineDynamicAssembly (assemblyName, AssemblyBuilderAccess.Run);
		ModuleBuilder moduleBuilder = assemblyBuilder.DefineDynamicModule ("MyDynamicModule");
		TypeBuilder typeBuilder = moduleBuilder.DefineType ("MyDynamicType", TypeAttributes.Public);
		ConstructorBuilder constructorBuilder = typeBuilder.DefineConstructor (MethodAttributes.Public, CallingConventions.Standard, null);
		ILGenerator ilGenerator = constructorBuilder.GetILGenerator ();
		ilGenerator.EmitWriteLine ("MyDynamicType instantiated!");
		ilGenerator.Emit (OpCodes.Ret);
		typeBuilder.CreateType ();
		return assemblyBuilder;
	}
開發者ID:Zman0169,項目名稱:mono,代碼行數:15,代碼來源:assembly_append_ordering.cs

示例12: InitDAD

    static void InitDAD(AppDomain domain)
    {
        // this prints out the name of any assembly
        // loaded into the domain, after it has been
        // created.
        domain.AssemblyLoad += (o, s) =>
        {
            Console.WriteLine("\n{0} has just now been loaded!!\n", s.LoadedAssembly.GetName().Name);
        };

        domain.ProcessExit += (o, s) =>
        {
            Console.WriteLine("\nAD has just been unloaded!!\n");
        };
    }
開發者ID:walrus7521,項目名稱:code,代碼行數:15,代碼來源:Domain.cs

示例13: ManifestRunner

        internal ManifestRunner (AppDomain domain, ActivationContext activationContext) {
            m_domain = domain;

            string file, parameters;
            CmsUtils.GetEntryPoint(activationContext, out file, out parameters);
            if (parameters == null || parameters.Length == 0)
                m_args = new string[0];
            else
                m_args = parameters.Split(' ');

            m_apt = ApartmentState.Unknown;

            // get the 'merged' application directory path.
            string directoryName = activationContext.ApplicationDirectory;
            m_path = Path.Combine(directoryName, file);
        }
開發者ID:gbarnett,項目名稱:shared-source-cli-2.0,代碼行數:16,代碼來源:applicationactivator.cs

示例14: Eval

		Eval(AppDomain appDomain, string description, EvalStarter evalStarter)
		{
			this.appDomain = appDomain;
			this.process = appDomain.Process;
			this.description = description;
			this.state = EvalState.Evaluating;
			this.thread = GetEvaluationThread(appDomain);
			this.corEval = thread.CorThread.CreateEval();
			
			try {
				evalStarter(this);
			} catch (COMException e) {
				if ((uint)e.ErrorCode == 0x80131C26) {
					throw new GetValueException("Can not evaluate in optimized code");
				} else if ((uint)e.ErrorCode == 0x80131C28) {
					throw new GetValueException("Object is in wrong AppDomain");
				} else if ((uint)e.ErrorCode == 0x8013130A) {
					// Happens on getting of Sytem.Threading.Thread.ManagedThreadId; See SD2-1116
					throw new GetValueException("Function does not have IL code");
				} else if ((uint)e.ErrorCode == 0x80131C23) {
					// The operation failed because it is a GC unsafe point. (Exception from HRESULT: 0x80131C23)
					// This can probably happen when we break and the thread is in native code
					throw new GetValueException("Thread is in GC unsafe point");
				} else if ((uint)e.ErrorCode == 0x80131C22) {
					// The operation is illegal because of a stack overflow.
					throw new GetValueException("Can not evaluate after stack overflow");
				} else if ((uint)e.ErrorCode == 0x80131313) {
					// Func eval cannot work. Bad starting point.
					// Reproduction circumstancess are unknown
					throw new GetValueException("Func eval cannot work. Bad starting point.");
				} else {
					#if DEBUG
						throw; // Expose for more diagnostics
					#else
						throw new GetValueException(e.Message);
					#endif
				}
			}
			
			appDomain.Process.ActiveEvals.Add(this);
			
			if (appDomain.Process.Options.SuspendOtherThreads) {
				appDomain.Process.AsyncContinue(DebuggeeStateAction.Keep, new Thread[] { thread }, CorDebugThreadState.THREAD_SUSPEND);
			} else {
				appDomain.Process.AsyncContinue(DebuggeeStateAction.Keep, this.Process.UnsuspendedThreads, CorDebugThreadState.THREAD_RUN);
			}
		}
開發者ID:KAW0,項目名稱:Alter-Native,代碼行數:47,代碼來源:Eval.cs

示例15: ManifestRunner

        internal ManifestRunner (AppDomain domain, ActivationContext activationContext) {
            m_domain = domain;

            string file, parameters;
            CmsUtils.GetEntryPoint(activationContext, out file, out parameters);

            if (String.IsNullOrEmpty(file))
                throw new ArgumentException(Environment.GetResourceString("Argument_NoMain"));

            if (String.IsNullOrEmpty(parameters))
                m_args = new string[0];
            else
                m_args = parameters.Split(' ');

            m_apt = ApartmentState.Unknown;

            // get the 'merged' application directory path.
            string directoryName = activationContext.ApplicationDirectory;
            m_path = Path.Combine(directoryName, file);
        }
開發者ID:nlh774,項目名稱:DotNetReferenceSource,代碼行數:20,代碼來源:ApplicationActivator.cs


注:本文中的AppDomain類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。