Our application accesses a WCF service, which is hosted by a Windows Service on a single computer. The client application and service always will be on the same computer.
I've created a Windows Service that hosts a WCF service. To test my Windows Service code, I created a console application that contains the same app.config and code as my Windows Service. I start the console application in one debugging thread, and launch my client in another debugging thread. Everything works perfectly and I can easily use the debugger.
Now the rub...
So, I created an installer and installed my Windows Service. After successfully starting it, I successfully added the Service Reference to my client using http://localhost/VssService within Visual Studio 2010. I successfully attached to the service via "Attach To Process". I launched my client in a debugging thread, but when I try to step into a remote method, I get "Unable to automatically step into the server. The debugger failed to stop in the server process." This happens for both [NetNamedPipeBinding_IVssService] and [BasicHttpBinding_IVssService]. I have been struggling with this for hours and have run out of ideas, so I hope that you can help me. I've included the app.config files for my Windows Service and Client application. Hopefully they will help.
I appreciate your taking time to read this question and hope that you can help be to resolve this problem...
Mike
===================== SERVICE APP.CONFIG =============================
<services>
<service behaviorConfiguration="VssServiceBehavior" name="ClientSaver.VssService.VssService">
<endpoint address="net.pipe://localhost/VssService/Pipe/" binding="netNamedPipeBinding"
bindingConfiguration="" contract="ClientSaver.VssService.IVssService" />
<endpoint address="http://localhost/VssService/" binding="basicHttpBinding"
bindingConfiguration="" contract="ClientSaver.VssService.IVssService" />
<endpoint address="http://localhost/VssService/MEX/" binding="mexHttpBinding"
bindingConfiguration="" contract="IMetadataExchange" />
<host>
<baseAddresses>
<add baseAddress="http://localhost/VssService/" />
</baseAddresses>
</host>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="VssServiceBehavior">
<serviceMetadata httpGetEnabled="True" policyVersion="Policy15" />
<serviceDebug includeExceptionDetailInFaults="False" />
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
========================= CLIENT APP.CONFIG =============================
<endpoint address="http://localhost/VssService/" binding="basicHttpBinding"
bindingConfiguration="" contract="ClientSaver.VssService.IVssService" />
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="VssServiceBehavior">
<serviceMetadata httpGetEnabled="true" policyVersion="Policy15" />
<serviceDebug includeExceptionDetailInFaults="true" />
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
Ok. One way I use when VS debugging stops working is to place a System.Diagnostics.Debugger.Break() in a conventient place in the service code (say, constructor or method). This causes the JIT debugger to fire up and allows me to connect to the service with the code broken at that point with any VS instance I have.
Obviously you remove it from non debugging code.
You can't step across executable boundaries. Youll need to set breakpoint in your server code (that is project). Then from server`s project attach to the running windows service process (be carefull here ... you need to have latest server project running as windows service). Then, when you step in your Windows Forms app, it'll get caught by the server's breakpoint.
You should use internet explorer as default browser to debug your service...
Have a look at the debugging tools for windows. There are a couple of tools in here that are useful for debugging windows services.
Have you tried manually loading debug symbols? It once happened to me and it was happening because VS was not loading the symbols.
Related
I have a WCF Service Application project in Visual Studio that contains the following files
ZooWebService.svc
WebConfig
I attempted to host the Web Service in IIS but when i browse to my web service from IIS the Web Service does not load at all. It just says "loading" in the browser.
Here is my WebConfig file:
<?xml version="1.0"?>
<configuration>
<appSettings>
<add key="aspnet:UseTaskFriendlySynchronizationContext" value="true" />
</appSettings>
<system.web>
<compilation debug="false" targetFramework="4.6.1" />
<httpRuntime targetFramework="4.6.1"/>
</system.web>
<system.serviceModel>
<services>
<service behaviorConfiguration="Default"
name="WCFWebService.ZooWCFService">
<endpoint address="" binding="basicHttpBinding"
contract="WCFWebService.IZooWCFService" />
<endpoint address="mex" binding="mexHttpBinding"
contract="IMetadataExchange" />
<host>
<baseAddresses>
<add baseAddress="http://localhost:8080/" />
</baseAddresses>
</host>
</service>
</services>
<behaviors>
<endpointBehaviors>
<behavior name="webBehavior">
<webHttp />
</behavior>
</endpointBehaviors>
<serviceBehaviors>
<behavior name="Default">
<serviceMetadata httpGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="true"/>
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
</configuration>
I did the following so what have i done wrong?
Open IIS
Right clicked on Default Website
Selected "Add Application"
Populated "Alias" field
Populated "Physical Path" to directory of where the solution contents are
Clicked OK
Rebuilt the solution in Visual Studio
We don’t need to specify the base address in the configuration file which needs to be set up in the web site binding module.
https://social.msdn.microsoft.com/Forums/vstudio/en-US/d42fc165-052d-476a-9580-1240b3d0293d/specify-endpoint-in-wcf-webconfig?forum=wcf
then we should enable the WCF feature in the IIS.
At last we could see the web service description in http://ip:port/xxxx.svc.
Feel free to let me know if there is anything I can help with.
For enabling the WCF in IIS, you may have to enable the HTTP activation feature for the .net framework first.
Some of links to do this
https://docs.sdl.com/LiveContent/content/en-US/SDL%20Tridion%20full%20documentation-v1/GUID-326D6F7B-08EC-43EB-A5A7-9C51DD9E555C
https://pubs.vmware.com/mirage-56/index.jsp?topic=%2Fcom.vmware.mirage.api.pg.doc%2FGUID-552D845B-E530-4898-A06B-4F73E668BEFF.html
Once this is done you may try to deploy WCF directly from the visual studio to your local IIS>
Right click on the WCFproject -> go to properties -> in properties window -> select web tab -> in servers section select Local IIS and click on Create Virtual Directory.
Now run the WCF from Visual studio, this will host the WCF in local IIS.
I have a very weird problem with a 3 tiers client/server application with WCF.
First, I have a service windows which host WCF services in basicHttpBinding. This is the server app.config :
<?xml version="1.0"?>
<configuration>
<system.serviceModel>
<services>
<service name="Business.BSServiceManagement" behaviorConfiguration="myServiceBehave">
<host>
<baseAddresses>
<add baseAddress="http://localhost:35001"/>
</baseAddresses>
</host>
<endpoint address="/Clients" binding="basicHttpBinding" name="Clients" contract="Contracts.BusinessFacade.IBFClientManagement"/>
<endpoint address="/Users" binding="basicHttpBinding" name="Users" contract="Contracts.BusinessFacade.IBFUserManagement"/>
<endpoint address="/Licences" binding="basicHttpBinding" name="Licences" contract="Contracts.BusinessFacade.IBFLicenceManagement"/>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="myServiceBehave">
<serviceMetadata httpGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="true"/>
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
</configuration>
This service is deployed on a server in DMZ and I have access from my computer (in firefox, if I put service address with port number)
Secondly, I have a client application made with winforms which consume the service with ChannelFactory.
This is the client app.config :
<?xml version="1.0"?>
<configuration>
<system.serviceModel>
<client>
<endpoint address="http://192.168.128.1:35001/Clients" binding="basicHttpBinding" name="Clients" contract="Contracts.BusinessFacade.IBFClientManagement"/>
<endpoint address="http://192.168.128.1:35001/Users" binding="basicHttpBinding" name="Users" contract="Contracts.BusinessFacade.IBFUserManagement"/>
<endpoint address="http://192.168.128.1:35001/Licences" binding="basicHttpBinding" name="Licences" contract="Contracts.BusinessFacade.IBFLicenceManagement"/>
</client>
</system.serviceModel>
</configuration>
When I debug client application, all works perfectly. So I've made a installer project to deploy application on several computers but when I execute exe of application (installed or directly in bin/release), I have an error message like this :
There was no endpoint listening at http://192.168.128.1:35001/Users...
The inner exception says:
Unable to connect to the remote server
I tried adding mex endpoint, change port number, check server and client computer firewall, I don't understand where is the problem.
Thanks for your help.
EDIT 1 :
After several tests I have the same problem in release exe but not in debug exe.
If I execute the debug exe all works fine but the release exe return the error message.
The problem is with your Service.
Make sure that the Service is Started and running.
Once you start the Service, browse URL(eg: localhost:8080/example), just to make sure Service is running fine.
When you add Service Reference to your client Application, it automatically generates endpoints in app.config file.
When you added Installer to client project, make sure that it is builds Successfully.
When you install it, it should work for you.
I have a sweet WinForm application (on my computer) and a SQL Server database (on server X). I'm using SqlConnection and everything works fine.
But not I want to change it and use WCF or other technologies to connect and switch information between my app and database.
I also have one more server to use as application server (Server Y).
I've started using WCF: created project, created installer.
Uploaded it on my Y server and installed it. Service started, also I've added Service Reference to my WinForm app, but the ServiceClient is not working properly.
When I call ServiceClient's method it throws exception:
An exception of type 'System.ServiceModel.EndpointNotFoundException' occurred in mscorlib.dll but was not handled in user code
Additional information: There was no endpoint listening at http://localhost:41272/service that could accept the message. This is often caused by an incorrect address or SOAP action. See InnerException, if present, for more details.
As I guess my endpoint is blowing things up.
So I want you guys help me how to configure SQL endpoint.
Here is my WCF's web.config:
<?xml version="1.0"?>
<configuration>
<system.web>
<compilation debug="true" targetFramework="4.5" />
<httpRuntime />
<pages controlRenderingCompatibilityVersion="4.0" />
</system.web>
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior name="SampleSvcBehavior">
<serviceDebug includeExceptionDetailInFaults="true" />
<serviceMetadata httpGetEnabled="true" />
</behavior>
</serviceBehaviors>
</behaviors>
<services>
<service behaviorConfiguration="SampleSvcBehavior"
name="FMG_WCF.FmgService">
<endpoint name="SampleSvcBasicHttpEndPoint"
address=""
binding="basicHttpBinding" bindingConfiguration=""
contract="FMG_WCF.IFmgService" />
<endpoint name="SampleSvcMexHttpEndPoint"
address="mex"
binding="mexHttpBinding" bindingConfiguration=""
contract="IMetadataExchange" />
<host>
<baseAddresses>
<add baseAddress="http://localhost:41272/service" />
</baseAddresses>
</host>
</service>
</services>
</system.serviceModel>
</configuration>
This error is not related with SQL endpoint. In facts you do not need endpoints for connecting WCF to database. Here is your answer in another post.
EndpointNotFoundException - 404 - Hosting WCF Service over HTTPS in IIS through Visual Studio
You have two options, if the service has been modified from when you created it you can simply right click on the service reference and configure the service reference. In the popup you can change the Url to point to serverX and you service reference and config file will be automatically updated.
If no changes were made to the service, for example your binding type or security then simply updating the Url in the config file should be enough.
I have searched on here for the exact solution to my problem to no avail.
I have added a Web Service to my project but am unable to reference it. Clicking Discover works fine - the service is available but when it comes to retrieving a list of services at its location the following text appears:
The HTML document does not contain Web service discovery information.
Metadata contains a reference that cannot be resolved:
Metadata contains a reference that cannot be resolved:
'http://localhost:57657/Services/AFDiscovery.svc'.
If the service is defined in the current solution, try building the solution and
adding the service reference again.
How do I fix this? I am attempting to run the service locally so I do not need to add it within IIS.
Web.config information:
<services>
<service name="WebServiceInterface.AFDiscovery">
<endpoint address="" binding="wsHttpBinding" contract="WebServiceInterface.AFDiscovery" />
</service>
</services>
You can add the project containing the WebServiceInterface.AFDiscovery in your solution. Then in the project using the web service, when you add your reference, instead of clicking "Discover", use the load from project option.
If you want to load the reference via a URL (Discover button), try browsing to "http://localhost:57657/Services/AFDiscovery.svc?WSDL" in your browser. If you get a message saying the metadata isn't accessible, you must modify your web service web.config.
Check this link for configuring the web.config: http://msdn.microsoft.com/en-us/library/aa751951.aspx
It should look similar to:
<configuration>
<system.serviceModel>
<services>
<service
name="WebServiceInterface.AFDiscovery"
behaviorConfiguration="SimpleServiceBehavior">
<endpoint address=""
binding="wsHttpBinding"
contract="WebServiceInterface.IAFDiscovery" />
<endpoint address="mex"
binding="mexHttpBinding"
contract="IMetadataExchange" />
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="SimpleServiceBehavior">
<serviceMetadata httpGetEnabled="True"/>
<serviceDebug includeExceptionDetailInFaults="False" />
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
</configuration>
One of the possibility is the service name in your Web.config does not
match the namespace in your class file.Make sure the names are the
same then try again.
Refer
And double Check your Service MarkUp code by reghclick and Choose MarkUp
I am getting a Bad Request (Invalid host) when trying to run my C# WCF service under mono. This service is part of an application, not being hosted using a web server.
I have configured my services with the following:
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior name="DefaultServiceBehavior">
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="false" />
</behavior>
</serviceBehaviors>
</behaviors>
<services>
<service behaviorConfiguration="DefaultServiceBehavior" name="MyServices.TaskService">
<endpoint address="V1" binding="basicHttpBinding" contract="MyServices.ITaskServiceV1" />
<host>
<baseAddresses>
<add baseAddress="http://localhost:8731/MyServices/Tasks" />
</baseAddresses>
</host>
</service>
</services>
</system.serviceModel>
When I try to visit http://localhost:8731/MyServices/Tasks or any of its endpoints (including ?wsdl), I get the 400 error.
I have deployed this successfully using the .net runtime, just can't figure out what's wrong for deploying with mono. Any help would be greatly appreciated.
EDIT Mono version: 2.10.1
I had the same issue today.
Hosting a wcf service inside a .net 3.5 application worked but same code using mono 3.2.2 gives invalid host error response.
So I checked mono source and found out that mono searches for a valid endpoint from request url using case sensitive compare. Changed my url to fit case like in my service config resolved the issue.