I have written and tested a WinForms application and everything works fine on my machine (cliche, I know). When I created a setup project and installed it on a co-worker's machine, he receives the following message:
************** Exception Text **************
System.IndexOutOfRangeException: There is no row at position 0.
at System.Data.RBTree`1.GetNodeByIndex(Int32 userIndex)
at System.Data.RBTree`1.get_Item(Int32 index)
at System.Data.DataRowCollection.get_Item(Int32 index)
at MyApp.MainForm.MainForm_Load(Object sender, EventArgs e)
at System.Windows.Forms.Form.OnLoad(EventArgs e)
at System.Windows.Forms.Form.OnCreateControl()
at System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible)
at System.Windows.Forms.Control.CreateControl()
at System.Windows.Forms.Control.WmShowWindow(Message& m)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ScrollableControl.WndProc(Message& m)
at System.Windows.Forms.ContainerControl.WndProc(Message& m)
at System.Windows.Forms.Form.WmShowWindow(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)
I will admit I am a beginner when it comes to handling exceptions like this one. The text doesn't make a whole lot of sense to me and I'm unsure of the best way to debug this since I can't get the error to occur on my machine.
Can anyone tell what the problem is, or advise me on the best way to debug this? Any help is greatly appreciated!
Apparently you are using a DataRowCollection object on your main form load event handler, and this DataRowCollection object is empty (i.e. contains no rows). The form load event handler seems to assume that it will not be empty.
I suggest you set a breakpoint (F9) on the opening brace of MainForm_Load and step (F10 or F11) through your code until you find where the code tries to use the DataRowCollection.
Visual Studio has a remote debugging feature that is very nice. If you start the remote debugging host on the coworker's computer, then you can attach to that running process from within the IDE on your own machine. I have used this a couple of time with very good results.
http://msdn.microsoft.com/en-us/library/y7f5zaaa(VS.71).aspx
Sounds like a difference in the data - you're trying to access a node in a tree by index that doesn't exist...
You're creating a data row collection and accesing it with collection[0] without validating if it has at least one element to start with. Perhaps your coleague connects to an empty data store that has no rows?
Related
I have a program that I have been developing over time which has suddenly started throwing errors up when closing forms.
Normally when you debug the software if it throws up one of these errors you get taken to the code and you can find what the issue is, however for some reason this error does show in the debugger, through stepping through the code i have managed to narrow it down to when its calling the base.Dispose() on the form its closing, and only if its closed in a certain order.
I have a Main form, which is populated with Mdichildren forms every time the user clicks connect, it will dispose all the forms and re-create them as tabs
This has been working fine since forever but now all of a sudden something is starting to throw up a NRE.
System.NullReferenceException: Object reference not set to an instance of an object.
at System.Windows.Forms.Form.DeactivateMdiChild()
at System.Windows.Forms.Form.WmMdiActivate(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.DebuggableCallback(IntPtr hWnd, Int32 msg , IntPtr wparam, IntPtr lparam)
at System.Windows.Forms.UnsafeNativeMethods.CallWindowProc(IntPtr wndProc, IntPtr hWnd, Int32 msg, IntPtr wParam, IntPtr lParam)
at System.Windows.Forms.NativeWindow.DefWndProc(Message& m)
at System.Windows.Forms.Control.DefWndProc(Message& m)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.MdiClient.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)
I can see its something to do with the Mdi child form deactivating, I have Checked the Parent form is set correctly which it is and am now lost after lots of googling.
Following Code launch's the forms.
public void CheckIfExisits(Form MainForm, string DBASE, string ODBC, UltraToolbarsManager UTBM)
{
var ASQL = new Accounts.SQL.SummaryTab();
var FSQL = new FocalPoint.SQL.SummaryTab();
var WSQL = new WorkFlowForms.SQL.SummaryTab();
var AVER = ASQL.DimVer(DBASE, ODBC);
var FVER = FSQL.FPVer(DBASE, ODBC);
var WVER = WSQL.WffVer(DBASE, ODBC);
if (AVER != "0")
{
var FrmAccSum = new FrmAccountsSummary(DBASE, ODBC, UTBM) { MdiParent = MainForm };
FrmAccSum.Show();
}
if (FVER != "0")
{
var FrmFPSum = new FrmFocalPointSummaryNew(DBASE, ODBC, UTBM) { MdiParent = MainForm };
FrmFPSum.Show();
}
if (WVER != "0")
{
var FrmWFFSum = new FrmWorkFlowFormSummarys(DBASE, ODBC, UTBM) { MdiParent = MainForm };
FrmWFFSum.Show();
}
}
If i close the forms in reverse order that they were opened it works fine, if however i try close the Accounts form then the Focalpoint form i get the NRE error.
I can provide the code that closes the forms, however as i can replicate this by closing the forms manually i dont think this is where the issue lies.
My main form calls the class as follows
SummaryFormLaunch SFL = new SummaryFormLaunch();
SFL.CheckIfExisits(this, cmbDBASE.Text, cmbODBC.Text, ultraToolbarsManager1);
Any Advice on trying to trace down the cause of the error would be welcome as i am at a loss.
Cheers!
EDit: Using VS 2008, .net 3.5SP1
Edit 2: Will also add that if i turn on Thrown for NRE in the exceptions list i still don't get taken to the error at hand just gives me the NRE Error in a box and doesn't take me to the part in the code.
Edit 3: This appears to happen whenever i close the Accounts form (First mdi child created) first, if i leave this to last it appears to work fine, however if i close this first, whatever the last form closed is will cause the NRE.
Well this was a nightmare, one that could have been easier to diagnose if I could actually debug it correctly.
I had changed part of the code to make a form active, this was to help set a focus on a form if the header tabs changed (As these should always show the same information)
I had used this
this.ActivateMdiChild(frm);
Now this is fine and does the job i want it too (Make the correct form active) however when the Base.Dispose does it disposing it looks at the Parent form for the ActiveMdiChild and tries to deactivate it.
But because what was the active MdiChild has already been deactivated this is a null value, which was causing my NRE error.
Does mean i have to try and find another way of setting the active form but at least this random issue has now gone!
I am having an issue with a user where my application just throws and unhandled exception for no particular reason. I am not sure what is causing this as the application itself does not check nor handle anything remotely related to and Input Language change event. The exception is pretty vague as it stands with no inner exception or any other information that tells what is going on as it seems to be an arithmetic overflow exception.
Here is the exception message and stack trace:
Type: System.OverflowException
Message: 算術演算の結果オーバーフローが発生しました。
Source: System.Windows.Forms
Stack Trace: 場所 System.Windows.Forms.InputLanguageChangingEventArgs..ctor(InputLanguage inputLanguage, Boolean sysCharSet)
場所 System.Windows.Forms.Control.WmInputLangChangeRequest(Message& m)
場所 System.Windows.Forms.Control.WndProc(Message& m)
場所 System.Windows.Forms.ButtonBase.WndProc(Message& m)
場所 System.Windows.Forms.Button.WndProc(Message& m)
場所 System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
The exception message is "Arithmetic operation resulted in an overflow". Has anyone experienced such behaviour before
This is actually a bug in .NET Framework, in System.Windows.Forms.InputLanguage.Culture getter (you cannot see it in the stack trace since it gets inlined inside InputLanguageChangingEventArgs..ctor by the JIT):
public CultureInfo Culture
{
get
{
return new CultureInfo((int)this.handle & 65535);
}
}
here, this.handle is IntPtr and that means it is 64-bit on x64 OS, but mistakenly casted to int, and that causes the OverflowException if some of the higher bits in this handle are set.
The only workaround I can think of is to completely filter out messages with handle not fitting into int type:
// call this before Application.Run():
Application.AddMessageFilter(new WmInputLangChangeRequestFilter());
class WmInputLangChangeRequestFilter : IMessageFilter
{
public bool PreFilterMessage(ref Message m)
{
if (m.Msg == 0x0050)
{
return (long)m.LParam > 0x7FFFFFFF;
}
return false;
}
}
I have seen the "OverflowException" in Greenshot, where I researched this I arrived here.
Here is some additional information to the issue:
On MSDN there are some comments to it: https://msdn.microsoft.com/en-us/library/windows/desktop/ms632630(v=vs.85).aspx
It is said that the Windows-Message is not posted on e.g. Windows 7, which I can confirm I have never seen it and can't reproduce it.
Here is also some information "WHAT BROKE THE INPUT LANGUAGE MESSAGES?": http://www.siao2.com/2006/05/16/598980.aspx
I currently think that for my application the message is not important, so I added Torvin's solution to ignore it...
I have made a C# project. Every thing is working fine when i run project through Visual Studio 2010. After that i have created setup for this solution and when i tried to open the dialog box then it showed the above error. After running project from setup file it also making trouble to write into database.
Here is the complete stack of exception that came on access of dialog.
See the end of this message for details on invoking just-in-time
(JIT) debugging instead of this dialog box.
***** Exception Text ******* System.AccessViolationException: Attempted to read or write protected
memory. This is often an indication that other memory is corrupt.
at System.Windows.Forms.FileDialogNative.IFileDialog.Show(IntPtr
parent) at System.Windows.Forms.FileDialog.RunDialogVista(IntPtr
hWndOwner) at System.Windows.Forms.FileDialog.RunDialog(IntPtr
hWndOwner) at
System.Windows.Forms.CommonDialog.ShowDialog(IWin32Window owner) at
System.Windows.Forms.CommonDialog.ShowDialog() at
Email_Client.ImportContacts.btnBrowse_Click(Object sender, EventArgs
e) in E:\Development.net Projects\Email Client\Email
Client\ImportContacts.cs:line 35 at
System.Windows.Forms.Control.OnClick(EventArgs e) at
System.Windows.Forms.Button.OnClick(EventArgs e) at
System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent) at
System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons
button, Int32 clicks) at
System.Windows.Forms.Control.WndProc(Message& m) at
System.Windows.Forms.ButtonBase.WndProc(Message& m) at
System.Windows.Forms.Button.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)
Please help.
I was the same problem and i solved it by install Hotfix
https://support.microsoft.com/en-us/hotfix/kbhotfix?kbnum=2516475&kbln=en-US
in my case the problem occured because i use accdb instead of mdb
vb.net or c#
I am getting an error when I am trying to use ctrl + C and ctrl +V on a datagridview control.
This is not reproducible on my other machine.
Further analyzing the case, I figured out that this issue occurs only if Google Chrome is running. If I close Google Chrome, it works fine as expected.
This is the exception thrown by application,
Requested Clipboard operation did not succeed.
--STACK TRACE--
at System.Windows.Forms.Clipboard.ThrowIfFailed(Int32 hr)
at System.Windows.Forms.Clipboard.SetDataObject(Object data, Boolean copy, Int32 retryTimes, Int32 retryDelay)
at System.Windows.Forms.DataGridView.ProcessInsertKey(Keys keyData)
at System.Windows.Forms.DataGridView.ProcessDataGridViewKey(KeyEventArgs e)
at System.Windows.Forms.DataGridView.OnKeyDown(KeyEventArgs e)
at System.Windows.Forms.Control.ProcessKeyEventArgs(Message& m)
at System.Windows.Forms.DataGridView.ProcessKeyEventArgs(Message& m)
at System.Windows.Forms.Control.ProcessKeyMessage(Message& m)
at System.Windows.Forms.Control.WmKeyChar(Message& m)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.DataGridView.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)
System.Windows.Forms
This issue occurs with Internet Explorer as well.
Is there anything that I have to do on datagridview.
Please help me out to troubleshoot this issue.
Thanks in advance,
Vijay
This looks similar to this question ..
Requested Clipboard operation did not succeed
Also related ..
http://social.msdn.microsoft.com/Forums/en/csharpgeneral/thread/31da5cec-7d47-41f0-a2e5-ee16e609a871
From above link..
The problem with the clipboard is that it is shared among all
processes and only one process can access it at a time. So if another
process uses the clipboard at the same time as your application then
you may get this exception. Your other computer may have a process
that uses the clipboard even when the process's window is not active
(e.g. the user is performing an action in your application). This is
also known to be a problem with Virtual machines.
My advice is to catch the exception and try again a few times, sooner
or later the clipboard will be freed so you could use it. You could
inherit from the Clipboard class and provide additional methods that
you use in your application.
And one more..
http://channel9.msdn.com/Forums/TechOff/Requested-Clipboard-operation-did-not-succeed
Have you guys met something similar?
Exception type: System.ComponentModel.Win32Exception
Exception message: The operation completed successfully .
Exception stack trace:
------------------------
at System.Drawing.BufferedGraphicsContext.CreateCompatibleDIB(IntPtr hdc, IntPtr hpal, Int32 ulWidth, Int32 ulHeight, IntPtr& ppvBits)
at System.Drawing.BufferedGraphicsContext.CreateBuffer(IntPtr src, Int32 offsetX, Int32 offsetY, Int32 width, Int32 height)
at System.Drawing.BufferedGraphicsContext.AllocBuffer(Graphics targetGraphics, IntPtr targetDC, Rectangle targetRectangle)
at System.Drawing.BufferedGraphicsContext.AllocBufferInTempManager(Graphics targetGraphics, IntPtr targetDC, Rectangle targetRectangle)
at System.Drawing.BufferedGraphicsContext.Allocate(IntPtr targetDC, Rectangle targetRectangle)
at System.Windows.Forms.Control.WmPaint(Message& m)
at System.Windows.Forms.Control.WndProc(Message& m)
at DevExpress.XtraEditors.Container.EditorContainer.WndProc(Message& m)
at DevExpress.XtraGrid.GridControl.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)
Everywhere in the app where there is one graphics object used , it is used with using so disposing is enabled.
Thanks.
We had some similar problems. It sounds like you have some memory leaks in your application. We also had a similar problem and it took us a long time to find out where and what to fix.
In general I can advice you to check, whether the Dispose method of your win form components get invoked when you hide and don't use it any more. But to verify whether you have memory leaks and where to fix them you need a good memory profiler.
At least in our case it solved these win32 exceptions.
Edit:
I just have seen, that dispose is enabled in your case, I still advice you to check every call! We also thought that Dispose gets called, but sometimes it was not!