本文整理汇总了C#中System.AppDomain.ExecuteAssembly方法的典型用法代码示例。如果您正苦于以下问题:C# AppDomain.ExecuteAssembly方法的具体用法?C# AppDomain.ExecuteAssembly怎么用?C# AppDomain.ExecuteAssembly使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.AppDomain
的用法示例。
在下文中一共展示了AppDomain.ExecuteAssembly方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: LaunchAppDomain
public void LaunchAppDomain()
{
UnloadAppDomain();
QAppDomain = AppDomain.CreateDomain("QAppDomain");
AppDomain.MonitoringIsEnabled = true;
string path = Win32Hooks.HookManager.Instance.AssemblyPath;
if(this.EveAccount.DX11) {
t = new Thread(delegate() { QAppDomain.ExecuteAssembly(path + "\\Questor\\Questor.exe",args: new String[] {"-i","-c", Win32Hooks.HookManager.Instance.CharName,"-u", Win32Hooks.HookManager.Instance.EveAccount.AccountName, "-p", Win32Hooks.HookManager.Instance.EveAccount.Password}); });
} else {
t = new Thread(delegate() { QAppDomain.ExecuteAssembly(path + "\\Questor\\Questor.exe",args: new String[] {"-d","-i","-c", Win32Hooks.HookManager.Instance.CharName,"-u", Win32Hooks.HookManager.Instance.EveAccount.AccountName, "-p", Win32Hooks.HookManager.Instance.EveAccount.Password}); });
}
t.Start();
}
示例2: 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));
}
示例3: application2Worker_DoWork
private void application2Worker_DoWork(object sender, DoWorkEventArgs e)
{
//Strange things happens when exiting the Console Application. When pressing the "x" in the window, it closes even the forms application
//and closing then re-opening the console application creates an IOexception. It seems something is not being closed properly. A solution could be
//to re-create the appdomain everytime the console app starts. This is an ugly temporary solution, but it works for now.
cDomain = AppDomain.CreateDomain("ConsoleDomain");
//domain.CreateInstanceFromAndUnwrap(@"C:\Users\Mads\Documents\GitHub\ProgrammeringIII\Programmering III\ApplicationDomainsConsole\bin\Debug\ApplicationDomainsConsole.exe", ")
cDomain.ExecuteAssembly(@"C:\Users\Mads\Documents\GitHub\ProgrammeringIII\Programmering III\ApplicationDomainsConsole\bin\Debug\ApplicationDomainsConsole.exe");
}
示例4: Start
public override void Start()
{
var setup = AppDomainSetup();
try
{
domain = AppDomain.CreateDomain(executable, new Evidence(), setup);
thread = new Thread(() => domain.ExecuteAssembly(GetExecutablePath()));
thread.Start();
}
catch (Exception)
{
AppDomain.Unload(domain);
domain = null;
thread = null;
throw;
}
}
示例5: SwitchDomainForRazorEngine
private static void SwitchDomainForRazorEngine()
{
if (AppDomain.CurrentDomain.IsDefaultAppDomain())
{
// RazorEngine cannot clean up from the default appdomain...
//Console.WriteLine("Switching to secound AppDomain, for RazorEngine...");
AppDomainSetup adSetup = new AppDomainSetup();
adSetup.ApplicationBase = AppDomain.CurrentDomain.SetupInformation.ApplicationBase;
var current = AppDomain.CurrentDomain;
// You only need to add strongnames when your appdomain is not a full trust environment.
var strongNames = new StrongName[0];
_domain = AppDomain.CreateDomain(
"MyMainDomain", null,
current.SetupInformation, new PermissionSet(PermissionState.Unrestricted),
strongNames);
_domain.ExecuteAssembly(Assembly.GetExecutingAssembly().Location);
}
}
示例6: loadServer
public override void loadServer(string filename)
{
if (appDomain != null)
throw new ApplicationException("Server is already loaded");
appDomain = AppDomain.CreateDomain(Utils.randomName(15, 20));
thread = new Thread(new ThreadStart(() => {
try {
appDomain.ExecuteAssembly(filename, null, new string[] { ipcName, ipcUri });
}
catch (NullReferenceException) {
// Here if appDomain was set to null by Dispose() before this thread started
}
catch (AppDomainUnloadedException) {
// Here if it was unloaded by Dispose()
}
unloadAppDomain(appDomain);
appDomain = null;
}));
thread.Start();
}
示例7: RunAssembly
private static void RunAssembly(AppDomain appDomain)
{
appDomain.ExecuteAssembly("../../../LoadedAppDomain/bin/Debug/LoadedAppDomain.exe");
}
示例8: StartFieldWorksThread
internal void StartFieldWorksThread()
{
m_FieldWorksDomain = AppDomain.CreateDomain("Running FieldWorks Domain");
GetFieldWorksInfo().PretendNotRunningUnitTests();
// FIXME: use FwAppArgs.kProject and FwAppArgs.kApp
m_FieldWorksDomain.ExecuteAssembly(typeof(FieldWorks).Assembly.Location, null, new string[] {"-app", App, "-db", Db});
}
示例9: Run
private void Run()
{
string assemblyFile = Assembly.GetEntryAssembly().Location;
string assemblyFolder = Path.GetDirectoryName(assemblyFile);
string assemblyFileName = Path.GetFileNameWithoutExtension(assemblyFile);
var versionDirectory = new VersionDirectoryFinder(log).GetVersionDirectory(assemblyFolder);
if (versionDirectory == null)
{
log.Error("Cannot find any valid directory, which has a name with version pattern.");
Console.ReadKey();
return;
}
var exeDirectory = new DirectoryInfo(Path.Combine(versionDirectory.FullName, assemblyFileName));
var files = exeDirectory.GetFiles("*.exe");
if (files.Length == 0)
throw new FileNotFoundException(string.Format("Cannot find a file with 'exe' extension inside '{0}'",
exeDirectory.FullName));
if (files.Length > 1)
throw new InvalidOperationException(string.Format("There is more than 1 file with 'exe' extension inside '{0}'",
exeDirectory.FullName));
var targetFile = files[0].FullName;
var targetFolder = Path.GetDirectoryName(targetFile);
var targetFileConfig = GetConfigurationFilename(targetFile);
var currentFileConfig = GetConfigurationFilename(assemblyFile);
//targetFileConfig = new ConfigurationFileMerger().MergeFiles(targetFileConfig, currentFileConfig);
try
{
domain = AppDomain.CreateDomain(AppDomain.CurrentDomain.FriendlyName + "_bootstrapped",
AppDomain.CurrentDomain.Evidence,
new AppDomainSetup
{
ConfigurationFile = targetFileConfig,
ApplicationBase = targetFolder,
});
var logger = (UnhandledExceptionLogger)domain.CreateInstanceFromAndUnwrap(Assembly.GetExecutingAssembly().Location,
typeof(UnhandledExceptionLogger).FullName,
false, BindingFlags.Default, null, null,
Thread.CurrentThread.CurrentCulture, null);
logger.ProcessUnhandledExceptions();
BootstrapperParameters.WriteToDomain(new BootstrapperParameters
{
BootstrapperFile = assemblyFile,
ConfigurationFile = currentFileConfig,
}, domain);
// var newArgs = new List<string>(args);
// newArgs.AddRange(.ToArray());
var returnValue = domain.ExecuteAssembly(targetFile, args);
AppDomain.Unload(domain);
if (returnValue == (int) ReturnCodes.RestartDueToAvailableUpdate || returnValue == (int) ReturnCodes.RestartDueToConfigChange)
Main(args);
}
catch (Exception ex)
{
log.Error("An error occurred while running bootstrapped program", ex);
Console.ReadLine();
}
}
示例10: InvokeAppDomain
private void InvokeAppDomain(AppDomain domain)
{
domain.ExecuteAssembly(domain.FriendlyName);
}
示例11: ExecuteAssembly
private static int ExecuteAssembly(string exePath, AppDomain domain)
{
return domain.ExecuteAssembly(exePath);
}