F
Frank Sharp
VS 2005, Office 2003:
When showing a form with a Datagrid or Datagridview in an Office AddIn
(Outlook, Excel, Word) I always get an AccessViolationException (Attempted
to read or write protected memory...) in System.Drawing.
This problem started about 2 weeks ago in an AddIn that worked for 2 years
now. So I guess it must have something to do with an Office Update or any
other update. I just can't remember of any other update in my System. It
also happens just on one of my PC's.
I used a ComShim for this AddIn, but I also tried it with VSTO. It has
nothing to do with specific code in my existing AddIn because I also created
a simple AddIn with just a form and a DatagridView and no code behind. As
soon as System.Drawing tries to paint the grid I get an
Accessviolationexception.
Standalone Windows-Form projects have no problems with Datagrids or
Datagridviews.
I would be very happy for any suggestions because I spent already days to
find a solution for this problem.
Below is a call stack of the exception (with german language pack) from a
simple ExcelAddIn with just a Datagridview that I created for testing
(created with VSTO SE, but the problem is the same if I use a ComShim, the
same if I write an AddIn for Excel or Outlook..; I just installed VSTO to
see if there is a difference in behavior..).
Thanks a lot for any ideas.
Frank
Es wurde versucht, im geschützten Speicher zu lesen oder zu schreiben. Dies
ist häufig ein Hinweis darauf, dass anderer Speicher beschädigt ist.
************** Ausnahmetext **************
System.AccessViolationException: Es wurde versucht, im geschützten Speicher
zu lesen oder zu schreiben. Dies ist häufig ein Hinweis darauf, dass anderer
Speicher beschädigt ist.
bei System.Drawing.SafeNativeMethods.Gdip.GdipDrawRectangleI(HandleRef
graphics, HandleRef pen, Int32 x, Int32 y, Int32 width, Int32 height)
bei System.Drawing.Graphics.DrawRectangle(Pen pen, Int32 x, Int32 y,
Int32 width, Int32 height)
bei System.Windows.Forms.Control.PaintException(PaintEventArgs e)
bei System.Windows.Forms.Control.PaintWithErrorHandling(PaintEventArgs e,
Int16 layer, Boolean disposeEventArgs)
bei System.Windows.Forms.Control.WmPaint(Message& m)
bei System.Windows.Forms.Control.WndProc(Message& m)
bei System.Windows.Forms.DataGridView.WndProc(Message& m)
bei System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message&
m)
bei System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
bei System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg,
IntPtr wparam, IntPtr lparam)
************** Geladene Assemblys **************
mscorlib
Assemblyversion: 2.0.0.0
Win32-Version: 2.0.50727.42 (RTM.050727-4200)
CodeBase:
file:///C:/WINDOWS/Microsoft.NET/Framework/v2.0.50727/mscorlib.dll
----------------------------------------
Microsoft.VisualStudio.Tools.Applications.Runtime
Assemblyversion: 8.0.0.0
Win32-Version: 8.0.50727.816
CodeBase:
file:///C:/WINDOWS/assembly/GAC_MSIL/Microsoft.VisualStudio.Tools.Applications.Runtime/8.0.0.0__b03f5f7f11d50a3a/Microsoft.VisualStudio.Tools.Applications.Runtime.dll
----------------------------------------
Microsoft.Office.Tools.Common
Assemblyversion: 8.0.0.0
Win32-Version: 8.0.50727.816
CodeBase:
file:///C:/WINDOWS/assembly/GAC_MSIL/Microsoft.Office.Tools.Common/8.0.0.0__b03f5f7f11d50a3a/Microsoft.Office.Tools.Common.dll
----------------------------------------
System
Assemblyversion: 2.0.0.0
Win32-Version: 2.0.50727.42 (RTM.050727-4200)
CodeBase:
file:///C:/WINDOWS/assembly/GAC_MSIL/System/2.0.0.0__b77a5c561934e089/System.dll
----------------------------------------
System.Windows.Forms
Assemblyversion: 2.0.0.0
Win32-Version: 2.0.50727.42 (RTM.050727-4200)
CodeBase:
file:///C:/WINDOWS/assembly/GAC_MSIL/System.Windows.Forms/2.0.0.0__b77a5c561934e089/System.Windows.Forms.dll
----------------------------------------
GridTestWord
Assemblyversion: 1.0.0.0
Win32-Version: 1.0.0.0
CodeBase:
file:///C:/Dokumente%20und%20Einstellungen/My.Name/Eigene%20Dateien/Visual%20Studio%202005/Projects/GridTestWord/GridTestWord/bin/Debug/GridTestWord.DLL
----------------------------------------
Microsoft.Office.Interop.Word
Assemblyversion: 11.0.0.0
Win32-Version: 11.0.5530
CodeBase:
file:///C:/WINDOWS/assembly/GAC/Microsoft.Office.Interop.Word/11.0.0.0__71e9bce111e9429c/Microsoft.Office.Interop.Word.dll
----------------------------------------
System.Drawing
Assemblyversion: 2.0.0.0
Win32-Version: 2.0.50727.42 (RTM.050727-4200)
CodeBase:
file:///C:/WINDOWS/assembly/GAC_MSIL/System.Drawing/2.0.0.0__b03f5f7f11d50a3a/System.Drawing.dll
----------------------------------------
System.Data
Assemblyversion: 2.0.0.0
Win32-Version: 2.0.50727.42 (RTM.050727-4200)
CodeBase:
file:///C:/WINDOWS/assembly/GAC_32/System.Data/2.0.0.0__b77a5c561934e089/System.Data.dll
----------------------------------------
System.Xml
Assemblyversion: 2.0.0.0
Win32-Version: 2.0.50727.42 (RTM.050727-4200)
CodeBase:
file:///C:/WINDOWS/assembly/GAC_MSIL/System.Xml/2.0.0.0__b77a5c561934e089/System.Xml.dll
----------------------------------------
Accessibility
Assemblyversion: 2.0.0.0
Win32-Version: 2.0.50727.42 (RTM.050727-4200)
CodeBase:
file:///C:/WINDOWS/assembly/GAC_MSIL/Accessibility/2.0.0.0__b03f5f7f11d50a3a/Accessibility.dll
----------------------------------------
System.Windows.Forms.resources
Assemblyversion: 2.0.0.0
Win32-Version: 2.0.50727.42 (RTM.050727-4200)
CodeBase:
file:///C:/WINDOWS/assembly/GAC_MSIL/System.Windows.Forms.resources/2.0.0.0_de_b77a5c561934e089/System.Windows.Forms.resources.dll
----------------------------------------
Microsoft.VisualBasic
Assemblyversion: 8.0.0.0
Win32-Version: 8.0.50727.42 (RTM.050727-4200)
CodeBase:
file:///C:/WINDOWS/assembly/GAC_MSIL/Microsoft.VisualBasic/8.0.0.0__b03f5f7f11d50a3a/Microsoft.VisualBasic.dll
----------------------------------------
Microsoft.VisualStudio.Tools.Applications.Runtime.resources
Assemblyversion: 8.0.0.0
Win32-Version: 8.0.50727.42
CodeBase:
file:///C:/WINDOWS/assembly/GAC_MSIL/Microsoft.VisualStudio.Tools.Applications.Runtime.resources/8.0.0.0_de_b03f5f7f11d50a3a/Microsoft.VisualStudio.Tools.Applications.Runtime.resources.dll
----------------------------------------
When showing a form with a Datagrid or Datagridview in an Office AddIn
(Outlook, Excel, Word) I always get an AccessViolationException (Attempted
to read or write protected memory...) in System.Drawing.
This problem started about 2 weeks ago in an AddIn that worked for 2 years
now. So I guess it must have something to do with an Office Update or any
other update. I just can't remember of any other update in my System. It
also happens just on one of my PC's.
I used a ComShim for this AddIn, but I also tried it with VSTO. It has
nothing to do with specific code in my existing AddIn because I also created
a simple AddIn with just a form and a DatagridView and no code behind. As
soon as System.Drawing tries to paint the grid I get an
Accessviolationexception.
Standalone Windows-Form projects have no problems with Datagrids or
Datagridviews.
I would be very happy for any suggestions because I spent already days to
find a solution for this problem.
Below is a call stack of the exception (with german language pack) from a
simple ExcelAddIn with just a Datagridview that I created for testing
(created with VSTO SE, but the problem is the same if I use a ComShim, the
same if I write an AddIn for Excel or Outlook..; I just installed VSTO to
see if there is a difference in behavior..).
Thanks a lot for any ideas.
Frank
Es wurde versucht, im geschützten Speicher zu lesen oder zu schreiben. Dies
ist häufig ein Hinweis darauf, dass anderer Speicher beschädigt ist.
************** Ausnahmetext **************
System.AccessViolationException: Es wurde versucht, im geschützten Speicher
zu lesen oder zu schreiben. Dies ist häufig ein Hinweis darauf, dass anderer
Speicher beschädigt ist.
bei System.Drawing.SafeNativeMethods.Gdip.GdipDrawRectangleI(HandleRef
graphics, HandleRef pen, Int32 x, Int32 y, Int32 width, Int32 height)
bei System.Drawing.Graphics.DrawRectangle(Pen pen, Int32 x, Int32 y,
Int32 width, Int32 height)
bei System.Windows.Forms.Control.PaintException(PaintEventArgs e)
bei System.Windows.Forms.Control.PaintWithErrorHandling(PaintEventArgs e,
Int16 layer, Boolean disposeEventArgs)
bei System.Windows.Forms.Control.WmPaint(Message& m)
bei System.Windows.Forms.Control.WndProc(Message& m)
bei System.Windows.Forms.DataGridView.WndProc(Message& m)
bei System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message&
m)
bei System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
bei System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg,
IntPtr wparam, IntPtr lparam)
************** Geladene Assemblys **************
mscorlib
Assemblyversion: 2.0.0.0
Win32-Version: 2.0.50727.42 (RTM.050727-4200)
CodeBase:
file:///C:/WINDOWS/Microsoft.NET/Framework/v2.0.50727/mscorlib.dll
----------------------------------------
Microsoft.VisualStudio.Tools.Applications.Runtime
Assemblyversion: 8.0.0.0
Win32-Version: 8.0.50727.816
CodeBase:
file:///C:/WINDOWS/assembly/GAC_MSIL/Microsoft.VisualStudio.Tools.Applications.Runtime/8.0.0.0__b03f5f7f11d50a3a/Microsoft.VisualStudio.Tools.Applications.Runtime.dll
----------------------------------------
Microsoft.Office.Tools.Common
Assemblyversion: 8.0.0.0
Win32-Version: 8.0.50727.816
CodeBase:
file:///C:/WINDOWS/assembly/GAC_MSIL/Microsoft.Office.Tools.Common/8.0.0.0__b03f5f7f11d50a3a/Microsoft.Office.Tools.Common.dll
----------------------------------------
System
Assemblyversion: 2.0.0.0
Win32-Version: 2.0.50727.42 (RTM.050727-4200)
CodeBase:
file:///C:/WINDOWS/assembly/GAC_MSIL/System/2.0.0.0__b77a5c561934e089/System.dll
----------------------------------------
System.Windows.Forms
Assemblyversion: 2.0.0.0
Win32-Version: 2.0.50727.42 (RTM.050727-4200)
CodeBase:
file:///C:/WINDOWS/assembly/GAC_MSIL/System.Windows.Forms/2.0.0.0__b77a5c561934e089/System.Windows.Forms.dll
----------------------------------------
GridTestWord
Assemblyversion: 1.0.0.0
Win32-Version: 1.0.0.0
CodeBase:
file:///C:/Dokumente%20und%20Einstellungen/My.Name/Eigene%20Dateien/Visual%20Studio%202005/Projects/GridTestWord/GridTestWord/bin/Debug/GridTestWord.DLL
----------------------------------------
Microsoft.Office.Interop.Word
Assemblyversion: 11.0.0.0
Win32-Version: 11.0.5530
CodeBase:
file:///C:/WINDOWS/assembly/GAC/Microsoft.Office.Interop.Word/11.0.0.0__71e9bce111e9429c/Microsoft.Office.Interop.Word.dll
----------------------------------------
System.Drawing
Assemblyversion: 2.0.0.0
Win32-Version: 2.0.50727.42 (RTM.050727-4200)
CodeBase:
file:///C:/WINDOWS/assembly/GAC_MSIL/System.Drawing/2.0.0.0__b03f5f7f11d50a3a/System.Drawing.dll
----------------------------------------
System.Data
Assemblyversion: 2.0.0.0
Win32-Version: 2.0.50727.42 (RTM.050727-4200)
CodeBase:
file:///C:/WINDOWS/assembly/GAC_32/System.Data/2.0.0.0__b77a5c561934e089/System.Data.dll
----------------------------------------
System.Xml
Assemblyversion: 2.0.0.0
Win32-Version: 2.0.50727.42 (RTM.050727-4200)
CodeBase:
file:///C:/WINDOWS/assembly/GAC_MSIL/System.Xml/2.0.0.0__b77a5c561934e089/System.Xml.dll
----------------------------------------
Accessibility
Assemblyversion: 2.0.0.0
Win32-Version: 2.0.50727.42 (RTM.050727-4200)
CodeBase:
file:///C:/WINDOWS/assembly/GAC_MSIL/Accessibility/2.0.0.0__b03f5f7f11d50a3a/Accessibility.dll
----------------------------------------
System.Windows.Forms.resources
Assemblyversion: 2.0.0.0
Win32-Version: 2.0.50727.42 (RTM.050727-4200)
CodeBase:
file:///C:/WINDOWS/assembly/GAC_MSIL/System.Windows.Forms.resources/2.0.0.0_de_b77a5c561934e089/System.Windows.Forms.resources.dll
----------------------------------------
Microsoft.VisualBasic
Assemblyversion: 8.0.0.0
Win32-Version: 8.0.50727.42 (RTM.050727-4200)
CodeBase:
file:///C:/WINDOWS/assembly/GAC_MSIL/Microsoft.VisualBasic/8.0.0.0__b03f5f7f11d50a3a/Microsoft.VisualBasic.dll
----------------------------------------
Microsoft.VisualStudio.Tools.Applications.Runtime.resources
Assemblyversion: 8.0.0.0
Win32-Version: 8.0.50727.42
CodeBase:
file:///C:/WINDOWS/assembly/GAC_MSIL/Microsoft.VisualStudio.Tools.Applications.Runtime.resources/8.0.0.0_de_b03f5f7f11d50a3a/Microsoft.VisualStudio.Tools.Applications.Runtime.resources.dll
----------------------------------------