本文整理汇总了C#中AppDomain.CreateInstanceAndUnwrap方法的典型用法代码示例。如果您正苦于以下问题:C# AppDomain.CreateInstanceAndUnwrap方法的具体用法?C# AppDomain.CreateInstanceAndUnwrap怎么用?C# AppDomain.CreateInstanceAndUnwrap使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AppDomain
的用法示例。
在下文中一共展示了AppDomain.CreateInstanceAndUnwrap方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetRemote
public static Foo GetRemote (AppDomain domain)
{
Foo test = (Foo) domain.CreateInstanceAndUnwrap (
typeof (Foo).Assembly.FullName,
typeof (Foo).FullName, new object [0]);
return test;
}
示例2: CreateCrossDomainTester
static CrossDomainTester CreateCrossDomainTester (AppDomain domain)
{
Type testerType = typeof (CrossDomainTester);
return (CrossDomainTester) domain.CreateInstanceAndUnwrap (
testerType.Assembly.FullName, testerType.FullName, false,
BindingFlags.Public | BindingFlags.Instance, null, new object [0],
CultureInfo.InvariantCulture, new object [0], domain.Evidence);
}
示例3: LoadAssemblies
public void LoadAssemblies()
{
if (ad != null)
{
System.Console.Error.WriteLine("Unloading domain");
AppDomain.Unload(ad);
}
ad = AppDomain.CreateDomain("MyAppDomain");
object o = ad.CreateInstanceAndUnwrap(Assembly.GetExecutingAssembly().FullName, "CompleteSharp+MyAppDomain+Hack");
Hack h = o as Hack;
h.ad = this;
int idx = 0;
foreach (string a in assemblies)
{
try
{
FileInfo fi = new FileInfo(a);
times[idx] = fi.LastWriteTime;
idx++;
System.Console.Error.WriteLine("Loading: " + a);
h.Load(a);
}
catch (Exception e)
{
reportError(e);
}
}
}
示例4: GetRemote
static Program GetRemote (AppDomain domain)
{
Program test = (Program) domain.CreateInstanceAndUnwrap (
typeof (Program).Assembly.FullName,
typeof (Program).FullName, new object [0]);
return test;
}
示例5: CreateAppDomain
/// <summary>
/// Creates the app-domain and the instance of the ResourceRetriever and
/// sets the private fields with the references.
/// </summary>
///
private void CreateAppDomain()
{
if (_domain == null)
{
// Create an app-domain to load the resource assemblies in so that they can be
// unloaded.
_domain = AppDomain.CreateDomain("ResourceIndirectDomain");
_resourceRetriever =
(ResourceRetriever)_domain.CreateInstanceAndUnwrap(
Assembly.GetExecutingAssembly().FullName,
"System.Management.Automation.ResourceRetriever");
}
}