IDesign C # Coding specification (ix)

Source: Internet
Author: User
Tags config empty soap hosting firewall
Code | Specification 4.5 remote Operation Remoting
1. Prefer to use a management configuration (configuration file) instead of using program autoconfiguration.
Prefer administrator configuration to programmatic configation.
2. Always complete the IDisposable in a separate call object.
Always implement IDisposable on the single call objects.
3. Always use TCP channel and binary format for remote operation
Always prefer TCP channel and binary format when using remoting.
A) Unless a firewall is set up
Unless a firewall is present.
4. Always provide a null lease for a bundle of objects.
Always provide a null lease for a singleton object.
public class Mysingleton:marshalbyrefobject
{
public override Object InitializeLifetimeService ()
{
return null;
}
}
5. Always provide sponsor for client-activated objects. This sponsor should return to the initial lease time.
Always provide a sponsor for client activated object. The sponsor should return to the initial lease time.
A) Chapter programming. NET components.
6. Always do not register sponsor when the client application is stopped.
Always Unregister the sponsor on client application shutdown.
7. Always place the remote object in the class library.
Always put the remote objects in class libraries.
8. Avoid using Soapsuds.
Avoid using SoapSuds.
9. Avoid hosting IIS.
Avoid hosting in IIS.
10. Avoid using a single directional channel.
Avoid using uni-directional channels.
11. Always load the remote configuration file in the main () method, even if the file is empty. And the application does not use remote operations.
Always load a remoting configuration file in Main () even if the file is empty, and the application does does not use remoting.
A allows you to redefine the remote invocation, configure the channel, and change the application publishing (add channel, etc.) in the file.
Allow the option of remoting some types later on, post deployment, and changing the application topology.
Static void Main ()
{
Remotingconfiguration.configue ("MyApp.exe.config");
/*rest of Main () * *
}
12. Avoid the use of Activator.GetObject () and Activator.CreateInstance () when activating remote objects. Instead, you use new.
Avoid using Activator.GetObject () and Activator.CreateInstance () for remote objects activation. Use new instead.
13. Always register port () on the client to allow recursive invocation.
Always Register port () on the client side and to allow callbacks.
14. Always set the client and server-side type filtering to full so that it can be invoked recursively.
Always elevate type filtering to full on both client and host to allow callbacks.
Host Config File:
<channels>
<channel ref = "TCP" port = "8005" >
<serverProviders>
<formatter ref = "Soap" TypeFilterLevel = "full"/>
<formatter ref = "binary" TypeFilterLevel = "full"/>
</serverProviders>
</channel>
<channel ref = "http" port = "8006" >
<serverProviders>
<formatter ref = "Soap" TypeFilterLevel = "full"/>
<formatter ref = "binary" TypeFilterLevel = "full/" >
</serverProviders>
</channel>
</channels>
Client Config File:
<channels>
<channel ref = "TCP" port = "0" >
<serverProviders>
<formatter ref = "Soap" TypeFilterLevel = "full"/>
<formatter ref = "binary" TypeFilterLevel = "full"/>
</serverProviders>
</channel>
</channels>



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.