C # windows service supports image Mirroring

Source: Internet
Author: User

Exam exam article: https://www.microsoft.com/china/msdn/library/architecture/architecture/architecturetopic/BuildSucApp/BSAAsecmodsecmod29.mspx? Mfr = true
 
1. First, define the method that the program object needs to operate on. This interface is set to a simple class for reference by windowsservice and programming client.
Public interface IRemoteObjectMethod
{
Void dosomething ();
}

2. Then, create a windows service Project and add the classes of the actual program object interface.
Public class RemoteObject: MarshalByRefObject, IRemoteObjectMethod
{
Public RemoteObject ()
{}
// Examples of Adding Methods
}

3. Add strongswan program object configuration to app. config.
As follows:
<System. runtime. remoting>
<Application name = "ServerToClientService">
<Service>
<Wellknow type = "downloaderservice. externaldownsyncobject, downloaderservice" objecturi = "downsyncobject" mode = "singlecall"/>
</Service>
<Channels>
<Channel ref = "TCP" Port = "6767">
<Serverproviders>
<Formatter ref = "binary"/>
</Serverproviders>
</Channel>
</Channels>
</Application>
</System. runtime. remoting>

4. In the start method of Windows Service, add the replacement of the photo upload program.
Protected override void onstart (string [] ARGs)
{
RemotingConfiguration. Configure (AppDomain. CurrentDomain. SetupInformation. ConfigurationFile );
}

5. Install windows server. You don't have to renew it.

At this point, the windows service has been completed, and all subsequent operations are performed on the shuttle bus.

6. Add the category and configuration file for retrieving the processed object.
Public class RemoteObjectFactory
{
// Specify the service name of the target image
Private static string svc_Name = ConfigurationSettings. deleettings ["ServiceName"];
// The IP address of the Local Service
Private static string svc_ipAddress = ConfigurationSettings. deleettings ["ServiceIP"];
// Specifies the port used when the program processes the image.
Private Static int svc_port = int. parse (configurationsettings. deleettings ["serviceport"]);
// Identification of the entire process on the Image
Private Static string svc_objecturi = configurationsettings. deleettings ["objecturi"];
// Type of the router interface
Private Static string channeltype = configurationsettings. deleetask[ "channeltype"];


Public static iremoteobjectmethod getserversyncobject ()
{
String url = channeltype + ": //" + svc_ipaddress + ":" + svc_port.tostring () + "/" + svc_name + "/" + svc_objecturi;
IRemoteObjectMethod obj = (IRemoteObjectMethod) Activator. GetObject (typeof (IRemoteObjectMethod), url );
If (obj = null)
{
Throw new Exception ("Service not exists or Remoteobject not exists! ");
}
Return obj;
}
}
The method used to create the upload process for image mirroring, and add the corresponding configuration scheme in app. config.

7. Use the guest terminal to renew the client.
IRemoteObjectMethod remoteObject = RemoteObjectFactory. GetServerSyncObject ();
RemoteObject. dosomething ();

In this way, it seems that it can be used better than the actual progress method of linear regression :)

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.