Hi all,
today I will give you an example of a single WCF application exposing data with the following endpoints at the same time:

  • SOAP 1.1 (basicHttpBinding)
  • SAOP 1.2 (wshttpBinding)

So, the WCF service I propost it is hosted by Visual Studio itself as well as a Windows Service. You can download the solution here.
Once you run the solution (remember to run Visual Studio as admin!), you can test SOAP endpoints by Visual Studio WCF Test Client (that will automatically start) and REST endpoints copying paste into your web browser the following URLs:

So, let’s take a look at the Solution structure:


The solution is composed by:

  • Contracts: it defines the WCF Service contract, I mean the data (dto object) exposed outside the service, the Fault classes describing errors, and the service interface
  • Dal: it could be Entity Framework or something else that is able to retrieve data from a DataBase. In this example this Dll is empty, I didn’t realized a complex example. However it is clear that the DAL will be not exposed outside the service as is, but it will mapped into Data Contracts object.
  • Service Host: in this sample you can install the WCF Service as a Windows Service. The Install.bat and Uninstall.bat will do the job for you!
  • Services: the service implementation itself. You could set it as a Startup Project in fact if we take a look at the project we can see that Visual Studio will host the service and it will starts the WCFTest client as well on startup:


Here you are the most interesting part: the App.config which is the same for the Service (when hosted by Visual Studio) and the Host program:

      <service name="Marzio.Pattano.Services.SampleService" behaviorConfiguration="SampleServiceBehavior">
            <add baseAddress="http://localhost:8081/MyService" />
        <endpoint address="soapBasic" binding="basicHttpBinding" bindingConfiguration="basicHttpBinding" contract="Marzio.Pattano.Contracts.Service.ISampleService" />
        <endpoint address="soapWs" binding="wsHttpBinding" bindingConfiguration="wsHttpBinding" contract="Marzio.Pattano.Contracts.Service.ISampleService" />
        <endpoint address="json" binding="webHttpBinding" bindingConfiguration="webHttpBindingJson" behaviorConfiguration="jsonBehavior" contract="Marzio.Pattano.Contracts.Service.ISampleService" />
        <endpoint address="xml" binding="webHttpBinding" bindingConfiguration="webHttpBindingXml" behaviorConfiguration="poxBehavior" contract="Marzio.Pattano.Contracts.Service.ISampleService" />
        <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
        <behavior name="jsonBehavior">
          <enableWebScript />
        <behavior name="poxBehavior">
          <webHttp />
        <behavior name="SampleServiceBehavior">
          <serviceMetadata httpGetEnabled="true" />
          <serviceDebug includeExceptionDetailInFaults="True" />
          <serviceCredentials useIdentityConfiguration="false" />
        <binding name="basicHttpBinding">
          <security mode="None" />
        <binding name="webHttpBindingJson">
          <security mode="None" />
        <binding name="webHttpBindingXml">
          <security mode="None" />
        <binding name="wsHttpBinding">
          <security mode="None" />
    <serviceHostingEnvironment multipleSiteBindingsEnabled="true" />

so we basicallye have:

  • the four endpoints (soapBasic, soapWs ,json, xml) plus the endpoint MEX for SOAP.
  • the endpointBehaviors: basically json must have enableWebScript and poxBehavior webHttp
  • the bindings:
    notice that webHttpBinding has been defined twice for Json and Xml, this will solve a WCF issue! So keep both of them!

At least notice the service contract:

    public interface ISampleService
        Employee GetEmployee(int employeeId);

where [WebGet] tells WCF that this is a REST method.

Happy coding!!!

Hi all guys,
it’s time to learn something new about Team Foundation Server.

Sometimes happens that you (or in enterprise organization a tester, who really is an essential role when you want to work efficiently focusing on customer) discover a bug into sources that you had deployed to some customer or to tester for making tests. So, in this scenario until yesterday, I believed that you are forced to make a branch from the label that you delivered than apply your patch into the code and merging it into main (or development) branch. That’s quite complex and you can do something better!

In fact you can get the sources at Labeled version, then directly apply your fix and checking it! What happens? Really simply and efficiently: your patch will be contained in the Label and the patch is merged into the latest version too! Really impressive!

If you need some practical information you can take a look at this article I found: http://www.olegsych.com/2009/04/simplifying-tfs-applying-hot-fixes-without-branching/

Hi all guys,
today I discovered that when you delete a branch from the Team Explorer in Visual Studio, the branch is not really deleted, but you can ‘restore’ the deleted branch if needed.
Bye the way if you really want to delete a branch (maybe after some months after the ‘weak’ deletion) you can do it using Visual Studio Command Prompt Console.
First of all you can see all the deleted branches in your Team Explorer enabling the following flag in your Tools > Options > Source Control > Visual Studio Team Foundation Server:


If you really want to delete a branch you can execute the following command (from Visual Studio Command Prompt):

tf destroy $/MyProject/Main/Bin /collection:http://servername:8080/tfs/myproject
Do you want to destroy $/MyProject/Main/Bin and all of its children? (Yes/No) y
Destroyed: $/MyProject/Main/Bin;X3601
Destroyed: $/MyProject/Main/Bin/Native;X360

You can find additional documentation from Micsofot here and remark that you can use the /preview option for seeing which files will be permanently deleted. I suggest you to use output redirection in order to really check all files in the following way:

tf destroy $/MyProject/Main/Bin /collection:http://servername:8080/tfs/myproject /preview > c:\prova.txt

Additionally you can force tfs to clean all files of this branch from the DB after executing the command specifying the following option /startcleanup. By default, the clean-up is scheduled to run once each day.

The WordPress.com stats helper monkeys prepared a 2013 annual report for this blog.

Here’s an excerpt:

The concert hall at the Sydney Opera House holds 2,700 people. This blog was viewed about 22,000 times in 2013. If it were a concert at Sydney Opera House, it would take about 8 sold-out performances for that many people to see it.

Click here to see the complete report.

Hi all,
after some months of studies about MEF, Unity and EntityFramework I decided to share some “pre-cooked solution” about what I learned.

The first sample provide the basic knowledge about modularity architecture. You can download the sample application (VS2012) here.


As displayed in the picture you have three main actors:

  • Program: the Program knows just the Core library and it is totally unaware about Plugins components. This means that your Program does not have references on Plugins.
  • Core Application: the Core Application defines the Plugin Interface (IPaymentPlugin) and provides the PaymentService, a way for retrieving Plugins implementations. We will discover in an other post about why I choose to define the IPaymentService interface (when I will discuss about Unity).
  • Plugins: each plugin implements the Plugin Interface (IPaymentPlugin).

    The core of the application is implemented by GetPaymentPlugins a method of PaymentService of course. Here the code that is able to dynamically retrieving Plugins:

            public IList<IPaymentPlugin> GetPaymentPlugins()
                List<IPaymentPlugin> plugins = new List<IPaymentPlugin>();
                List<Assembly> allAssemblies = new List<Assembly>();
                string path = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
                foreach (string dll in Directory.GetFiles(path, "*.dll"))
                    Assembly assembly = Assembly.LoadFile(dll);
                    foreach (Type ti in assembly.GetTypes().Where(x => x.GetInterfaces().Contains(typeof(IPaymentPlugin))))
                return plugins;

  • If you are creating Windows Services you may run into this error:

    Error 1001. The specified service has been marked for deletion

    At first I used to restart my machine to get rid of it, but there is a (much) simpler way: close the Services Manager and you will never encounter this error!


    when you are developing your applications using VS 2010 and unfortunately your TFS server became unreachable, your Visual Studio 2010 stuck!
    Since you are unable to tell to VS that your TFS is unreachable you should waiting for VS until it detects that is unable to connect to TFS… This is really annoying and this makes you wasting your precious time…

    Bernhard Tschirren has developed a VS addon for adding the Go Off Line button into VS Source Control Menu! Using this button befor opening your your .sln you can avoid the VS stuck even if your TFS is offline🙂

    Here you are the GoOffline VS Ads link (for installing just double click it after downloading): Click Here

    Happy coding and stay tuned!