WCF cannot add service due - cannot obtain meta data

I have the following,

(In VS2012)

PostCodes is my solution it is an ASP.NET Web forms application I have two services,

Service1 and Service2

Everything was working fine until I started to add some real stuff to IService2. This meaning started to make constructors and I now receieve and error from the WCF test client that states (When i hit run inside my Service2.svc.cs tab)

"Failed to add a service. Service metadata may not be accessible. Make sure your service is running and exposing metadata."

here is my Web.Config

<compilation debug="true" targetFramework="4.0" />
    <behavior name="">
      <serviceMetadata httpGetEnabled="true" />
      <serviceDebug includeExceptionDetailInFaults="false" />
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />

Now I have tried time and time again to allow my WCF test client to obtain the meta data by adding endpoints to the web.config file as follows

  <service name="Service2" // 
    <endpoint address=http://localhost/Service2
              contract="IService2" />
    <endpoint address="http://localhost/Service2/mex"
              contract="IMetadataExchange" />

To clairfy My solution is called PostCodes, I have two services, Service1 and Service2

The above did not work, and I still get the error when running the WCF Test Client...

I am not running this online or anything this is purely to run through the Test Client and on my local machine.

So my question is - What have I done wrong in adding these end points and how can I fix it.

Any advice would be great,

Post below for any clarifications if needed



i got the reason, you cant define a constructor in interface, as you cannot instantiate them. here is a relevant SO for your better understanding

Interface defining a constructor signature?


There is always a class implementing the interface , which you could find in the same WCF service project.you will find the code behind file name within .svc file inside your WCF project.whatever you wanted add within the interfaced constructor, add the same inside the constructor defined in the class.

Happy Coding:)


 ? WCF service with Windows authentication throws exception "Username not defined" even if it is defined
 ? Windows network authentication the right way
 ? Windows network authentication the right way
 ? Windows network authentication the right way
 ? Windows network authentication the right way
 ? Windows Authentication and Network Service account as a db_owner
 ? Network Authentication when running exe from WMI
 ? windows authentication with a custom login page
 ? browser popup in windows authentication
 ? A better way to get a Windows Username using Forms Authentication?