Skip to content

Instantly share code, notes, and snippets.

@codingarchitect
Created January 18, 2017 08:38
Show Gist options
  • Select an option

  • Save codingarchitect/9ac448fc25cbe12374b5db05e0e24d86 to your computer and use it in GitHub Desktop.

Select an option

Save codingarchitect/9ac448fc25cbe12374b5db05e0e24d86 to your computer and use it in GitHub Desktop.
LINQPad Query that compiles code to a different executable and executes it in a different app domain with shadow copying - The executable folder can be used to execute the exe standalone as well.
<Query Kind="Program">
<Reference>&lt;RuntimeDirectory&gt;\Microsoft.CSharp.dll</Reference>
<Reference>&lt;RuntimeDirectory&gt;\System.Runtime.InteropServices.dll</Reference>
<Reference>&lt;RuntimeDirectory&gt;\System.Runtime.InteropServices.WindowsRuntime.dll</Reference>
<NuGetReference>CodingArchitect.Utilities</NuGetReference>
<NuGetReference>Microsoft.Web.Administration</NuGetReference>
<NuGetReference>NHibernate</NuGetReference>
<NuGetReference>NUnitLite</NuGetReference>
<NuGetReference>SqlLocalDb</NuGetReference>
<Namespace>CodingArchitect.Utilities.AppDomain</Namespace>
<Namespace>Microsoft.CSharp</Namespace>
<Namespace>Microsoft.CSharp.RuntimeBinder</Namespace>
<Namespace>System.CodeDom.Compiler</Namespace>
<Namespace>System.Runtime.InteropServices</Namespace>
</Query>
void Main(string[] args)
{
var queryDirectory = Path.GetDirectoryName(Util.CurrentQueryPath);
var companyName = "CodingArchitect";
var applicationName = "AppDomain";
CodingArchitect.Utilities.Linqpad.Util.SetupApplication(companyName, applicationName, queryDirectory, Util.CurrentQueryPath);
}
// Define other methods and classes here
}
#region Service Classes
namespace CodingArchitect.Spikes.AppDomain
{
using NUnitLite;
using CodingArchitect.Utilities.AppDomain;
public class Program : ConsoleCatcherBase
{
public override void DoExecute()
{
Console.WriteLine("Hello World");
}
public static void Main(string[] args)
{
new Program().DoExecute();
}
}
}
#endregion
class EOF {
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment