tagged [exception]

Why does the inner exception reach the ThreadException handler and not the actual thrown exception?

Why does the inner exception reach the ThreadException handler and not the actual thrown exception? I'm seeing some wierd behaviour when throwing exceptions and catching them in the `Application.Threa...

7 Dec at 11:57

Where can I find a list of SocketErrorCode and NativeErrorCode thrown by SocketException?

Where can I find a list of SocketErrorCode and NativeErrorCode thrown by SocketException? A SocketException has a SocketErrorCode and NativeErrorCode. I would like to find a list where these codes (or...

8 Dec at 22:12

How to Trace all local variables when an exception occurs

How to Trace all local variables when an exception occurs any generic way to trace/log values of all local variables when an exception occurs in a method? (in C# 3)

12 Dec at 10:51

Why wasn't the Java "throws" clause (in method declaration) included in C#?

Why wasn't the Java "throws" clause (in method declaration) included in C#? Why wasn't the Java "throws" clause (in method declaration) included in C#?

Handling unhandled exceptions problem

Handling unhandled exceptions problem I wanted to set some handler for all the unexpected exceptions that I might not have caught inside my code. In `Program.Main()` I used the following code: But it ...

2 Jan at 09:56

Thread was being aborted when exporting to excel?

Thread was being aborted when exporting to excel? I have a DataTable which is bound to a GridView. I also have a button that when clicked exports the DataTable to an Excel file. However, the following...

7 Jan at 17:40

Is this a bad practice to catch a non-specific exception such as System.Exception? Why?

Is this a bad practice to catch a non-specific exception such as System.Exception? Why? I am currently doing a code review and the following code made me jump. I see multiple issues with this code. Do...

8 Jan at 23:7

Puzzling Enumerable.Cast InvalidCastException

Puzzling Enumerable.Cast InvalidCastException The following throws an `InvalidCastException`. Why? I'm using Visual Studio 2008 SP1.

15 Jan at 03:19

In C#, how can I serialize System.Exception? (.Net CF 2.0)

In C#, how can I serialize System.Exception? (.Net CF 2.0) I want to write an Exception to an MS Message Queue. When I attempt it I get an exception. So I tried simplifying it by using the XmlSerializ...

What is the best way to communicate that your constructor has failed in C#?

What is the best way to communicate that your constructor has failed in C#? In C# I want to communicate to the calling method that the parameters passed to an object have caused its instantiation to f...

23 Jan at 01:39

Should Exception Messages be Globalized

Should Exception Messages be Globalized I'm working on a project and I'm just starting to do all the work necessary to globalize the application. One thing that comes up quite often is whether to glob...

23 Jan at 20:46

Where Should Exception Messages be Stored

Where Should Exception Messages be Stored Since I can't use Microsoft as an example for best practice since their exception messages are stored in resource files out of necessity, I am forced to ask w...

23 Jan at 21:23

Do I need to create my own InvalidArgumentException.. I couldn't find any builtin type in c#

Do I need to create my own InvalidArgumentException.. I couldn't find any builtin type in c# Do I need to create my own InvalidArgumentException.. I couldn't find any built-in types in c#... Is there ...

26 Jan at 20:42

ASP.NET Access to the temp directory is denied

ASP.NET Access to the temp directory is denied I'm experiencing this problem today on many different servers. The servers were not touched recently. The only thing that comes in my mind is a windows u...

12 Feb at 17:2

What's the essential difference between the two HandleException() methods of Exception Handling Application Block (Ent Lib 4.1)

What's the essential difference between the two HandleException() methods of Exception Handling Application Block (Ent Lib 4.1) In the most recent version (4.1, released October 2008) of The Microsoft...

13 Feb at 21:3

Why use finally in C#?

Why use finally in C#? Whatever is inside finally blocks is executed (almost) always, so what's the difference between enclosing code into it or leaving it unclosed?

13 Feb at 21:36

NHibernate - not-null property reference a null or transient value

NHibernate - not-null property reference a null or transient value I'm getting this exception (Full exception at the bottom): ``` NHibernate.PropertyValueException was unhandled by user code Message="...

Can you set VS2008 to break on an error inside a try-catch statement

Can you set VS2008 to break on an error inside a try-catch statement One of the things I loved about VB6 is that you had the ability to tell the development environment to break on all errors regardle...

How to handle general exceptions in Asp.Net MVC?

How to handle general exceptions in Asp.Net MVC? I want to transfer all unhandled exceptions to an error page in Asp.Net MVC. What is the way to handle the unhandled exceptions in Asp.net MVC? Is ther...

6 Mar at 11:36

What exception to throw from a property setter?

What exception to throw from a property setter? I have a string property that has a maximum length requirement because the data is linked to a database. What exception should I throw if the caller tri...

11 Mar at 10:19

"Exception has been thrown by the target of an invocation" error (mscorlib)

"Exception has been thrown by the target of an invocation" error (mscorlib) I have a website developed in ASP.Net 2.0 that is throwing the error in the production environment. It was not throwing this...

16 Mar at 13:7

C# Image.Clone Out of Memory Exception

C# Image.Clone Out of Memory Exception Why am I getting an out of memory exception? So this dies in C# on the first time through: Where splitBitmaps is a List BUT this works in VB for at least 4 iter...

18 Mar at 12:56

The difference between re-throwing parameter-less catch and not doing anything?

The difference between re-throwing parameter-less catch and not doing anything? Suppose I have the following two classes in two different assemblies: ``` //in assembly A public class TypeA { // Const...

4 Apr at 17:50

C# "Using" Syntax

C# "Using" Syntax Does the using catch the exception or throw it? i.e. If the streamreader throws an exception is it caught by using or thrown so the calling function can handle it?

11 Apr at 21:52

Will code in a Finally statement fire if I return a value in a Try block?

Will code in a Finally statement fire if I return a value in a Try block? I'm reviewing some code for a friend and say that he was using a return statement inside of a try-finally block. Does the code...

16 Apr at 14:16