How to debug a remotely hosted WCF web service - wcf

I am new to WCF web service development and I can use some help.
I have a simple web service written in C# that I'm hosting on a remote server (it's hosted on IIS 5.1).
I've written a client application for that web service that I'm running on my workstation.I am able to connect to the service without any problems.
However, I would like to be able to debug the web service.I need to be able to step through the code, set breakpoints, etc.How do I achieve that from my local machine? I'm using Visual Studio 2010.
Thank you in advance.

I see two possibilities:
Local debugging: For debugging, run your service on your local machine. If you want to run it on the local IIS, simply start a second instance if VS2010 and attach to the w3wp.exe process (menu Tools -> Attach to process)
Remote Debugging: You have to install and start the VS2010 remote debugger on the server. Start a second instance of VS2010 on your development box and connect to the remote debugger with menu Tools -> Attach to process.
See msdn for more information about remote debugging with VS2010.

Related

Connect VS2022 debugger to ASP.NET Core application hosted on windows server IIS (2019)

I'm having issues with ASP.NET Core 6 app on my VPN Windows server 2019. Basically, I have Syncfusion OCRProcessor with tesseract files, but my application can't find part of the path for tesseract binaries on server when locally is working fine (on server error message is "cannot find part of the path C:\inetpub\wwwroot\myapp\x64").
After contacting Syncfusion support didn't solve the issue, I have checked for permissions in file system, double checked the locations of the binaries on IIS, checked if dll's are blocked in from Windows in file system. I have tried to connect from my machine with VS 2022 Community to my VPN server (public IP address) to try to debug the application, but going trough all the documents about remote debugging, still I can't connect to my app and hit the breakpoint in code to determine what is happening..
I have installed remote debugger for VS 2022 onto server, configure it and started, I have published application again over web deploy with debug config to IIS, but I just don't understand next step - how to attach to the process on external server..
Most of the videos and documentation suggests that IIS is installed locally on development machine, or IIS is on some PC in local network, but I have public server.. Can anyone help with the advice how to proceed further?
Thanks!
Ok, I have managed to connect debugger from VS 2022 to IIS.
The issue was in port, firewall and also in description on Microsoft help site https://learn.microsoft.com/en-us/visualstudio/debugger/remote-debugging-aspnet-on-a-remote-iis-7-5-computer?view=vs-2022 where in step 3 is written "Set the Qualifier field to and press Enter." - you need to enter ip address and port into connection target textbox.
After succesfull logging in onto server, I needed to select w3wp.exe process with title "CoreApp: https://.. ", set breakpoint in VS 2022 and open ASP.NET Core app in browser. After that I managed to debug application on IIS.
Hope this would be helpful to someone!

WCF Web Service : How to run?

Am planning to build a WCF Web service using Visual Studio 2015. I came up with a sample web service that i can launch from visual studio and this works fine when i call the APIs from browser on local host.
Now i want to deploy it in a server. Am not sure how I can deploy in a server. The final out put of the web service is a DLL.
Can someone explain to me how to deploy this in a Windows server?
Do i need to run this web service DLL as a service?
Does it got anything to do with IIS?
As per your request, I have made this an answer.
If you're looking to host a WCF service which is exposed to the outside world then the best solution is to host the service via IIS which you can find out how to do by reviewing the following article.
You can find a more visual tutorial here.
If you encounter errors after publishing to IIS then please refer to the following StackOverflow answer to see which Windows Features must be enabled.

WCF self host: when I run into visual studio service works, when I run the release exe does not

I have a service that is host in a console application. when I run this application inside visual studio, the service is open and I can access from the client or when I use the uri in an internet browser.
However, when I run the exe, the service is not open and I can't acccess to the service. I have tried to run as elevated privileges, but it does not work.
Why in visual estudio works and stand alone not?
I am using VS2015 community and WCF 4.5.
Thanks.

WinCe cannot connect and consume WCF service

I created a test WCFServiceLibrary project leaving the example code created by VS20212, then i created a ConsoleApplication in the same solution and added a web reference to the service.
In my ConsoleApplication i write this:
var ns = new ServiceReference1.Service1();
Console.WriteLine( ns.GetData( 100 ) );
I press F5 and everything seems fine.
Now i keep my WcfTestClient (the server hosting my service when launching from visual studio) running and create a new CompactFramework 2.0 ConsoleApplication project from VS2008.
I add a web reference as before, i compile and distribute my app on my test device I try to execute the same code you see above but i get this error:
"Unable to connect to the remote server" inner exception {"No connection could be made because the target machine actively refused it"}
Dows WcfTestClient have some limitation that do not allow me to connect from outside localhost? How can i solve this problem?
I had to change 'localhost' to my actual server ip in my CompactFramework project's app.config since i was remotely debugging an application deployed on a real device :)

Web Deploy results in ERROR_COULD_NOT_CONNECT_TO_REMOTESVC

We are trying to configure continuous integration with TFS 2012. While queuing a new build, the publish fails with the error:
Build FAILED.
"C:\src\ProjectName.sln" (default target) (1) ->
"C:\src\Website\ProjectName.csproj" (default target) (2) ->
(MSDeployPublish target) ->
C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v11.0\Web\Microsoft.Web.Publishing.targets(4377,5): msdeploy error ERROR_COULD_NOT_CONNECT_TO_REMOTESVC: Web deployment task failed. (Could not connect to the remote computer ("ServerName") using the specified process ("Web Management Service") because the server did not respond. Make sure that the process ("Web Management Service") is started on the remote computer. Learn more at: http://go.microsoft.com/fwlink/?LinkId=221672#ERROR_COULD_NOT_CONNECT_TO_REMOTESVC)**
I checked all the points mentioned in the IIS.NET documentation for this error. Both services mentioned, Web Management Service and Web Deployment Agent Service, are running fine. A restart of those services has no change in behavior.
Windows Server 2008 R2 with IIS 7.
Web Deployment Agent Service is running on port 8172.
Web Deploy 3.0
Windows Firewall is not blocking any port on the server.
How can this be fixed?
If you install Web Deploy 3.x BEFORE Web Management Tools are installed, you'll have to re-install Web Deploy. I beat my head against the wall for hours on this.
Install the Web Management Services ("Turn Windows Features On/Off"/Roles -> Web Server -> Management Tools -> Management Service)
Then uninstall Web Deploy (repair didn't work) via the usual Add/Remove Programs control panel
Install Web Deploy 3.x again using Web Platform Installer.
Fixed. /Sigh
Double check in your Web Deploy settings that the name of the website is exactly that of what's in IIS.
Ben Day blogged more about it.
Fix that i saw on another website:
Fix it by adding “http://” to server.
In other words, when server is www.xxxx.com would get the 403 error, but when server is http://www.xxxx.com, then it works.
You need also to indicate the app name e.g 'Default Web Site/MyApp'
That was my error. Once I added /MyApp, it worked.
I got this error when using msdeploy, not TFS. In my case I needed to make sure the user msdeploy is using had permission to deploy to the website.
Find the website in IIS manager, right click and go to Deploy, then Configure Web Deploy Publishing. Find the user used by Web Deploy and setup for this website.
In my case the Internet proxy was enabled on source - which made msdeploy to reach out to internet instead of local ICN.
You should check the logs on your IIS first - see that you actually get to the server, and then you can locate the exact error here - https://support.microsoft.com/en-us/help/943891/the-http-status-code-in-iis-7-0-iis-7-5-and-iis-8-0
Uninstalling and re-installing (not repairing!) after setting up IIS did most of the magic for me.
There is another possible cause of the error. IIS Managemente Service have its own configuration for IP Address Restrictions, which default value is Deny Access for unspecified clients (Windows Server 2012 R2 with IIS 8.5).
You must set this value to Allow or add access to your specific IP address/IP address range using the Allow... button.
Remember, you must Stop the Management Service previously to change this configuration.