. NET application loading container KGlue

Source: Internet
Author: User

When updating an application, do you encounter the following cumbersome tasks: [site stop service-Update Service-Start Service]; because the file is occupied by the program, you must stop the program when updating the file, and start the program manually after the update is complete. KGlue is used to solve the preceding problems. Its main function is to use appDomain to load and run applications with each configuration; monitors application file changes and automatically detaches and restarts applications. simply put, after the file is directly replaced during application update, KGlue reloads the program.

Use Configuration
KGlue can be used to configure multiple applications. Applications can be stored in any directory accessible by KGlue. You only need to add the relevant application directory in the configuration file.

<? Xml version = "1.0" encoding = "UTF-8"?>
<Configuration>
<ConfigSections>
<Section name = "appSection" type = "KGlue. AppSection, KGlue"/>
</ConfigSections>
<AppSection xmlns = "urn: KGlue">
<Items>
<Add name = "test" path = "test" args = "henry fan"/>
<Add name = "tcpserver" path = "tcp"/>
<Add name = "config" path = "config"/>
<Add name = "chatroom" path = "websocket_chatroom"/>
</Items>
</AppSection>
</Configuration>
The preceding configuration file describes the four applications. The path is the directory corresponding to the application. If the full path is not specified, it is the subdirectory under the KGlue running directory. The args parameter is required to start the application, it can be null. KGlue enables New AppDomains to run each configuration.

Application loading rules
KGlue supports loading DLL or code (cs, vb). Therefore, you only need to provide DLL or code files during release. because the application needs a rule definition to start, the corresponding class implementation KGlue. IAppAdapter can be used. KGlue traverses all DLL or code files in the configuration directory. After the domain is created, all IAppAdapter classes are instantiated and called.

 
Public class Class1: KGlue. IAppAdapter
{
Public void Start (string [] args)
{
Console. WriteLine (args. Length );
Foreach (string item in args)
{
Console. WriteLine (item );
}
 
}
 
Public string Name
{
Get {return "Class1 ";}
}
 
Public void Stop ()
{

}
}
The above is a simple application that outputs startup parameters. save the file to the corresponding directory (do not forget to put KGlue. dll Directory) and configure the KGlue configuration file.

 
<? Xml version = "1.0" encoding = "UTF-8"?>
<Configuration>
<ConfigSections>
<Section name = "appSection" type = "KGlue. AppSection, KGlue"/>
</ConfigSections>
<AppSection xmlns = "urn: KGlue">
<Items>
<Add name = "test" path = "d: \ test" args = "henry fan"/>
</Items>
</AppSection>
</Configuration>

Related Article

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.