?
Solved

Object reference not set to an instance of an object

Posted on 2004-08-25
4
Medium Priority
?
191 Views
Last Modified: 2010-04-23
I know why this is happening I just don't know how to fix it.  I have the following code in a class:

Dim frm As New frmStateDTS
frm = frmStateDTS.ActiveForm
frm.Invoke(frm.CallBindStudentData)

In this class, a dataset is being filled from text file.  When the file is imported I call the "callBindDtudentData" method invoker so I can bind the datagrid in my form with the dataset filled in the class.  This operation can take a long time so I may minimize the form and open another window.  When it gets to the line
'frm.Invoke(frm.CallBindStudentData)' I get the following error:

Object reference not set to an instance of an object.

This only happens when the form is not the top window or I have another window (ie web browser) open on top of the form.
0
Comment
Question by:km1039
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
4 Comments
 
LVL 18

Expert Comment

by:DotNetLover_Baan
ID: 11898329
what are you trying to do with   "frm = frmStateDTS.ActiveForm"... ?
0
 
LVL 18

Expert Comment

by:DotNetLover_Baan
ID: 11898335
you can just use...

Dim frm As New frmStateDTS()
frm.CallBindStudentData()

-Baan
0
 
LVL 37

Accepted Solution

by:
gregoryyoung earned 2000 total points
ID: 11898473
that won't work baan ...

the issue is with ...

Dim frm As New frmStateDTS
frm = frmStateDTS.ActiveForm 'its not the active form therefor this is null
frm.Invoke(frm.CallBindStudentData)

there are a few other ways you could do this ... i.e. find the reference to the form you want, baan's method will just create a new form. An answer might be to have your application remember which students form is active in order to run the invoke. You could also just handle this problem by showing an error message in the case that ie etc are in front of your form

if not frm is nothing
else
error
end if
0
 
LVL 18

Expert Comment

by:DotNetLover_Baan
ID: 11898522
oh.. ok... I guess..  I understood his question now... he wants to get the active form and call the method in it...
did I really get it ?? :))
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Article by: Kraeven
Introduction Remote Share is a simple remote sharing tool, enabling you to see, add and remove remote or local shares. The application is written in VB.NET targeting the .NET framework 2.0. The source code and the compiled programs have been in…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.
Suggested Courses
Course of the Month14 days, 7 hours left to enroll

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question