views:

111

answers:

2

I am trying to debug a problem with a .net compact framework application I have running on windows mobile 6. It occurs when I call a web-service call on my development machine.

I don't need any help with the actual error, but with invoking the debugger at the correct time.

I run the web-service in debug mode and am able to trigger a breakpoint in visual studio fine so I know it is attached ok. The problem I have is that when my web service throws an exception, the web-service call immediately ends and the text of the exception appears on the screen of my mobile client. What I really want to happen is that the exception causes Visual Studio to break execution and allow me to use the debugger for further investigation. As you might imagine, not being able to get a line number is pretty frustrating as I have to step through the code line by line until the exception appears on the mobile client.

I've read on the web how you might wish to turn exceptions into SOAP ones for transmission to remote clients, I think this may be is what is happening but I don't want it to!

A: 

Is the exception happening in your application (how it's handling the result of the webservice call), or is it happening at the remote service, and the exception is being passed back?

As a temporary workaround, you might try enclosing the webservice call in a Try/Catch block, and then calling it again from the Catch section, with a breakpoint on the call. That way, when it fails the first time, execution will break on the second call, so you can step into it or check various values all you want, without having to step through your code to get to that point.

rwmnau
It's most definitely occurring within the web service. The actual error is from an sql server call which only happens in the web service. I've just shown it to a colleague and he agrees that it is bizarre behaviour.Extra try-catch wrappers on the client won't really help in this instance as I need the visual studio debugger to be triggered by the exception thrown on my web service.
Neil Trodden
Ah - I was thinking that your app was just reporting the exception, instead of handling it properly. Since it's coming from the server, it makes sense now.
rwmnau
+1  A: 

It appears that Visual Studio is only set up to handle 'unhandled' exceptions but from what I can gather, the code that calls my web service method wraps it in a try..catch, handles the error and passes it to the client over SOAP.

If you go to Debug->Exceptions... in Visual Studio there are check-boxes to force visual studio to invoke the debugger on exceptions thrown handled within the .NET framework - check the "thrown" column next to Common Language Runtime Exceptions and it then picks it up properly!

Neil Trodden
Glad to hear it! I know there's an option in there to break on all exceptions, even if they're handled, which might be what you're talking about. That way, you can follow the execution path in all cases.
rwmnau
You have to be careful because (in the compact framework) Microsoft actually throw (and handle) exceptions internally! So I had to un-check some libraries such as System.Data and it worked fine!
Neil Trodden