Click here to Skip to main content
14,644,614 members
Rate this:
Please Sign up or sign in to vote.
I was making a c# winform application in SharpDevelop using Net Framework 4. The application is almost complete but I decided to use Visual Studio 13 Community Edition. When I run application in this through Visual Studio, It is giving me strange exception (RowNotInTableException when I delete some row in Datagridview). I again run the application in SharpDevelop and there was no exception.

My question is, are these new exceptions from Visual Studio or already existed in my code which are now being discovered by Visual Studio. and how can I fix them now???

Now I cannot check my complete application again in Visual Studio to see whether there are new exceptions or not??

Edit 1:

I have a datagridview, datatable (dt) and a bindingsource (bs).

bs.DataSource = dt;
dataGridView1.DataSource = bs;

Now if I add some data in datagridview in the running application and then select the entire row by clicking the row header and then press "delete key" on keyboard. It gives me exception in the following code.

The exception is:

An exception of type System.Data.RowNotInTableException occurred in System.Data.dll but was not handled in user code

Additional information: This row has been removed from a table and does not have any data. BeginEdit() will allow creation of new data in this row.


dataGridView1.DataBindingComplete += (S,E)=>
            {
                for(int i = 0; i < dt.Rows.Count; i++)
                {
                    if (dt.Rows[i]["order Ref No."].ToString() != "")//Exception occurs here
                    {
                        //do something
                    }
                }

            };
Posted
Updated 4-Jul-15 9:05am
v2
Comments
Afzaal Ahmad Zeeshan 4-Jul-15 11:35am
   
Yes, if the client has .NET framework 4.5. He would be able to see the exceptions also.
   
Do you want to talk about nothing? If, instead, you create a really small but comprehensive and self-contained code sample which works without exception in v.4 and gives this exception with 4.5 or 4.6, we would be able to consider it.
—SA
Suvendu Shekhar Giri 4-Jul-15 13:09pm
   
Can you share your code for deleting row?
I feel there is still something else which is doing this and possibly it's a case of suppressing that particular exception in 4.0.
Rate this:
Please Sign up or sign in to vote.

Solution 1

The effect of different framework depends not on the actually installed framework(s), but on the target framework of the assemblies being executed.

Suppose you develop some product having .NET v.4.0. Apparently, all the assemblies are targeted to v.4.0 or lower versions. When your user installs v.4.5 or 4.6, nothing should be changed. Even if some user does not have any .NET version and installs v.4.0 will be supported. Nothing bad should be changed.

Now, it won't be the excuse for not fixing your code, if there is some issue revealed only by v.4.5 or 4.6. Actually, it sounds weird, and I cannot be 100% sure your observations are correct, but let's assume it is really the case. If some problem is revealed but it does not affect some version of your product, it's still a problem which should be fixed. You are going to support your product, aren't you? :-)

—SA
   
Rate this:
Please Sign up or sign in to vote.

Solution 2

Problem solved by adding
dt.AcceptChanges()
as below:

dataGridView1.DataBindingComplete += (S,E)=>
            {
                dt.AcceptChanges();
                for(int i = 0; i < dt.Rows.Count; i++)
                {
                    if (dt.Rows[i]["order Ref No."].ToString() != "")//Exception occurs here
                    {
                        //do something
                    }
                }
 
            };



But why no exception was being raised in SharpDevelop IDE??? I guess Visual Studio is better as it shows all the errors or exception in our code while SharpDevelop misses some.
   

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100