1

I'm using VS2012.

I made a simple service that I ran yesterday and it worked fine.

But now I'm doing it all again, just to review it, and for my surprise it doesn't work.

Don't know why the machine is actively refusing it 127...:6414.

The service is being run locally, in the same machine, and VS 2012 is being run as Administrator.

This is the complete the error:

"There was an error downloading 'http://localhost:6414/HostDevServer/HelloWorldService.svc'. Unable to connect to the remote server. No connection could be made because the target machine actively refused it 127...:6414"

I tried to make an inbound rule in the firewall, didn't work.

Tried deactivating Microsoft Security Essentials, didn't work.

Tried doing it all in other machine, the same error.

Tried changing the port number, didn't work.

I googled it and what I found wasn't for me.

The service is very simple, the ServiceModel definition in the Web.Config is this:

<system.serviceModel>
    <serviceHostingEnvironment >
        <serviceActivations>
            <add factory="System.ServiceModel.Activation.ServiceHostFactory"
                 relativeAddress="./HostDevServer/HelloWorldService.svc"
                 service="MyWCFServices.HelloWorldService"/>
        </serviceActivations>
    </serviceHostingEnvironment>
    <behaviors>
        <serviceBehaviors>
            <behavior>
                <serviceMetadata httpGetEnabled="true"/>
            </behavior>
        </serviceBehaviors>
    </behaviors>
</system.serviceModel>

The service is made with a console application, is being hosted in a new web site that uses IIS Express, all in the same solution.

The property pages for the HostDevServer is:

enter image description here

enter image description here

Whe I run it the WCF Test Client throws the error:

enter image description here

What could it be?

Rafael
  • 2,413
  • 4
  • 32
  • 54
  • possible help here http://stackoverflow.com/questions/2972600/no-connection-could-be-made-because-the-target-machine-actively-refused-it Have you tried to do a netstat -an | find 6414 to see if the process is actually listening? Do you have Anti-Virus blocking incoming connections? – Mike Feb 26 '14 at 15:54
  • "The service is made with a console application, is being hosted in IIS Express" - You're hosting a console application in IIS? That doesn't make sense... – Tim Feb 26 '14 at 16:03
  • Tim, I'm following a book, I think it is called Hosting, but I really don't know much. I created a console application that defines a service, then added a new web site that's defining the service for it's use in the Web.config. May be it isn't called Hosting, so, sorry I used that word – Rafael Feb 26 '14 at 16:11
  • MIke, I tried deactivating the anti virus, but it didn't work also. I'm a newbie, and the service is not in production, is only a test, I'm studying wcf. it worked yesterday, and something is preventing it from working. I run it with IIS Express, ran withing Visual Studio, that's why netstat doesn't show it, I think. So, the service is well written but something is different today – Rafael Feb 26 '14 at 16:15
  • I uploaded the simple project. Is a Visual Studio 2012 one. https://onedrive.live.com/?gologin=1&mkt=es-ES#cid=228822BB183339A9&id=228822BB183339A9!234 – Rafael Feb 26 '14 at 16:29
  • I have VS2010, so I wasn't able to run it directly. I did cut/paste the code into a vs2010 WCF Service Library project and it ran fine. I did see the namespaces changed from the default, but that shouldn't be an issue. I'm not sure how 2012/.net 4.5 works, but I didn't see any endpoints in the configuration file. – Mike Feb 26 '14 at 20:18
  • I also did it in VS2010 and it worked fine, now I know how to do it in VS2012 – Rafael Feb 27 '14 at 17:13

2 Answers2

1

I'd downloaded your project and run it in my machine with no problems. If your problem happens always, it means that your machine has no services listening on the specified port, or there is a firewall stopping you. Try turning of the firewall.

Did you try to debug your web service project only? If so, tell me if you can access to the following URL: http://localhost:PORT_NUMBER/HostDevServer/HelloWorldService.svc, where PORT_NUMBER is the port that you configure for the server in your solution. Try not to use port 80, It's generally used on other applications. Maybe your service isn't starting because of a problem at compile time, so you can try deleting all .pdb files from your bin directory.

Please, try to modify your web.config. Replace your system.serviceModel tag with the following:

<system.serviceModel>
    <serviceHostingEnvironment >
        <serviceActivations>
            <add factory="System.ServiceModel.Activation.ServiceHostFactory"
                 relativeAddress="./HostDevServer/HelloWorldService.svc"
                 service="MyWCFServices.HelloWorldService"/>
        </serviceActivations>
    </serviceHostingEnvironment>
    <behaviors>
        <serviceBehaviors>
            <behavior name="metadataBehavior">
                <serviceMetadata httpGetEnabled="true"/>
            </behavior>
        </serviceBehaviors>
    </behaviors>
    <services>
      <service name="MyWCFServices.HelloWorldService" behaviorConfiguration="metadataBehavior">
        <endpoint
            address="" binding="basicHttpBinding" contract="MyWCFServices.IHelloWorldService"/>
        <endpoint
            address="mex"
            binding="mexHttpBinding"
            contract="IMetadataExchange"/>
      </service>
    </services>
</system.serviceModel>
Juan Fausd
  • 43
  • 7
  • Hi Juan, I tried it but I got the same result. And that´s exactly what I can´t do, to run the service – Rafael Feb 26 '14 at 19:24
  • I turned the firewall off with no success. But it ran well yesterday. Strange thing is that I developed it all again in other machine, and the same error ocurred. And it also ran well yesterday. I´m studying with my laptop, but not with the second computer. So weird! What do you mean with "no services listening on the specified port", I changed the port number with no sucess either – Rafael Feb 26 '14 at 21:40
  • I deleted the dll and pdb files from the bin directory and started it but when the WCF Test Client gets to the middle of it's progress bar, it stops and throws the error – Rafael Feb 26 '14 at 22:14
  • Hi Juan, what version of Visual Studio are you using, 2010 or 2012? – Rafael Feb 27 '14 at 14:34
  • Hi Rafael. I'm using VS 2012. – Juan Fausd Feb 27 '14 at 14:49
  • Are you using IIS Express and WCF Test Client? – Rafael Feb 27 '14 at 15:07
  • Yes, I'm using those technologies. – Juan Fausd Feb 27 '14 at 15:11
  • I know what the problem is, I was putting an arbitrary number as the port to be used in Property Pages(Shift-F4)->Start URL. But, when creating a new web site with IIS Express, VS reserves a port number for this service, it can be found in the Properties Window(F4), so, this port number has to be used in the address we set as the Start URL in Property Pages. And that´s it. You have been very helpful Juan. – Rafael Feb 27 '14 at 16:46
  • Well done Rafael! Please edit your post with the solution, so others can use it. – Juan Fausd Feb 27 '14 at 17:12
0

In VS2012, Open your "HostDevServer" -> Properties Window (F4) and check the port used at Developer Web Server.URL (http://localhost:<Port Number>), then make sure that Property Pages (Shift+F4).Start Options... .Start URL: is On and set to

http://localhost:<Port Number>/HostDevServer/HelloWorldService.svc 
Rafael
  • 2,413
  • 4
  • 32
  • 54