Microsoft KB Archive/826220

= You receive an &quot;Access violation&quot; error message or a &quot;The memory could not be read&quot; error message when you quit a WinForm program =

Article ID: 826220

Article Last Modified on 5/21/2007

-

APPLIES TO

 Microsoft Office Web Components, when used with:  Microsoft Visual Studio .NET 2003 Academic Edition

 Microsoft Visual Studio .NET 2003 Enterprise Architect

 Microsoft Visual Studio .NET 2003 Enterprise Developer

 Microsoft Visual Studio .NET 2003 Professional Edition</li></ul>

 Microsoft Visual Studio .NET 2002 Academic Edition</li></ul>

 Microsoft Visual Studio .NET 2002 Enterprise Architect</li></ul>

 Microsoft Visual Studio .NET 2002 Enterprise Developer</li></ul>

 Microsoft Visual Studio .NET 2002 Professional Edition</li></ul>

 Microsoft .NET Framework 1.0</li></ul>

 Microsoft .NET Framework 1.1</li></ul> </li></ul>

-

<div class="notice_section">

<div class="symptoms_section">

SYMPTOMS
When you quit a Windows Form (WinForm) program that was created in either Microsoft Visual Studio .NET (2002) or Microsoft Visual Studio .NET (2003), you may receive one of the following error messages:

Unhandled exception at 0x77f87e4b (NTDLL.DLL) in [ApplicationName]: 0xC0000005: Access violation reading location 0x00000324.

-or-

The instruction at &quot;0x77f87e4b&quot; referenced memory at &quot;0x00000324&quot;. The memory could not be &quot;read&quot;. Click on OK to terminate the program.

<div class="cause_section">

CAUSE
This problem may occur when both of the following conditions are true:
 * Your display color quality is set to 256 colors.
 * The WinForm program contains a Microsoft Office XP Web Component control.

<div class="workaround_section">

WORKAROUND
To work around this problem, use one of the following methods.

Method 1: Change Your Display Settings
Change your display settings to run in a mode that is higher than (8-bit) 256 color. To do this, follow these steps:
 * 1) Click Start, and then click Control Panel.
 * 2) Click Appearance and Themes.
 * 3) Click Display.
 * 4) On the Settings tab, change the color quality to a higher setting (for example, Highest (32 bit)).
 * 5) Click OK to close the Display Properties dialog box.

Method 2: Run the Managed Code from an Unmanaged Loader
The loader handles process startup and shutdown and can load and unload the Office Web Components and GDIPlus together in an orderly fashion.

For more information, visit the following Microsoft Web site:

http://msdn2.microsoft.com/en-us/library/9x0wh2z3(vs.71).aspx

Method 3: Unload the Office Web Components Before Unloading GDIPlus
Close all open WinForms, close the Office Web Components, and then close GDIPlus. To do this, add a static Main function to your .NET program, and then add additional code such as the following:

Microsoft provides programming examples for illustration only, without warranty either expressed or implied. This includes, but is not limited to, the implied warranties of merchantability or fitness for a particular purpose. This article assumes that you are familiar with the programming language that is being demonstrated and with the tools that are used to create and to debug procedures. Microsoft support engineers can help explain the functionality of a particular procedure, but they will not modify these examples to provide added functionality or construct procedures to meet your specific requirements. <DllImport(&quot;kernel32.dll&quot;, EntryPoint:=&quot;GetModuleHandle&quot;, _          SetLastError:=True, CharSet:=CharSet.Auto,            CallingConvention:=CallingConvention.StdCall)> _ Public Overloads Shared Function GetModuleHandle(ByVal sLibName As String) As IntPtr End Function

<DllImport(&quot;kernel32.dll&quot;, EntryPoint:=&quot;FreeLibrary&quot;, _       SetLastError:=True, CallingConvention:=CallingConvention.StdCall)> _ Public Overloads Shared Function FreeLibrary(ByVal hMod As IntPtr) As Integer End Function

<STAThread> Public Overloads Shared Sub Main Dim hOwcHandle As IntPtr System.Windows.Forms.Application.Run(New frmMainForm) GC.Collect(2) ' Try to free if all instances were finalized already. ' If OWC is still around, then force unload it before exit. hOwcHandle = GetModuleHandle(&quot;owc10.dll&quot;) If Not hOwcHandle.Equals(IntPtr.Zero) Then FreeLibrary(hOwcHandle) End Sub

<div class="status_section">

STATUS
Microsoft has confirmed that this is a problem in the Microsoft products that are listed in the &quot;Applies to&quot; section.

Additional query words: OfficeQFE 8995 OWC10

Keywords: kbvs2002sp1sweep kbbug kberrmsg kbprb KB826220

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.