本文整理匯總了C#中System.AppDomain.GetHashCode方法的典型用法代碼示例。如果您正苦於以下問題:C# AppDomain.GetHashCode方法的具體用法?C# AppDomain.GetHashCode怎麽用?C# AppDomain.GetHashCode使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類System.AppDomain
的用法示例。
在下文中一共展示了AppDomain.GetHashCode方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: Load
public String Load(String assembly)
{
String domainBase = "unknown";
try
{
if (_currentDomain != null)
{
AppDomain.Unload(_currentDomain);
}
_currentDomain = null;
// The assembly is expected to be in the ModelMod installation directory.
// (Unlike this app domain assembly, which must be copied into the game dir).
// Setting appbase to this modelmod install dir allows the references
// (fsharp, monogame, etc) to be loaded
// without requiring them to be copied to the game dir.
var ads = new AppDomainSetup();
ads.ApplicationBase = Path.GetDirectoryName(assembly);
ads.DisallowBindingRedirects = false;
ads.DisallowCodeDownload = true;
// use the configuration file property to specify the name of the assembly that must be loaded.
// can't use a static field; the sandbox domain has a separate copy of all the statics.
ads.ConfigurationFile = assembly;
// this loader callback is needed so that we can hot-swap the assembly.
// http://stackoverflow.com/questions/425077/how-to-delete-the-pluginassembly-after-appdomain-unloaddomain
var d = base.CreateDomain("ImSoFriendly", null, ads);
_currentDomain = d;
domainBase = d.BaseDirectory;
d.DoCallBack(new CrossAppDomainDelegate(LoaderCB));
return ""; // empty string means no error, otherwise, its an error message
}
catch (Exception e)
{
return "Error during load. " + Environment.NewLine
+ "Root app domain: " + AppDomain.CurrentDomain.GetHashCode() + Environment.NewLine
+ "Sandbox domain: " + _currentDomain.GetHashCode() + Environment.NewLine
+ "Sandbox domain base: " + domainBase + Environment.NewLine
+ "Exception: " + e.ToString();
}
}