When to attach debugger to w3wp.exe - c#

I have a WCF service hosted in IIS. My client is a Windows forms. I have provided service reference in my client application, so that it can generate server proxies (based on the service wsdl) and access methods exposed in my service. If I want to debug the server code, I can step into(F11) that server method from my client application. I understand that I am not actually debugging the server code, but I am stepping into the proxy generated by the client. I am confused that for some services, for debugging the server side code, it is often suggest to attach the debugger of client application to w3wp.exe. Why is this done, is there any reason for doing this?
Thanks

I have seen this before. I think that Visual Studio is smart enough to detect that the server code is hosted inside IIS, and it suggests that you attach to the application pool inside IIS, if you do this you can actually debug the WCF service code.

This is mainly suggested to ensure you are testing the latest service code.
if you are debugging the proxy, you have to make sure you update the proxy for every change made in it or you will still be looking at the old proxy while the actual service has changed and the reference is not updated.
if you attach a debugger to w3wp.exe, you will be hitting the current version of the WCF service code and not the version in your proxy.

Related

C# Web service works in console but not from asp.net website on IIS server

I'm using a web service which works fine when I run it on my machine in an ASP.NET application using the default IIS Express VS 2010 comes with. However, when I move it to our server with IIS I get the error:
Error: There was no endpoint listening at 'web service name here' that could accept the message. This is often caused by an incorrect address or SOAP action.
'web service name here' is just a placeholder I put for this post. It has the right web service name.
So I pulled out the small login code that this is failing on into a console application and ran that from the IIS server and it worked! So I have to assume this is some kind of permissions issue with the IIS server on how it's running my web service code? In my ASP.NET program I have a separate DLL that handles the web service. The ASP.NET application fires off a separate thread that uses the DLL I made that uses the web service. Is it something to do with the separate thread permissions maybe? Any ideas?
Your first step when faced with this sort of issue is to search your config files for "web service name here" (or if this isn't actually the message you're getting the address given in the message). My suspicion is somewhere you'll have a WCF reference set up which needs a proper IP address.
Once you've got the address (assuming it looks valid) you need to check you can access it from the machine which is having the difficulties - it may be a firewall issue.
Now that you've established that your console application is connecting correctly from the same machine the next step is to check that both your IIS App Pool and Console application are running under the same user account/permissions. It may be that one identity has permission to access the network/internet and the other one doesn't.

Deploy a backend application on a Windows Server

I'm making an application in C# with VS 2012 that checks a database every 15 seconds and perform some actions when it finds data. Right now I've created a Console Application so I can debug it easely but during relese this application needs to run in a IIS server.
How can I do that? I've read this question but it looks like some sort of workaround because to run it I need to perform these steps. Right now I'm reading the docs about Windows Service Application, Is this the right way?
EDIT Sorry but I've never used Windows server before, so as people pointed out IIS is only a web server, the thing I need to do is run my application in a Windows Server environment
IIS is a web-server and accordingly it should be used for hosting web applications.
Develop a windows service which does the job of checking the database in intervals and invoke a web service (which you can host in IIS)
If your application is performing some data query and manipulation on the server then I would recommend the approach to host it in a windows service.
Some advantages to this are:
The service will start and run independently of a user logging into the server.
You can configure the service to recover should it experience an exception (ideally not!).
The service will start automatically (if configured) when the server restarts.
You can configure which user group (or user) the service should run under so you have a more granual approach to security.
As it's running as a seperate process, you can monitor its memory and processor utilisation.
Debugging is slightly more cumbersome but not difficult, one approach I've used is to install the service locally, start it and then attach to it via the debugger. This question describes another approach I've also used.

Need to debug my Web API service that's requested from a client machine - need help, how do I do this?

I built a Web API service that's hosted locally on my machine in IIS. I have an iOS app that I'm running via XCode that makes the call to the web service. The connectivity is there, and works. The iOS app successfully makes the connection to my published web service.
The problem is my web service is returning a non descriptive error to the client (iOS), so what I need to be able to do is step through the web service code while running my iOS app.
So, in summary:
I run an iOS app via my MacBook, and it connects to my .NET Web API service.
My Web API service is published to my local IIS, and is returning an error back to the client.
Breakpoints aren't being hit in Visual Studio - do I need to attach my Visual Studio debugger to a specific process? I've tried running my web service in debug mode while running my iOS app, to no avail.
How can I step through my web service code when running the client app (iOS) that accesses the web service?
Attach to process - http://msdn.microsoft.com/en-us/library/vstudio/3s68z0b3.aspx
Make sure "Show processes from all users" is checked, and pick w3wp.exe
You may need to hit the service once first to make sure its started.
To debug an app that's hosted by IIS, you want to attach to process (in Visual Studio it's Tools->Attach to Process or Ctrl+Alt+P) and pick w3wp.exe from the list (you might have to check a few boxes for the process to show up).
Another option is to use our free VS Extension called Conveyor
https://marketplace.visualstudio.com/items?itemName=vs-publisher-1448185.ConveyorbyKeyoti
With it you open up IIS Express to remote connections on your network (or even the web through tunnelling).
Once you've done that you can debug the project directly from VS and connect to the Conveyor port number (or domain name via tunnelling) and debug as you would locally.
you can use Postman client.
First : run the API FROM visual studio
Second : go to postman put the url and add the parameter in body
More information : http://www.tutorialsteacher.com/webapi/test-web-api
this often works for me i generally list all of the processes in IIS with appcmd command
appcmd list wp
and pretty much you know which process to attach by seeing the names of the web services
if appcmd is not available please visit
Here for configuring this

Difference between website's access and web service's acess

Following this question, I've met another problem where the request just doesn't go through. When I was first given the task, the website was working like so :
Website -> Web Services -> Library -> External Server (TextML Server for those who might be familiar with it).
I was asked a couple of things and of them was to get the web service layer out of the way to improve performance, like this :
Website -> Library -> External Server
So I went through the code and made the proper changes but I faced a problem where authentication was a problem, I asked the question and found the solution. Now the Website use the correct user to connect with the External Server. But then the method connecting with this particular server just run and goes on, and on, and on.... forever.
So the question is quite simple :
Is there a difference for the External Server either its a Web Service or a website that's is trying to establish a connection?
I use c#, asp on Windows XP and when I debut I use the local IIS which runs IIS 5.0 (I know its kinda old)
Also, one point to note if that if inside the same method, I use the webservice from my website to connect, it works and then the next line of code I use the library, it doesn't.
Example code :
WsDocServerService.DocServer doc = new WsDocServerService.DocServer();
XmlDocument oIndexList = new XmlDocument();
oIndexList = doc.GetSystemDocument(INDEX_FILE);//This will work
oIndexList = DocServerController.GetSystemDocument(INDEX_FILE);//This wont
//But both way I use the DocServerController.GetSystemDocument(filename); to get the file
Thanks a lot!
Although, I don't need a solution, maybe a proper answer could help me to solve the problem!
EDIT
The web service method called above is calling the controller method :
DocServerController.GetSystemDocument(INDEX_FILE);
That's why I thought this was useless to go with the Web Service, and yes I meant an .ASMX web Service.
I went with the admin of the server and reviewed the event log, there is an error relating a COM+ program that appears every time I run the above method. Sadly, I think the problem has something to do with the server itself.
Do you think I should shut the question?
EDIT
Event viewer logged entry :
The run-time environment has detected an inconsistency in its internal state.
This indicates a potential instability in the process that could be caused by
the custom components running in the COM+ application, the components they
make use of, or other factors. VariantUnmarshal: CoUnmarshalInterface for
IID_IDispatch failure
Server Application ID: {F27C90B8-C40E-4B76-8F01-A8C035EACC08}
Server Application Instance ID:
{79C9FDFC-78AD-461B-95E6-80FF54880317}
Server Application Name: Textml Server
Error Code = 0x800706ba : The RPC server is unavailable.
COM+ Services Internals Information:
File: d:\nt\com\complus\src\comsvcs\ucp\assoc.cpp, Line: 723
Comsvcs.dll file version: ENU 2001.12.4720.3959 shp
For more information, see Help and Support Center at
http://go.microsoft.com/fwlink/events.asp.
There seems to be some COM+ misconfiguration on your server.
Here are some workarounds by other people running into this problem (Event 4689):
http://www.eventid.net/display.asp?eventid=4689&eventno=3980&source=COM+&phase=1

How to debug WCF service with Silverlight

I have two solutions, one is the WCF service and the other one is the Silverlight.
I would like to use the debugger on both solutions at the same time. The debugger for the WCF service automatically starts a ASP.NET development server. However, I have a hard time making my Silverlight client connecting to the ASP.NET development server. The error says that I'm lacking of the client domain policy file.
Does anyone know where should I put the clientaccesspolicy.xml for the ASP.NET development server?
Thanks a lot!
clientaccesspolicy.xml needs to be in the root directory for the web server running the WCF service. In your case, this probably means the solution directory for the WCF application (if you're running the web server "in place").
You could also try using Fiddler or Firebug to determine exactly where the file is being requested.

Categories