本文整理汇总了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());
}
示例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;
}
示例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();
}
示例4: BuildChildDomain
private static AppDomain BuildChildDomain(AppDomain parentDomain)
{
var evidence = new Evidence(parentDomain.Evidence);
AppDomainSetup setup = parentDomain.SetupInformation;
return AppDomain.CreateDomain("DiscoveryRegion",
evidence, setup);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
}
示例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;
}
示例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);
}
}
示例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;
}
示例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");
};
}
示例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);
}
示例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);
}
}
示例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);
}