Skip to content

Instantly share code, notes, and snippets.

@jonpryor
Created January 17, 2013 16:49
Show Gist options
  • Save jonpryor/4557439 to your computer and use it in GitHub Desktop.
Save jonpryor/4557439 to your computer and use it in GitHub Desktop.
diff --git a/PluginExample/Program.cs b/PluginExample/Program.cs
index 7d45ae6..1e320f5 100644
--- a/PluginExample/Program.cs
+++ b/PluginExample/Program.cs
@@ -1,5 +1,6 @@
using System;
using System.Net;
+using System.IO;
using System.Security;
using System.Security.Permissions;
using System.Security.Policy;
@@ -10,11 +11,19 @@ namespace PluginExample {
class Program : IPluginHost {
static void Main(string[] args) {
- object plugindom = CreateSandboxedDomain(@"C:\Users\blez\Desktop\PluginExample\TestPlugin\bin\Release\TestPlugin.dll", "TestPlugin", "TestPlugin.ExampleClass", false);
+ // object plugindom = CreateSandboxedDomain(@"C:\Users\blez\Desktop\PluginExample\TestPlugin\bin\Release\TestPlugin.dll", "TestPlugin", "TestPlugin.ExampleClass", false);
+ string dir = Path.GetDirectoryName (typeof (Program).Assembly.Location);
+ object plugindom = CreateSandboxedDomain(
+ Path.Combine (dir, "..", "..", "..", "TestPlugin", "bin", "Release", "TestPlugin.dll"),
+ "TestPlugin", "TestPlugin.ExampleClass", false);
var examplePlugin = (IPlugin) plugindom;
examplePlugin.Host = new Program();
+ try {
Console.WriteLine(examplePlugin.SomeMethod("Hello world"));
+ } catch (Exception e) {
+ Console.WriteLine ("Exception caught invoking plugin: {0}", e);
+ }
//Console.WriteLine("An app domain is now started and running in the background.");
//Console.WriteLine("Press any key to terminate and unload the restricted appdomain!");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment