Created
December 17, 2010 20:24
-
-
Save beccasaurus/745645 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Threading.Tasks; | |
namespace AppThatRunsItself { | |
public class App { | |
public static void Main(string[] args) { | |
// we might instantiate a host and run an app with it | |
var host = new Hosting.Host(); | |
var dotNet40_thing = new Task(() => Console.WriteLine("Hello from task")); | |
// we might ask the host to run our app ... but we'll just pass it .NET 4.0 stuff | |
host.GimmeShit(dotNet40_thing); | |
} | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Reflection; | |
namespace Hosting { | |
public class Host { | |
string CurrentRuntime { | |
get { return Environment.Version.ToString(); } | |
} | |
string CompiledRuntime { | |
get { return Assembly.GetExecutingAssembly().ImageRuntimeVersion; } | |
} | |
public void GimmeShit(object shit) { | |
Console.WriteLine("Host.GimmeShit was passed a {0}. Running on: {1}. Compiled on: {2}", | |
shit, CurrentRuntime, CompiledRuntime); | |
} | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# compile host.cs against .NET 2.0 | |
$ gmcs -t:library host.cs | |
# compile app.cs against .NET 4.0, referencing host.dll | |
dmcs app.cs -r:host.dll | |
# run app.exe in the .NET 4.0 runtime | |
$ mono-2.8 app.exe | |
Host.GimmeShit was passed a System.Threading.Tasks.Task. Running on: 4.0.30319.1. Compiled on: v2.0.50727 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment