Solved

Object reference not set to an instance of an object

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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

A while ago, I was working on a Windows Forms application and I needed a special label control with reflection (glass) effect to show some titles in a stylish way. I've always enjoyed working with graphics, but it's never too clever to re-invent …
1.0 - Introduction Converting Visual Basic 6.0 (VB6) to Visual Basic 2008+ (VB.NET). If ever there was a subject full of murkiness and bad decisions, it is this one!   The first problem seems to be that people considering this task of converting…
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

829 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