Solved

Object reference not set to an instance of an object

Posted on 2004-08-25
4
190 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 500 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

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

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…
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 …
If you're a developer or IT admin, you’re probably tasked with managing multiple websites, servers, applications, and levels of security on a daily basis. While this can be extremely time consuming, it can also be frustrating when systems aren't wor…
There are cases when e.g. an IT administrator wants to have full access and view into selected mailboxes on Exchange server, directly from his own email account in Outlook or Outlook Web Access. This proves useful when for example administrator want…

707 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