.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 ‘microsoft net framework 2’

FIX: A NullReferenceException exception may occur when you set the Table property of a DataView object in a .NET Framework 2.0 application

Symptoms
Consider the following scenario in a Microsoft .NET Framework 2.0 application:You set a DataTable object for the Table property of a DataView object.The DataTable object that you use contains fewer rows than the DataTable object that was previously set for the Table property. The DataView object is bound to a DataGrid object.In this scenario, a NullReferenceException exception may occur.
Resolution
This problem occurs because the DataView object raises a ListChanged event before the DataView object has completed the transition to the new DataTable object.The DataView object tries to access the index for a DataRow object. However, that index is no longer valid because the Table property is set to a different DataTable object.

FIX: A NullReferenceException error occurs when you run a .NET Framework 2.0 program

Symptoms
When you run a Microsoft .NET Framework 2.0 program, aNullReferenceException error occurs, or you receive an access violation error message. If you debug the crash, you find an access violation in the MSCORJIT!emitter::emitJumpDistBind function.
Resolution
This problem occurs because of an optimization bug in the just-in-time (JIT) compiler.

FIX: A .NET Framework 2.0-based application may experience an ArgumentNullException exception and may exit unexpectedly

Symptoms
When you run a Microsoft .NET Framework 2.0-based application, the application may experience an ArgumentNullException exception and may exit unexpectedly (crash).
Resolution
This problem occurs because the FileSystemWatcher class throws an unhandled ArgumentNullException exception. This exception is generated because a race condition occurs between events that raise loops and the StopRaisingEvents method.

Binary serialization exceptions occur when you serialize or deserialize the DateTimeFormatInfo class or the TextInfo class between different versions of the .NET Framework

Symptoms
When you serialize or deserialize the DateTimeFormatInfo class or the TextInfo class between a computer that is running the Microsoft .NET Framework 2.0 Service Pack 1 (SP1) and a computer that is running a pre-SP1 version of the .NET Framework 2.0, you receive one of the following binary serialization exceptions:
Exception 1

Exception type: System.Runtime.Serialization.Serialization
ExceptionMessage: Binary stream ‘0′ does not contain a valid BinaryHeader. Possible causes are invalid stream or object version change between serialization and deserialization.Exception 2

Exception type: System.ArgumentNull
ExceptionMessage: Value cannot be null.This problem occurs when you serializethe DateTimeFormatInfo class and the TextInfo class by setting the TypeFormat property of the BinaryFormatter class to FormatterTypeStyle.XsdString.
Resolution
This problem occurs because the FormatterTypeStyle.XsdString serialization formatting and the FormatterTypeStyle.TypesWhenNeeded serialization formatting drop type information for performance reasons when you serialize types across different versions of the .NET Framework.