.NET Questions and Solutions

As a software engineer, I focus on .NET, especially asp.net, C#, WCF and so on, and I am also very interested in Search Engine Optimization.

Entries Tagged ‘unhandled exception’

BUG: You receive an error message when you serialize a DBConcurrencyException object in ADO.NET 1.0

Symptoms
When you serialize a DBConcurrencyException object, the value of the Row property in the serialized version of the object is set to a null value and an exception occurs:

An unhandled exception of type ‘System.NullReferenceException’ occurred in app_name.exe
Additional information: Object reference not set to an instance of an object.
Resolution
Serialization support is not provided for DataRows in this version of Microsoft Visual Studio .NET.

BUG: You receive a “Type mismatch” error message when you assign a value type variable to a property through COM InterOp in Visual Basic .NET or in Visual Basic 2005

Symptoms
When you assign a value to a property of a Component Object Model (COM) object in .NET, you may receive the following error message when you run your application:

An unhandled exception of type ‘System.Runtime.InteropServices.COMException’ occurred in InterOpDemo.exe
Additional information: Type mismatch
Resolution
The problem occurs if all of the following conditions are true: You are using the COM object in early bound mode.The property in the COM object has both Set and Let methods.You are trying to pass a value type variable to that property. In early bound mode, Microsoft Visual Basic .NET and Visual Basic 2005 always call the Set method of the property if it is available. If you want to call the Let method, you must explicitly specify it.

BUG: Unhandled exception filter not called inside debugger

Symptoms
Win32 processes can install an unhandled exception filter function to catchexceptions that are not handled in a __try/__except block on a process-widebasis. When debugging such a process, you find that the unhandled exceptionfilter is never executed, even when you put a breakpoint inside it.However, when the process is not being debugged, its unhandled exceptionfilter is called as expected.
Resolution
When called from a process being debugged, the UnhandledExceptionFilter()Win32 API function does not call the application-installed unhandledexception filter.
Note The UnhandledExceptionFilter() API determines whether the process is being debugged. If the process is being debugged, the UnhandledExceptionFilter API passes the exception to the debugger. Then, the UnhandledExceptionFilter API calls the unhandled exception filter for the process.

BUG: Unhandled exception error occurs when you enumerate through the Hashtable

Symptoms
In a Remoting scenario, you may try to move the Enumerator for a Hashtable from the server side to the client side. You do this so you can iterate through the Hashtable on the client side. While you are enumerating through the Hashtable, you may receive the following error message:

An unhandled exception of type ‘System.InvalidOperationException’ occurred in mscorlib.dll
Additional information: Collection was modified; enumeration operation may not execute.
Resolution
The error occurs because the Hashtable Enumerator is a MarshalByValue component. Therefore, the Hashtable stores the owner of the Hashtable internally. When you request the Hashtable on the client side, the Hashtable is deserialized on the client side. During deserialization, the internal Hashtable is reconstructed. Therefore, the enumerator fails.

BUG: PInvoke method with System.GUID return type raises exception error

Symptoms
When you run Platform Invocation Services (PInvoke) with System.GUID as the return type, the process is unsuccessful and you receive the following exception error message:

An unhandled exception of type ‘System.Runtime.InteropServices.MarshalDirectiveException’ occurred in TestPInvoke.exe Additional information: Method’s type signature is not PInvoke compatible.
Resolution
Microsoft has confirmed that this is a problem in Visual Studio .NET.

An unhandled exception of the ‘System.ArgumentException’ type occurs after you rename the columns of a DataSet object

Symptoms
After you rename the columns of a DataTable object in the DataSet, if you try to refer to the columns in case-insensitive manner, you receive the following exception:

An unhandled exception of type ‘System.ArgumentException’ occurred in system.data.dll
Additional information: Column ‘ColumnName’ does not belong to table ‘Tablename’.
Resolution
When you first create a column in a DataTable object of a DataSet, the name is added to two indexes: a case-sensitive index and a case-insensitive index. When you rename the column in a DataTable object, the new name is not added to the case-insensitive index. Therefore, when you rename a DataTable column, the ColumnName becomes case-sensitive.