Solved

Object reference not set to an instance of an object

Posted on 2004-08-25
4
183 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
  • 3
4 Comments
 
LVL 18

Expert Comment

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

Expert Comment

by:DotNetLover_Baan
Comment Utility
you can just use...

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

-Baan
0
 
LVL 37

Accepted Solution

by:
gregoryyoung earned 500 total points
Comment Utility
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
Comment Utility
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Well, all of us have seen the multiple EXCEL.EXE's in task manager that won't die even if you call the .close, .dispose methods. Try this method to kill any excels in memory. You can copy the kill function to create a check function and replace the …
I think the Typed DataTable and Typed DataSet are very good options when working with data, but I don't like auto-generated code. First, I create an Abstract Class for my DataTables Common Code.  This class Inherits from DataTable. Also, it can …
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

763 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now