Question

I have a WCF Service Application. And a Windows Mobile 6 application with .NET Framework 3.5 in VS2008.

I create several versions of the WCF serice with various .NET Frameworks (3, 4 etc). in VS2012.

I host them under my local IIS 7. And I can successfully connect and run service methods via WCF Test Client. Everything seems OK.

I add service(s) with "Add -> Web reference" (both with localhost and 127.0.0.1) and try to connect from the mobile application.

Regardless of which version of the service I use I keep on getting the following error

Exception   : System.Net.WebException
Message     : Unable to connect to the remote server.
Stack Trace : 
              at System.Net.HttpWebRequest.finishGetResponse()
              at System.Net.HttpWebRequest.GetResponse()
              at System.Web.Services.Protocols.WebClientProtocol.GetWebResponse(WebRequest request)
              at System.Web.Services.Protocols.HttpWebClientProtocol.GetWebResponse(WebRequest request)
              at System.Web.Services.Protocols.SoapHttpClientProtocol.doInvoke(String methodName, Object[] parameters, WebClientAsyncResult asyncResult)
              at System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String methodName, Object[] parameters)
              at testWcfMobileClient.svc3.Service1.Test(Boolean& TestResult, Boolean& TestResultSpecified)
              at testWcfMobileClient.Form1.Form1_Load(Object sender, EventArgs e)
              at System.Windows.Forms.Form.OnLoad(EventArgs e)
              at System.Windows.Forms.Form._SetVisibleNotify(Boolean fVis)
              at System.Windows.Forms.Control.set_Visible(Boolean value)
              at System.Windows.Forms.Application.Run(Form fm)
              at testWcfMobileClient.Program.Main()

Inner Exception : 
Exception   : System.Net.Sockets.SocketException
Message     : No connection could be made because the target machine actively refused it
Stack Trace : 
              at System.Net.Sockets.Socket.ConnectNoCheck(EndPoint remoteEP)
              at System.Net.Sockets.Socket.Connect(EndPoint remoteEP)
              at System.Net.Connection.doConnect(IPEndPoint ep)
              at System.Net.Connection.connect(Object ignored)
              at System.Threading.ThreadPool.WorkItem.doWork(Object o)
              at System.Threading.Timer.ring()

I can not find a solution to my problem and any help is appreciated.

Regards.

UPDATE INFORMATION (24.03.2014)

I have been working on the issue since then and I would like to provide more information.

I have two servers, SRV01 and SRV02 respectively which do host several other web sites as well.

I deploy my Service Application to both servers, the issue is:

SRV01 responds as expected, no problem, confirming that there is no problem with the Emulator Network settings.

However SRV02 still throws the same Exception. The awkward situation here is SRV02 hosts other services as well which currently run smoothly.

I am comparing the IIS settings, Application settings, machine.config file and web.config files and everything also seems identical.

And one other wierd thing is that SRV02 is in my building & network, while SRV01 is a remote one in the same domain. I should probably going easier with the SRV02 but eh current situation is vice versa.

Was it helpful?

Solution

I finally found the answer in some post which I unfortunately do not remember the address.

All I have to do is replace the "localhost" to my PC's IP address.

Altough a satisfactory explanation do exist on the post which I found the answer as far as I can remember the reason was that "localhost" refers to the emulator itself and the application should point the machine hosting the service as another machine instead of the emulator itself.

OTHER TIPS

"No connection could be made because the target machine actively refused it" does normally mean the target is not reachable with the port setting. First check the port settings. Check the target IP address. Check the firewall. Does the (SQL) server support TCP/IP?

Verify that you can connect using ping (for example using Cambridge vxUtils). Verify that you have a network address in the emulator.

To get a TCP/IP connection in emulator you must either have a emulated network card (which is hard to get to work for windows 8, AFAIK it is impossible) or 'Dock' the emulated device and set WMDC Connection settings to 'This computer is connected to Internet' and allow Data connections (called ActiveSync Passthru connection). The emulator will normally not dock your emulated device. VS uses DMA to remote debug the app.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top