473,385 Members | 1,927 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

error: Null Value & Object reference not set...

I have a simple one form VB.NET desktop app, that does a little threading
like so

mThread = New System.Threading.Thread(AddressOf DoSearch)
mThread.Start()

mThread has been decleared with the form class
Dim mThread As System.Threading.Thread

The DoSearch sub is in the same class as my form, and this sub is adding
and changing values of controls on the form. I think it may be because of
this I'm getting the following errors.

Public Class >Form1<
An unhandled exception of type 'System.NullReferenceException' occurred in
system.windows.forms.dll
Additional information: Object reference not set to an instance of an
object.

Public Class >Form1<
An unhandled exception of type 'System.ArgumentNullException' occurred in
system.windows.forms.dll
Additional information: Value cannot be null.

It seems quite random.. The same search, with the same results may or may
not produce either of those errors or none at all?

Like I said.. My first though is that the thread some times just can not
find the form object class but I cant trace back in the code.. it always
brakes on that line "Public Class Form1"

Any ideas?

Thanks
DaveC
Nov 21 '05 #1
1 1578

"DaveC" <oh***@hotmail.com> wrote
I have a simple one form VB.NET desktop app, that does a little threading
like so

mThread = New System.Threading.Thread(AddressOf DoSearch)
mThread.Start()

mThread has been decleared with the form class
Dim mThread As System.Threading.Thread

The DoSearch sub is in the same class as my form, and this sub is adding
and changing values of controls on the form. I think it may be because of
this I'm getting the following errors.
Yes, I would concur.

It seems quite random.. The same search, with the same results may or may
not produce either of those errors or none at all?

Any ideas?

Code that effects any of the controls should be run from the main UI thread.
All that type of control accessing code should be moved out of your DoSearch
routine into a separate sub that you can call from the DoSearch routine.

Look into using the form's Invoke method to call out from DoSearch, to the
sub containing the control access code. Invoke will handle the cross-thread
issuses for you....

LFS
Nov 21 '05 #2

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

Similar topics

9
by: Tyler | last post by:
I am attempting to extend a legacy VB6 application by making it use a .NET component written in C# exposed through COM interop. Everything appeared to be going well (VB application creates the...
3
by: Ganesh Palaniappan | last post by:
We're getting following exception for the below piece of code. We're wondering how it is possible since we're having a null check for objGraphics and strokePen... Exception:...
0
by: iKiLL | last post by:
Hi All Code Below for this problem ERROR: "An existing connection was forcibly closed by the remote host"
2
by: arun1985 | last post by:
In the project i am using i am having the following code and when i upload it to the server.Its givig me the following error in the global.cs file. Server Error in '/' Application. ...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
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...
0
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,...
0
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...

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.