Wednesday, March 9, 2011

changing VC++ include setting for all projects in 1 solution

Here are the steps to change the settings file through UI:

  • Open up property manager by clicking on View.Property Manager.

  • Expand the project node and then the Configuration|Platform nodes, you will see "Microsoft.cpp..users" file for each Configuration|Platform. These are the files for the global settings, similar to the old tools/Options/VC++ Directories.

  • Multi-Select "Microsoft.cpp..users", right click and bring up the property page window

  • In the property page window, click on "VC++ Directories" (for example) in the left pane, add new paths for the directories such as "Include Directories". separated by semicolons

  • Make sure to save the settings before shutting down Visual Studio.

  • Re-launch Visual Studio and the new settings will be in effect.

If you would like to only change the settings for a specific project, you can right click on the project and bring up the property page. Change the settings for “VC++ Directories”, these settings will be persisted to the project file.

Sunday, February 20, 2011

WCF Contract - Overloading Methods



If you need to overload a funtion in WCF contract , you've probably encountered in :


Cannot have two operations in the same contract with the same name, methods ***** and ****** in type ******* violate this rule. You can change the name of one of the operations by changing the method name or by using the Name property of OperationContractAttribute


Here's how to fix this issue (second option)

http://www.switchonthecode.com/snippet-tutorials/wcf-snippet-tutorial-overloading-methods

Sunday, February 13, 2011

2 Endpoints for netTcpBinding with different contracts

Need to use same netTcpBinding binding but need additional endpoint for different contract? here's how:

1. It's very good to read this article
2. If you have current netTcpBinding it should look like this:



3. what you have here is a TCP type of WCF with base address. Thats a deafult implementation of netTcpBinding.
4. I suggest you to use the VS20010 tool "Edit WCF Configuration" to edit the App.config file instead of manually edition it.
5. Add additional end point same values as the 1'st netTcpBinding binding (leave the MexTcpBidingEndpoint alone)
6. Change the folowing :

  • give each endpoint a name (the default implementation keeps them empty , it's good to give them some name to know on which one you are working on
  • for each give a unique name in the address section , thats the magic here , giving the base address (see host baseaddress section) allownig wach binding to "sit" in a unique position within the service , leaving this section empty will cause assertion such as "When multiple endpoints on a service share the same ListenUri, those endpoints must all have the same Identity in their EndpointAddress."
  • For each binding state the contract.
7. the app.config script should look like this:


8. Thats it , Cool , no?

Sunday, January 30, 2011

XSD to byte array and vice versa


need to construct your own byte array from a defiined XSD ? heres how

 
first construct the class from XSD (or XML)

we use XSD tool
  • go to Visual studio command prompt
  • Go to path of xsd file(I.E c:\xsd)
  • xsd [file name].xsd /c /n:[namespace]
  • where
    • /c – generate classes
    • /n - namespace

Now you have created the class representation of the XML (or XSD) file.
you can now use this 2 functions to serialize and deserialize the objects , to byte array and from byte array
public static byte[] ObjectToXmlBytes(object o)

{

MemoryStream memoryStream = new MemoryStream();

XmlSerializer serializer = new XmlSerializer(o.GetType());

serializer.Serialize(memoryStream, o);

return memoryStream.ToArray();



}



public static object XmlBytesToObject(byte[] bytes, Type t)

{

MemoryStream memoryStream = new MemoryStream(bytes);

memoryStream.Position = 0;

XmlSerializer serializer = new XmlSerializer(t);

return serializer.Deserialize(memoryStream);

}
enjoy

 
Home | About | Link | Link
Simple Proff Blogger Template Created By Herro | Inspiring By Busy Bee Woo Themes