CLR hosted (bottom) hosted host

Source: Internet
Author: User
Tags definition class definition hosting

The way in which you manage the CLR through managed code, called a managed host. It's easy to implement a hosting host as long as you implement the System.appdomainmanager class. The definition of the AppDomainManager class is shown in code listing 1-1.

Code Listing 1-1 AppDomainManager class definition

[ComVisibleAttribute (True)]

[SecurityPermissionAttribute (SecurityAction.LinkDemand, Flags = securitypermissionflag.infrastructure)]

[SecurityPermissionAttribute (SecurityAction.InheritanceDemand, Flags = securitypermissionflag.infrastructure)]

Public Classappdomainmanager:marshalbyrefobject

To implement your own hosting host, you need to implement a subclass of the AppDomainManager class, overriding the virtual methods. Code Listing 1-2 customizes the Xhappdomainmanager class to implement a simple hosting host.

Code Listing 1-2 Customizing the Xhappdomainmanager class

Namespace managed Host

{

[GuidAttribute ("f4d15099-3407-4a7e-a607-dea440cf3891")]

[SecurityPermissionAttribute (SecurityAction.LinkDemand,

Flags = securitypermissionflag.infrastructure)]

[SecurityPermissionAttribute (SecurityAction.InheritanceDemand, Flags = securitypermissionflag.infrastructure)]

Class Xhappdomainmanager:appdomainmanager

{

Private Hostsecuritymanagerxhhostsecuritymanager = null;

public override void Initializenewdomain (Appdomainsetupappdomaininfo)

{

Console.WriteLine ("XH AppDomain Manager");

Xhhostsecuritymanager = AppDomain.CurrentDomain.CreateInstanceAndUnwrap (

"Xhsecuritymanager, version=1.0.0.3, culture=neutral," +

"publickeytoken=5659fc598c2a503e",

The managed host. Xhhostsecuritymanager ") as Hostsecuritymanager;

Console.WriteLine ("Custom Security Manager Created.");

}

public override Hostsecuritymanager Hostsecuritymanager

{

Get

{

return xhhostsecuritymanager;

}

}

public override assemblyentryassembly

{

Get

{

Return base. entryassembly;

}

}

}

}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.