• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# AppDomain类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



AppDomain类属于命名空间,在下文中一共展示了AppDomain类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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


示例16: Module

        internal Module(AppDomain appDomain, ICorDebugModule corModule)
        {
            this.appDomain = appDomain;
            this.process = appDomain.Process;
            this.corModule = corModule;

            metaData = new MetaDataImport(corModule);

            if (IsDynamic || IsInMemory) {
                name     = corModule.GetName();
            } else {
                fullPath = corModule.GetName();
                name     = System.IO.Path.GetFileName(FullPath);
            }
            asmFilename = corModule.GetAssembly().GetName();

            SetJITCompilerFlags();

            LoadSymbolsFromDisk(process.Options.SymbolsSearchPaths);
            ResetJustMyCodeStatus();
        }
开发者ID:BahNahNah,项目名称:dnSpy,代码行数:21,代码来源:Module.cs


示例17: MyCreateCallee

   private static Type MyCreateCallee(AppDomain domain)
   {
      AssemblyName myAssemblyName = new AssemblyName();
      myAssemblyName.Name = "EmittedAssembly";
      // Define a dynamic assembly in the current application domain.
      AssemblyBuilder myAssembly =
                  domain.DefineDynamicAssembly(myAssemblyName,AssemblyBuilderAccess.Run);
      // Define a dynamic module in this assembly.
      ModuleBuilder myModuleBuilder = myAssembly.DefineDynamicModule("EmittedModule");
      // Construct a 'TypeBuilder' given the name and attributes.
      TypeBuilder myTypeBuilder = myModuleBuilder.DefineType("HelloWorld",
         TypeAttributes.Public);
      // Define a constructor of the dynamic class.
      ConstructorBuilder myConstructor = myTypeBuilder.DefineConstructor(
               MethodAttributes.Public, CallingConventions.Standard, new Type[]{typeof(String)});
      ILGenerator myILGenerator = myConstructor.GetILGenerator();
      myILGenerator.Emit(OpCodes.Ldstr, "Constructor is invoked");
      myILGenerator.Emit(OpCodes.Ldarg_1);
      MethodInfo myMethodInfo =
                     typeof(Console).GetMethod("WriteLine",new Type[]{typeof(string)});
      myILGenerator.Emit(OpCodes.Call, myMethodInfo);
      myILGenerator.Emit(OpCodes.Ret);
      Type myType = typeof(MyAttribute);
      ConstructorInfo myConstructorInfo = myType.GetConstructor(new Type[]{typeof(object)});
      try
      {
        CustomAttributeBuilder methodCABuilder = new CustomAttributeBuilder (myConstructorInfo, new object [] { TypeCode.Double } );        

         myConstructor.SetCustomAttribute(methodCABuilder);
      }
      catch(ArgumentNullException ex)
      {
         Console.WriteLine("The following exception has occured : "+ex.Message);
      }
      catch(Exception ex)
      {
         Console.WriteLine("The following exception has occured : "+ex.Message);
      }
      return myTypeBuilder.CreateType();
   }
开发者ID:nobled,项目名称:mono,代码行数:40,代码来源:test-295.cs


示例18: Value

        internal Value(AppDomain appDomain, ICorDebugValue corValue)
        {
            if (corValue == null)
                throw new ArgumentNullException("corValue");
            this.appDomain = appDomain;
            this.corValue = corValue;
            this.corValue_pauseSession = this.Process.PauseSession;

            this.isNull = corValue is ICorDebugReferenceValue && ((ICorDebugReferenceValue)corValue).IsNull() != 0;

            if (corValue is ICorDebugReferenceValue &&
                ((ICorDebugReferenceValue)corValue).GetValue() == 0 &&
                ((ICorDebugValue2)corValue).GetExactType() == null)
            {
                // We were passed null reference and no metadata description
                // (happens during CreateThread callback for the thread object)
                this.type = appDomain.ObjectType;
            } else {
                ICorDebugType exactType = ((ICorDebugValue2)this.CorValue).GetExactType();
                this.type = DebugType.CreateFromCorType(appDomain, exactType);
            }
        }
开发者ID:BahNahNah,项目名称:dnSpy,代码行数:22,代码来源:Value.cs


示例19: AppDomain

		static AppDomain()
		{
			CurrentDomain = new AppDomain();
		}
开发者ID:samueldjack,项目名称:ravendb,代码行数:4,代码来源:AppDomain.cs


示例20: CheckPermissionSet

		internal static IPermission CheckPermissionSet (AppDomain ad, PermissionSet ps)
		{
			if ((ps == null) || ps.IsEmpty ())
				return null;

			PermissionSet granted = ad.GrantedPermissionSet;
			if (granted == null)
				return null;
			if (granted.IsUnrestricted ())
				return null;
			if (ps.IsUnrestricted ())
				return new SecurityPermission (SecurityPermissionFlag.NoFlags);

			foreach (IPermission p in ps) {
				if (p is CodeAccessPermission) {
					CodeAccessPermission grant = (CodeAccessPermission) granted.GetPermission (p.GetType ());
					if (grant == null) {
						if (!granted.IsUnrestricted () || !(p is IUnrestrictedPermission)) {
							if (!p.IsSubsetOf (null))
								return p;
						}
					} else if (!p.IsSubsetOf (grant)) {
						return p;
					}
				} else {
					// but non-CAS will throw on failure...
					try {
						p.Demand ();
					}
					catch (SecurityException) {
						// ... so we catch
						return p;
					}
				}
			}
			return null;
		}
开发者ID:shana,项目名称:mono,代码行数:37,代码来源:SecurityManager.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# AppFunc类代码示例发布时间:2022-05-24
下一篇:
C# AppDelegate类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap