Game Development Reference
In-Depth Information
routes messages to and from the proxy object. This class also handles a temporary
AppDomain used to load the plugin assembly independent from the main AppDomain .
using System;
using System.IO;
using System.Security;
using System.Security.Permissions;
using System.Security.Policy;
using System.Collections;
namespace Plugin.Manager
using Plugin.API;
public sealed class PluginLibrary
private AppDomain appDomain;
private PluginProxy proxy;
private string name = string.Empty;
public string Name
get { return name; }
The following method is used to load a plugin assembly from the file system into
memory, create a temporary AppDomain with enforced security permissions, and
instantiate the proxy object within the temporary AppDomain . If the plugin file is
source code, then the plugin is compiled and loaded afterwards. The supported source
code languages are C#, VB.NET, and J#. The default settings for the security policy
will deny the ability to compile source code at runtime, but you can either change
the policy file or disable security by commenting out EnforceSecurityPolicy() .
Remember to only do this in a fully trusted environment.
public bool Load(DirectoryInfo pluginDirectory, FileInfo plugin)
if (plugin.Exists)
using (FileStream stream = plugin.OpenRead())
Search Nedrilad ::

Custom Search