Article ID: 953102 - View products that this article applies to.
RAPID PUBLISHING ARTICLES PROVIDE INFORMATION DIRECTLY FROM WITHIN THE MICROSOFT SUPPORT ORGANIZATION. THE INFORMATION CONTAINED HEREIN IS CREATED IN RESPONSE TO EMERGING OR UNIQUE TOPICS, OR IS INTENDED SUPPLEMENT OTHER KNOWLEDGE BASE INFORMATION.
You have developed a Microsoft .NET Framework 2.0 Windows Forms application which contains a ToolTip control and a Treeview control. The application calls the ToolTip control’s SetToolTip method multiple times, for example, in the MouseMove event of the TreeView Control; and passes the Treeview control as the first parameter to the SetToolTip method.
When hovering the mouse over a Node in the TreeView control, the ToolTip may not display all the text specified in the SetToolTip method. When exiting the application, you may also receive the following error:
Unhandled exception has occurred in your application. If you click Continue, the application will ignore this error and attempt to continue. If you click Quit, the application will close immediately.
Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
System.AccessViolationException: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
at System.Environment.GetResourceFromDefault(String key)
at System.ObjectDisposedException..ctor(String objectName)
at System.Windows.Forms.Control.Dispose(Boolean disposing)
at System.Windows.Forms.Form.Dispose(Boolean disposing)
at WindowsFormsApplication1.Form1.Dispose(Boolean disposing) in C:\Projects\WindowsFormsApplication1\WindowsFormsApplication1\Form1.Designer.cs:line 20
at System.Windows.Forms.Form.WmClose(Message& m)
at System.Windows.Forms.Form.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
If you are debugging the application in Visual Studio, you may receive the following MDA error when exiting instead of the System.AccessViolationException above.
FatalExecutionEngineError was detected
The runtime has encountered a fatal error. The address of the error was at <address>, on thread <thread>. The error code is 0xc0000005. This error may be a bug in the CLR or in the unsafe or non-verifiable portions of user code. Common sources of this bug include user marshaling errors for COM-interop or PInvoke, which may corrupt the stack.
The TreeView control's ShowNodeToolTips property is set to True to enable built-in tooltips for the nodes in the TreeView control. This conflicts with the tooltip being created by the ToolTip control's SetToolTip method.
You can use one of the following solutions to work around this problem.
1. Set the TreeView control's ShowNodeToolTips property to False. This is the easiest solution if the intent is to use the ToolTip control for displaying ToolTips instead of the TreeView control's built-in Node ToolTips (the ToolTip control has some additional features not exposed by the TreeView control's ToolTip implementation).
2. Alternatively, you can remove the call to the ToolTip control's SetToolTip method, and use the TreeView control's built-in ToolTips. To do this, you must make sure that the TreeView control's ShowNodeToolTips property is set to True, and that you have set each TreeNode's ToolTipText property to the desired value.
STEPS TO REPRODUCE
1. Using Visual Studio 2005 or Visual Studio 2008, create a new C# Windows Forms application.
2. Add a TreeView control to the form named "treeView1".
3. Set the TreeView control's ShowNodeToolTips property to True.
4. Add a ToolTip control to the form named "toolTip1".
5. Add the following code to the form's Load event handler:
private void Form1_Load(object sender, EventArgs e)
for (int i = 0; i < 10; i++)
TreeNode newNode = new TreeNode();
newNode.Text = "test node " + i.ToString();
newNode.Tag = i.ToString();
6. Add the following code to the MouseMove event handler of the TreeView control:
private void treeView1_MouseMove(object sender, MouseEventArgs e)
TreeView tv = sender as TreeView;
if (tv != null)
TreeNode tn = tv.GetNodeAt(new Point(e.X, e.Y));
if (tn != null)
7. Build the application and run it.
8. Hover the mouse over several nodes in the TreeView control.
9. Close the form to exit the application.
You should receive one of the errors listed in the Result section above.
When running the application under a native code debugger, you may also see an Access Violation occurring in the following call stack.
System_Windows_Forms_ni!System.Windows.Forms.NativeWindow.Callback(IntPtr, Int32, IntPtr, IntPtr)+0x5a
MICROSOFT AND/OR ITS SUPPLIERS MAKE NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY, RELIABILITY OR ACCURACY OF THE INFORMATION CONTAINED IN THE DOCUMENTS AND RELATED GRAPHICS PUBLISHED ON THIS WEBSITE (THE “MATERIALS”) FOR ANY PURPOSE. THE MATERIALS MAY INCLUDE TECHNICAL INACCURACIES OR TYPOGRAPHICAL ERRORS AND MAY BE REVISED AT ANY TIME WITHOUT NOTICE.
TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW, MICROSOFT AND/OR ITS SUPPLIERS DISCLAIM AND EXCLUDE ALL REPRESENTATIONS, WARRANTIES, AND CONDITIONS WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING BUT NOT LIMITED TO REPRESENTATIONS, WARRANTIES, OR CONDITIONS OF TITLE, NON INFRINGEMENT, SATISFACTORY CONDITION OR QUALITY, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, WITH RESPECT TO THE MATERIALS.
Contact us for more help
Connect with Answer Desk for expert help.