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

Home Posts Topics Members FAQ

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.Threadin g.Thread(Addres sOf DoSearch)
mThread.Start()

mThread has been decleared with the form class
Dim mThread As System.Threadin g.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.NullRef erenceException ' 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.Argumen tNullException' 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 1590

"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.Threadin g.Thread(Addres sOf DoSearch)
mThread.Start()

mThread has been decleared with the form class
Dim mThread As System.Threadin g.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
5294
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 .NET component instead of the legacy VB6 component and invokes some methods successfully) until I hit a snag. For one method that is being invoked by the VB6 application, the method takes 2 parameters (string values) and a custom interface. ...
3
2063
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: System.NullReferenceException: Object reference not set to an instance of an object
0
3540
by: iKiLL | last post by:
Hi All Code Below for this problem ERROR: "An existing connection was forcibly closed by the remote host"
2
2332
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. -------------------------------------------------------------------------------- Object reference not set to an instance of an object. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack...
0
8440
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8866
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
8550
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
8638
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
5662
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();...
1
2769
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2006
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1769
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.