本文整理汇总了C#中System.AppDomainSetup.AppDomainInitializerArguments属性的典型用法代码示例。如果您正苦于以下问题:C# AppDomainSetup.AppDomainInitializerArguments属性的具体用法?C# AppDomainSetup.AppDomainInitializerArguments怎么用?C# AppDomainSetup.AppDomainInitializerArguments使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类System.AppDomainSetup
的用法示例。
在下文中一共展示了AppDomainSetup.AppDomainInitializerArguments属性的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Main
//引入命名空间
using System;
using System.Security.Policy;
public class Example
{
public static void Main()
{
// Get a reference to the default application domain.
//
AppDomain current = AppDomain.CurrentDomain;
// Create the AppDomainSetup that will be used to set up the child
// AppDomain.
AppDomainSetup ads = new AppDomainSetup();
// Use the evidence from the default application domain to
// create evidence for the child application domain.
//
Evidence ev = new Evidence(current.Evidence);
// Create an AppDomainInitializer delegate that represents the
// callback method, AppDomainInit. Assign this delegate to the
// AppDomainInitializer property of the AppDomainSetup object.
//
AppDomainInitializer adi = new AppDomainInitializer(AppDomainInit);
ads.AppDomainInitializer = adi;
// Create an array of strings to pass as arguments to the callback
// method. Assign the array to the AppDomainInitializerArguments
// property.
string[] initArgs = {"String1", "String2"};
ads.AppDomainInitializerArguments = initArgs;
// Create a child application domain named "ChildDomain", using
// the evidence and the AppDomainSetup object.
//
AppDomain ad = AppDomain.CreateDomain("ChildDomain", ev, ads);
Console.WriteLine("Press the Enter key to exit the example program.");
Console.ReadLine();
}
// The callback method invoked when the child application domain is
// initialized. The method simply displays the arguments that were
// passed to it.
//
public static void AppDomainInit(string[] args)
{
Console.WriteLine("AppDomain \"{0}\" is initialized with these arguments:",
AppDomain.CurrentDomain.FriendlyName);
foreach (string arg in args)
{
Console.WriteLine(" {0}", arg);
}
}
}
输出:
AppDomain "ChildDomain" is initialized with these arguments: String1 String2