473,666 Members | 2,065 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Sort datagrid (ThreadSystem.N ullReferenceExc eption in system.windows. forms.dll)

Please help

I have the problem that when I change the data in a
Windows.Forms.D ataGrid by a separate thread the following
Exception is thrown:

ThreadSystem.Nu llReferenceExce ption in
system.windows. forms.dll

I can't catch this Exception and it only occurs when I
allow sorting in the grid and choose the changing column
to sort.

I tried several things like monitors, suspend layout etc.
but nothing helped.
In the Threads Window of Visual Studio I can see that
there is an extra thread with the highest priority. I
assume that this one do the sorting in the background and
causes this exception.

Is this a bug of the datagrid or not and has anybody a
suggestion to solve this problem?

I have written a small test application to reproduce this
behavior. If you are interested I can send it to you.

Thanks
Ben

Nov 20 '05 #1
3 2384
Hi Ben,

No takers with just the message. I reckon you're gonna have to send that
Project.

Regards,
Fergus
Nov 20 '05 #2
On 2003-10-30, mahtan <Be***********@ hotmail.com> wrote:
Please help

I have the problem that when I change the data in a
Windows.Forms.D ataGrid by a separate thread the following
Exception is thrown:

ThreadSystem.Nu llReferenceExce ption in
system.windows. forms.dll

I can't catch this Exception and it only occurs when I
allow sorting in the grid and choose the changing column
to sort.

I tried several things like monitors, suspend layout etc.
but nothing helped.
In the Threads Window of Visual Studio I can see that
there is an extra thread with the highest priority. I
assume that this one do the sorting in the background and
causes this exception.

Is this a bug of the datagrid or not and has anybody a
suggestion to solve this problem?

I have written a small test application to reproduce this
behavior. If you are interested I can send it to you.

Thanks
Ben


Please do. But, I have to ask - are you trying to update the DataGrid
directly from the background thread? Because if you are, that is most
likely the source of your error. Windows forms controls are not thread
safe. All, except for 4, methods and properties must be called from the
GUI thread.

--
Tom Shelton
MVP [Visual Basic]
Nov 20 '05 #3
* Tom Shelton <to*@mtogden.co m> scripsit:
Please do. But, I have to ask - are you trying to update the DataGrid
directly from the background thread? Because if you are, that is most
likely the source of your error. Windows forms controls are not thread
safe. All, except for 4, methods and properties must be called from the
GUI thread.


A good introduction to Windows Forms + Multithreading can be found here:

<http://www.devx.com/dotnet/Article/11358>

--
Herfried K. Wagner
MVP · VB Classic, VB.NET
<http://www.mvps.org/dotnet>
Nov 20 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
1225
by: wesley | last post by:
Hi all, I have been getting this frustating problem where my application keep throwing a NullReferenceException, but for the light of me I could not localise the location of the problem since it was thrown from inside the windows form dll. I've printed the stack trace as it come out. This is strange what could possibly cause that? This is really bizzare I am at lost trying to figure what was happening here. Any idea anyone?
0
1857
by: sarah | last post by:
Using .NET C# installed Framework 1.1 with Service Pack 1 I have a MDI application in C# that contains 3 different forms. Form 1 has several controls one of which is a DataGrid control that works fine. Form 2 has several controls, none of which ia a DatGrid control. Form 3 has several controls, none of which as a DataGrid. In this configuration everything compiles and runs fine. When I add a DataGrid control to Form 3 I get the...
2
3264
by: Tamlin | last post by:
Hi all, I'm getting a bug with the datagrid object. I've created one from scratch, bound it to a dataview with 2 int32 columns and formatted the output as currency. I've found that when you use the F2 key to enter edit mode and then hit TAB or ESCAPE without actually editing the value, dotnet crashes with a null reference error.
0
1764
by: Shravan | last post by:
Hi, I have a Windows Forms Custom DataGrid, which is put in a usercontrol, which on setting DataSource is setting focus to grid. The call stack for setting the focus is as follows. This is not happened always whenever DataSource is set, only called sometimes, in a series of setting DataSource, I could get this setting focus only one time . Can anybody help me how to stop this one. system.windows.forms.dll!
3
5033
by: Ryan Liu | last post by:
Hi there, I got a NullReferenceException when delete last row in a datagrid. I had hard time to solve since it does not occur in my own code. I put a datagrid in my inherited user control, then put this control on a form. I use DataAdaptor to fill the data table and update database.
2
7806
by: Raed Sawalha | last post by:
i have a windows form(Main) with listview, when click an item in listview i open other window form (Sub) which generate the selected item from parent window in as treeview items when click any item in treeview i display the content item in axWebBrowser, i close the sub form normally when i close the main the following error is generated An unhandled exception of type 'System.NullReferenceException' occurred in system.windows.forms.dll ...
4
1824
by: Steve | last post by:
I am fairly new to VB.NET, and I am rewriting an application I wrote a while back, also in VB.NET. I aplied some new things I learned. Anyway, here is my problem....... I have a custom DataGrid with a buttonRow that does a delete function for me. Microsoft support helped me back then to get this done. Here is part of the code that creates the dataGrid: Dim ButtonColStyle As DataGridButtonColumn
0
1166
by: Becker | last post by:
I have a datatable that I use to display running processes. These running processes are spawned as different threads. I use the readerwriterlock class to ensure that when I write to the datatable, I obtain a write lock. The datagrid is set to have a datasource of the datatable. The problem is that I get this error intermittently and it draws a big red X across my datagrid: ************** Exception Text **************...
2
2652
by: Flack | last post by:
I have a DataGrid and a DataTable. When my form loads I create the DataTable with the appropriate columns and use it for the DataGrids.DataSource. Later on in my app, I alter the DataTable: dt.BeginLoadData(); for(int i = 0; i < _movesArrayList.Count; i++) { string columnValues = ((string)_movesArrayList).Split(COL_SEPARATOR); DataRow _moveRow = dt.NewRow();
0
8356
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8869
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8781
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8551
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
5664
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4198
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4368
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2011
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1775
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.