Summary of the WCF Project

Source: Internet
Author: User

Project knowledge point Accumulation
This document takes snapshots of some knowledge points learned by the project for future reference.

WCF and dbnull

When using WCF to transmit data, sometimes some Special Vertex types need to be transmitted, such as dbnull, so that the service will throw an error because the service cannot identify the type and Cannot serialize it normally.

Solution:

(1) For custom datacontract, add the knowntype attribute to the Contract definition body, as shown below:

[Datacontract]
[Knowntype (typeof (system. dbnull)]

(2) if it is a service method (for example, an error occurs when the encapsulated executescalar transmits dbnull), add serviceknowntype attribute to the interface definition of the method, as shown below:

[Serviceknowntype (typeof (system. dbnull)]
Object executescalar (...);

Above, over!

View port usage

Wsdualhttpbinding is used in WCF, and port 80 is used for callback. However, it is annoying that port 80 is always occupied by other applications on the machine. You can view it in the following ways:

Netstat-ano | find ": 80"

Result: TCP 0.0.0.0: 80 0.0.0.0: 0 listening 3328

Where 3328 is the process ID, you can go to the task manager to check, you can also use the following command:

Tasklist | find "3328"

Result: mxdownloadserver.exe 3328 console 0 3,228 K

In this way, you will know which application is in use. The above, over!

Monitor port communication status

When I encountered a problem in using WCF, I needed to monitor the Communication Status of port 80 on the machine. However, after searching for a long time, I did not find the available Sniffer Pro cracked version (Khan ...).

Therefore, we changed the tool to use windumpat at http://www.winpcap.org/default.htm.

Run the following command:

Windump-I 2 port 80> C: \ logfile.txt

You can record all the port 80 communications to the specified file. The above, over!

TF status/S: tfs001/User: *> C: \ 007.txt

Tf.exe is in the c: \ Program Files \ Microsoft Visual Studio 9.0 \ common7 \ ide directory.

Check the TFS File status (checkout)

TF status/S: tfs001/User: *> C: \ 007.txt

Tf.exe is in the c: \ Program Files \ Microsoft Visual Studio 9.0 \ common7 \ ide directory.

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.