本文整理汇总了C#中System.AppDomain类的典型用法代码示例。如果您正苦于以下问题:C# AppDomain类的具体用法?C# AppDomain怎么用?C# AppDomain使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
AppDomain类属于System命名空间,在下文中一共展示了AppDomain类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: RegisterAppDomainUnhandledExceptionHandler
public static void RegisterAppDomainUnhandledExceptionHandler(this ExceptionlessClient client, AppDomain appDomain = null) {
if (appDomain == null)
appDomain = AppDomain.CurrentDomain;
if (_onAppDomainUnhandledException == null)
_onAppDomainUnhandledException = (sender, args) => {
var exception = args.ExceptionObject as Exception;
if (exception == null)
return;
var contextData = new ContextData();
contextData.MarkAsUnhandledError();
contextData.SetSubmissionMethod("AppDomainUnhandledException");
exception.ToExceptionless(contextData, client).Submit();
// process queue immediately since the app is about to exit.
client.ProcessQueue();
};
try {
appDomain.UnhandledException -= _onAppDomainUnhandledException;
appDomain.UnhandledException += _onAppDomainUnhandledException;
} catch (Exception ex) {
client.Configuration.Resolver.GetLog().Error(typeof(ExceptionlessClientExtensions), ex, "An error occurred while wiring up to the unhandled exception event. This will happen when you are not running under full trust.");
}
}
示例2: Dispose
public void Dispose()
{
_extActivator.Dispose();
_extActivator = null;
AppDomain.Unload(_appdomain);
_appdomain = null;
}
示例3: FrameworkDriver
/// <summary>
/// Construct a FrameworkDriver for a particular assembly in a domain,
/// and associate some settings with it. The assembly must reference
/// the NUnit framework so that we can remotely create the FrameworkController.
/// </summary>
/// <param name="assemblyPath">The path to the test assembly</param>
/// <param name="testDomain">The domain in which the assembly will be loaded</param>
/// <param name="settings">A dictionary of load and run settings</param>
public FrameworkDriver(string assemblyPath, AppDomain testDomain, IDictionary<string, object> settings)
{
this.testDomain = testDomain;
this.assemblyPath = assemblyPath;
this.settings = settings;
this.testController = CreateObject(CONTROLLER_TYPE, assemblyPath, settings);
}
示例4: BuildChildDomain
/// <summary>
/// Creates a new child domain and copies the evidence from a parent domain.
/// </summary>
/// <param name="parentDomain">The parent domain.</param>
/// <returns>The new child domain.</returns>
/// <remarks>
/// Grabs the <paramref name="parentDomain"/> evidence and uses it to construct the new
/// <see cref="AppDomain"/> because in a ClickOnce execution environment, creating an
/// <see cref="AppDomain"/> will by default pick up the partial trust environment of
/// the AppLaunch.exe, which was the root executable. The AppLaunch.exe does a
/// create domain and applies the evidence from the ClickOnce manifests to
/// create the domain that the application is actually executing in. This will
/// need to be Full Trust for Composite Application Library applications.
/// </remarks>
protected virtual AppDomain BuildChildDomain(AppDomain parentDomain)
{
Evidence evidence = new Evidence(parentDomain.Evidence);
AppDomainSetup setup = parentDomain.SetupInformation;
var domain = AppDomain.CreateDomain("DiscoveryRegion", evidence, setup);
return domain;
}
示例5: BuildChildDomain
/// <summary>
/// Creates a new child domain and copies the evidence from a parent domain.
/// </summary>
/// <param name="parentDomain">The parent domain.</param>
/// <returns>The new child domain.</returns>
/// <remarks>
/// Grabs the <paramref name="parentDomain"/> evidence and uses it to construct the new
/// <see cref="AppDomain"/> because in a ClickOnce execution environment, creating an
/// <see cref="AppDomain"/> will by default pick up the partial trust environment of
/// the AppLaunch.exe, which was the root executable. The AppLaunch.exe does a
/// create domain and applies the evidence from the ClickOnce manifests to
/// create the domain that the application is actually executing in. This will
/// need to be Full Trust for Composite Application Library applications.
/// </remarks>
public static AppDomain BuildChildDomain(AppDomain parentDomain)
{
if (parentDomain == null) throw new ArgumentNullException("parentDomain");
var evidence = new Evidence(parentDomain.Evidence);
AppDomainSetup setup = parentDomain.SetupInformation;
return AppDomain.CreateDomain("DiscoveryRegion", evidence, setup);
}
示例6: LoadDecisionModule
/// <summary>
/// Loads the decision module based on the decision metadata
/// </summary>
/// <param name="decisionMetadata">The decision metadata.</param>
/// <param name="workspaceWrapper">The workspace wrapper.</param>
/// <param name="componentsAppDomain">The components app domain is the app domain which decision assembly is going to be loaded into.</param>
/// <returns>Loaded decision</returns>
internal static ILoopDecisionModule LoadDecisionModule(LoopScopeMetadata loopMetadata, IWorkspaceInternal workspaceWrapper,
AppDomain componentsAppDomain)
{
DecisionLoader loader = ConstructDecisionModuleInComponentsAppDomain(loopMetadata, workspaceWrapper, componentsAppDomain);
return (ILoopDecisionModule)loader.LoadedDecisionModule;
}
示例7: Dispose
public void Dispose()
{
var dir = Domain.BaseDirectory;
AppDomain.Unload(Domain);
Directory.Delete(dir, true);
Domain = null;
}
示例8: AssemblyEmitter
public AssemblyEmitter( string assemblyName, bool canSave )
{
m_AssemblyName = assemblyName;
m_AppDomain = AppDomain.CurrentDomain;
m_AssemblyBuilder = m_AppDomain.DefineDynamicAssembly(
new AssemblyName( assemblyName ),
canSave ? AssemblyBuilderAccess.RunAndSave : AssemblyBuilderAccess.Run
);
if ( canSave )
{
m_ModuleBuilder = m_AssemblyBuilder.DefineDynamicModule(
assemblyName,
String.Format( "{0}.dll", assemblyName.ToLower() ),
false
);
}
else
{
m_ModuleBuilder = m_AssemblyBuilder.DefineDynamicModule(
assemblyName,
false
);
}
}
示例9: Print
// Private Methods
private static void Print(AppDomain defaultAppDomain)
{
Assembly[] loadedAssemblies = defaultAppDomain.GetAssemblies();
Console.WriteLine("Here are the assemblies loaded in {0}\n", defaultAppDomain.FriendlyName);
foreach (Assembly a in loadedAssemblies)
PrintAssemblyName(a.GetName());
}
示例10: Load
public override bool Load( TestPackage package )
{
Unload();
log.Info("Loading " + package.Name);
try
{
if ( this.domain == null )
this.domain = Services.DomainManager.CreateDomain( package );
if (this.agent == null)
{
this.agent = DomainAgent.CreateInstance(domain);
this.agent.Start();
}
if ( this.TestRunner == null )
this.TestRunner = this.agent.CreateRunner( this.ID );
log.Info(
"Loading tests in AppDomain, see {0}_{1}.log",
domain.FriendlyName,
Process.GetCurrentProcess().Id);
return TestRunner.Load( package );
}
catch
{
log.Error("Load failure");
Unload();
throw;
}
}
示例11: AppDomainTypeResolver
protected AppDomainTypeResolver(AppDomain domain, string baseDir)
{
_domain = domain;
this.baseDir = baseDir;
domain.AssemblyResolve += new ResolveEventHandler(domain_AssemblyResolve);
}
示例12: CreateRemoteHost
protected override HostedService CreateRemoteHost(AppDomain appDomain)
{
appDomain.SetData("ConnectionString",_connectionString);
appDomain.DoCallBack(SetConnectionStringInAppDomain);
var service = base.CreateRemoteHost(appDomain);
return service;
}
示例13: Init
public virtual void Init()
{
serverDomain = AppDomainFactory.Create("server");
clientDomain = AppDomainFactory.Create("client");
serverContainer = CreateRemoteContainer(serverDomain, GetServerConfigFile());
}
示例14: RemoteDebugger
public RemoteDebugger()
{
// Create a new debugger session
mSessionId = Guid.NewGuid().ToString();
Evidence evidence = new Evidence(AppDomain.CurrentDomain.Evidence);
AppDomainSetup appDomainSetup = AppDomain.CurrentDomain.SetupInformation;
mAppDomain = AppDomain.CreateDomain(String.Format("Debugger-{0}", mSessionId), evidence, appDomainSetup);
/*
Type assemblyLoaderType = typeof(AssemblyLoader);
AssemblyLoader loader = mAppDomain.CreateInstanceAndUnwrap(assemblyLoaderType.Assembly.GetName().Name, assemblyLoaderType.FullName) as AssemblyLoader;
foreach (String assemblyPath in Directory.GetFiles(DebuggerConfig.ApplicationPath, "Tridion*.dll"))
{
loader.LoadAssembly(assemblyPath);
}
*/
Type debuggerHostType = typeof(DebugEngineServer);
mDebuggerHost = mAppDomain.CreateInstanceAndUnwrap(
debuggerHostType.Assembly.GetName().Name,
debuggerHostType.FullName,
true,
BindingFlags.Default,
null,
new Object[] { mSessionId },
null,
null) as DebugEngineServer;
}
示例15: AppDomainEvidenceFactory
internal AppDomainEvidenceFactory(AppDomain target)
{
Contract.Assert(target != null);
Contract.Assert(target == AppDomain.CurrentDomain, "AppDomainEvidenceFactory should not be used across domains.");
m_targetDomain = target;
}