exception

Cannot handle FaultException

i have a wcf service that does an operation. and in this operation there could be a fault. i have stated that there could be a fault in my service contract. here is the code below; public void Foo() { try { DoSomething(); // throws FaultException<FooFault> } catch (FaultException) { ...

Troubleshooting a NullReference exception in a service

I have a windows service that runs various system monitoring operations. However, when running SNMP related checks, I always get a NullReference exception. The code runs fine when run through the user interface (under my username and password), but always errors running as the service. I've tried running the service as different user ...

Unhandled exceptions filter in a windows service

I am creating a windows service and want to know best practices for this. In all my windows Program I have a form that asks the user if he wants to report the error and if he answers yes I created a case in FogBugz. What should I do in a windows service. ...

Adding extra information to a custom exception

I've created a custom exception for a very specific problem that can go wrong. I receive data from another system, and I raise the exception if it bombs while trying to parse that data. In my custom exception, I added a field called "ResponseData", so I can track exactly what my code couldn't handle. In custom exceptions such as this on...

Connecting to registry remotely, and getting exceptions

I've inherited a hoary old piece of code (by hoary, I mean warty with lots of undocumented bug fixes than WTF-y) and there's one part that's giving me a bit of trouble. Here's how it connects to the remote registry to get the add/remove programs key: try { remoteKey = RegistryKey.OpenRemoteBaseKey( ...

What is the point of the finally block?

Syntax aside, what is the difference between try { } catch() { } finally { x = 3; } and try { } catch() { } x = 3; edit: in .NET 2.0? ...

What is the difference between Raising Exceptions vs Throwing Exceptions in Ruby?

Ruby has two different exceptions mechanisms: Throw/Catch and Raise/Rescue. Why do we have two? When should you use one and not the other? ...

Apache XML-RPC Exception Handling

What is the easiest way to extract the original exception from an exception returned via Apache's implementation of XML-RPC? ...

Should I derive custom exceptions from Exception or ApplicationException in .NET?

What is best practice when creating your exception classes in a .NET solution: To derive from System.Exception or from System.ApplicationException? ...

What is the correct .NET exception to throw when try to insert a duplicate object into a collection?

I have an Asset object that has a property AssignedSoftware, which is a collection. I want to make sure that the same piece of Software is not assigned to an Asset more than once. In Add method I check to see if the Software already exist, and if it does, I want to throw an exception. Is there a standard .NET exception that I shoul...

What are some best practices for creating my own custom exception?

In a follow-up to a previous question regarding exceptions, what are best practices for creating a custom exception in .NET? More specifically should you inherit from System.Exception, System.ApplicationException or some other base exception? ...

Arithmetic underflow or overflow exception during debugging

This is the day of weird behavior. We have a Win32 project made with Delphi 2007, which hosts the .NET runtime and calls into .NET to show new forms, as part of a transition period. Recently we've begun experiencing exceptions at seemingly random locations and points of our code: Arithmetic overflow or underflow. The stack trace of on...

In C#, how can I rethrow InnerException without losing stack trace?

I am calling, through reflection, a method which may cause an exception. How can I pass the exception to my caller without the wrapper reflection puts around it? I am rethrowing the InnerException, but this destroys the stack trace. Example code: public void test1() { // Throw an exception for testing purposes th...

BufferedGraphicsContext Error

I am getting the below error and call stack at the same time everyday after several hours of application use. Can anyone shed some light on what is happening? System.InvalidOperationException: BufferedGraphicsContext cannot be disposed of because a buffer operation is currently in progress. at System.Drawing.BufferedGraphicsContext.Dis...

Does re.compile() or any given Python library call throw an exception?

I can't tell from the Python documentation whether the re.compile(x) function may throw an exception (assuming you pass in a string). I imagine there is something that could be considered an invalid regular expression. The larger question is, where do I go to find if a given Python library call may throw exception(s) and what those are? ...

Avoiding first chance exception messages when the exception is safely handled

The following bit of code catches the EOS Exception using (var reader = new BinaryReader(httpRequestBodyStream)) { try { while (true) { bodyByteList.Add(reader.ReadByte()); } } catch (EndOfStreamException) { } } So why do I still receive first-chance exceptions in my console? A first chance ex...

In PHP5, should I use Exceptions or trigger_error/set_error_handler ?

What are the pros/cons of doing either way. Is there One Right Way(tm) ? ...

How to get entire chain of Exceptions in Application.ThreadException event handler?

I was just working on fixing up exception handling in a .NET 2.0 app, and I stumbled onto some weird issue with Application.ThreadException. What I want is to be able to catch all exceptions from events behind GUI elements (e.g. button_Click, etc.). I then want to filter these exceptions on 'fatality', e.g. with some types of Exceptions...

C++ Exception code lookup

Knowing an exception code, is there a way to find out more about what the actual exception that was thrown means? My exception in question: 0x64487347 Exception address: 0x1 The call stack shows no information. I'm reviewing a .dmp of a crash and not actually debugging in Visual Studio. ...

ASP.NET WebService Returns Gibberish Characters When Throwing Exceptions

Greetings! I have a web service (ASMX) and in it, a web method that does some work and throws an exception if the input wasn't valid. [ScriptMethod] [WebMethod] public string MyWebMethod(string input) { string l_returnVal; if (!ValidInput(input)) { string l_errMsg = System.Web.HttpUtility.HtmlEncode(GetErrorMessage...