当前位置: 首页>>代码示例>>C#>>正文


C# AppDomainSetup.AppDomainInitializerArguments属性代码示例

本文整理汇总了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);
        }
    }
}
开发者ID:.NET开发者,项目名称:System,代码行数:57,代码来源:AppDomainSetup.AppDomainInitializerArguments

输出:

AppDomain "ChildDomain" is initialized with these arguments:
    String1
    String2


注:本文中的System.AppDomainSetup.AppDomainInitializerArguments属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。