.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 ‘NET’

Description of the .NET Framework 1.1 post-Service Pack 1 hotfix rollup package for System.windows.forms.dll

Symptoms
This article describesthe Microsoft.NET Framework 1.1 issues that are fixed in the .NET Framework 1.1 post-Service Pack 1 hotfix rollup package for System.windows.forms.dll.
Issues that are fixed in the hotfix packageFor more information, click the following article number to view the article in the Microsoft Knowledge Base:
875434?(http://support.microsoft.com/kb/875434/) FIX: You receive a NullReferenceException exception when you manually set a Control ID in the .NET Framework 1.1
840503?(http://support.microsoft.com/kb/840503/) FIX: The scroll bar may not show the correct position in a spreadsheet in a Windows Forms application in the Microsoft .NET Framework 1.1
841096?(http://support.microsoft.com/kb/841096/) Validation event does not fire for Microsoft Windows Forms controls
873429?(http://support.microsoft.com/kb/873429/) FIX: A gradual memory leak occurs in a WinForm application when you create, modify, or remove a MenuItem property for an MDI form in the .NET Framework 1.1
884579?(http://support.microsoft.com/kb/884579/) FIX: The Click event for a button in a UserControl control occurs even though another UserControl control is set to cancel form validation in a Microsoft Windows Forms application that is built on the Microsoft .NET Framework 1.1
886802?(http://support.microsoft.com/kb/886802/) FIX: You may receive the “AxImp error object reference not set to an instance of an object” error message when you run AxImp.exe on an ActiveX control in the .NET Framework 1.1
886686?(http://support.microsoft.com/kb/886686/) FIX: You can close a form by using the Close button even if the Cancel property of a Validating event is set to True on an object in a Windows Forms application in the .NET Framework 1.1
885446?(http://support.microsoft.com/kb/885446/) FIX: You may experience unexpected behavior when you press TAB or ENTER in a Windows Form on a computer that is running the .NET Framework 1.1 S885446
Resolution
Hotfix informationA supported hotfix is now available from Microsoft, but it is only intended to correct the problem that is described in this article. Only apply it to systems that are experiencing this specific problem. This hotfix may receive additional testing. Therefore, if you are not severely affected by this problem, we recommend that you wait for the next .NET Framework 1.1 service pack that contains this hotfix.
To resolve this problem immediately, contact Microsoft Product Support Services to obtain the hotfix. For a complete list of Microsoft Product Support Services telephone numbers and information about support costs, visit the following Microsoft Web site:
http://support.microsoft.com/contactus/?ws=support(http://support.microsoft.com/contactus/?ws=support)NoteIn special cases, charges that are ordinarily incurred for support calls may be canceled if a Microsoft Support Professional determines that a specific update will resolve your problem. The usual support costs will apply to additional support questions and issues that do not qualify for the specific update in question.PrerequisitesYou must have the.NET Framework 1.1 Service Pack 1 (SP1) installed to apply this hotfix.Restart informationYou do not have to restart your computer after you apply this hotfix.Hotfix replacement informationThis hotfix is not replaced by any later hotfix.Registry informationYou do not have to create or to modify any registry keys to activate any hotfixes that are contained in this package.Hotfix file informationThis hotfix contains only those files that you must have to correct the issues that this article lists. This hotfix may not contain of all the files that you must have to fully update a product to the latest build.
The English version of this hotfix has the file attributes (or later file attributes) that are listed in the following table. The dates and times for these files are listed in Coordinated Universal Time (UTC). When you view the file information, it is converted to local time. To find the difference between UTC and local time, use the Time Zone tab in the Date and Time tool in Control Panel.

DateTimeVersionSizeFile name———————————————————————07-Oct-200421:461.1.4322.20382,052,096System.windows.forms.dll

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: An “Object reference not set to an instance of an object” error occurs when you try to access data by using ADO Interop on an ASP.NET page

Symptoms
On a computer that has Microsoft .NET Framework 1.0 installed (and that does not have Microsoft Visual Studio .NET installed), when you try to access data using ADO Interop on an ASP.NET page that resides at an identical site and that is hosted on the same computer, you may receive the following error message:

Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.
Resolution
To resolve this problem, register the Adodb.dll file in the global assembly cache (GAC). On a computer where only the .NET Framework is installed, the file Gacutil.exe does not exist.. Either obtain the gacutil file by installing Microsoft .NET Framework SDK, or create a Visual Studio.NET setup project that uses the installer to install the correct components.
To register Adodb.dll in the GAC, follow these steps: Click Start and then click Run. In the Run dialog box, type the following command, and then click OK:
C:\WINDOWS\Microsoft.NET\Framework\v1.0.3705\gacutil /i C:\Program Files\Microsoft.NET\Primary Interop Assemblies\adodb.dll

BUG: A BadImageFormatException exception may occur when you use a recursively defined constraint of a generic type in a .NET Framework 2.0-based application

Symptoms
In a Microsoft .NET Framework 2.0-based application, you use a recursively defined constraint ofa generic type. When you do this, a BadImageFormatException exception may occur at run time. This problem occurs only in certain scenarios.
Resolution
This problem occurs because of an issue in the Microsoft Visual Studio 2005 common language runtime (CLR 2.0) components.

BUG: “System.Runtime.Serialization.SerializationException” exception if you declare a static local variable in a method of a Visual Basic .NET or Visual Basic 2005 class and try to serialize the …

Symptoms
Microsoft Visual Basic .NET or Microsoft Visual Basic 2005 allows you to declare static local variables inside a method of class. However, if you declare a static local variable in a method of the Visual Basic .NET or Visual Basic 2005 class, and then you try to serialize the object of the class by using BinaryFormatter or SoapFormatter, you receive the following exception during run time:

An unhandled exception of type ‘System.Runtime.Serialization.SerializationException’ occurred in mscorlib.dll
Additional information: The type Microsoft.VisualBasic.CompilerServices.StaticLocalInitFlag in Assembly Microsoft.VisualBasic, Version=7.0.3300.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a is not marked as serialized.
Resolution
The common language runtime does not support static variables in methods. When Visual Basic .NET or Visual Basic 2005 compiler compiles your code, it translates this high-level Visual Basic .NET or Visual Basic 2005 code to Microsoft intermediate language (MSIL) code that the common language runtime can understand to give you shared variable functionality. Visual Basic .NET or Visual Basic 2005 uses the Microsoft.VisualBasic.CompilerServices.StaticLocalInitFlag class to provide this functionality. In Visual Basic .NET or in Visual Basic 2005 compiler, the StaticLocalInitFlag is not marked as serialized. Therefore, you receive the exception during run time.

BUG: “Index was out of range” error message when you access a Visual Basic .NET 2002 collection object that implements IList with -1 Base

Symptoms
When you use the IList interface with a Visual Basic .NET collection object in Visual Basic .NET (2002) before you use the Insert property, you can insert elements in the list at index -1. If you insert an element at index -1, you receive the following error message when you try to read the element by using the Item property at index -1:

System.ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection.
Resolution
The IList index has a base of -1 instead of zero. Therefore, you can insert an element at index -1 even though MSDN documentation states that the IList index is zero-based. However, you receive an error when you try to read the value from the IList at index -1.