Results 1 to 11 of 11

Thread: Object reference not set to an instance of an object..sometimes?

  1. #1

    Thread Starter
    Member Redeye44us's Avatar
    Join Date
    Apr 2003
    Posts
    50

    Question Object reference not set to an instance of an object..sometimes?

    I have a application in VB.NET 2003 using Crystal Reports to create reports from an Access database. The problem I am running with one of my customers is that on two of the computers, when running crystalreportviewer for several reports, it returns the message in my subject line. There is one computer that is able to run all reports without a problem. They are all Windows 98 PCs. The reports also view correctly on my Windows 98 PC I use for testing. I do have the convertnullfieldtodefault set to true. Any ideas?

    Thanks

  2. #2
    Your Ad Here! Edneeis's Avatar
    Join Date
    Feb 2000
    Location
    Moreno Valley, CA (SoCal)
    Posts
    7,339
    Sounds like a coding issue, you must have forgot a New somewhere.

  3. #3
    PowerPoster
    Join Date
    Dec 2003
    Location
    Bristol, England (but heart is in Virginia)
    Posts
    2,949
    Hi,

    First thing to do is see what differences there are between the computors which display the error and those which don't. Usually it will be because they are accessing different databases and you coding differs slightly when handling each database. Just a thought, have you got separate coding for Access and SQL databases? If so, check your instantiating in both.
    Taxes
    The more I learn about VB.NET the more I like dBaseIII Plus

    The foregoing, whilst believed to be correct, is given without guarantee as to it's accuracy and entirely without recourse. You are required to decide for yourself whether or not it is suitable for your purposes and no liability for loss of any nature can be entertained.

  4. #4

    Thread Starter
    Member Redeye44us's Avatar
    Join Date
    Apr 2003
    Posts
    50
    All computers are accessing the same Access database, so there is no need to have different coding for SQL. As I have been checking this out, I noticed that all of the Win98 computers that work had .net framework 1.0 installed with the previous version of my app (VB.NET 2002). The current version is using .net framework 1.1 & VB.NET 2003. I thought maybe there was something in the 1.0 framework that would make the one computer work. To check this out, I formatted my Win98 computer and installed only the 1.1 version. It worked fine, so I know it's not something missing in my installation CD or something in 1.0 framework. The code is real basic:

    VB Code:
    1. Private Sub frmRpt_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    2.         Try
    3.             Me.LoadDataSet()
    4.         Catch eLoad As System.Exception
    5.              System.Windows.Forms.MessageBox.Show(eLoad.Message)
    6.         End Try
    7.         Dim rpt As New rptReport
    8.         rpt.SetDataSource(objdsRpt)
    9.         CrystalReportViewer1.ReportSource = rpt
    10.     End Sub

    Are there any known programs that might conflict with Crystal report veiwer?

    Thanks for you help,
    Joe

  5. #5
    PowerPoster
    Join Date
    Dec 2003
    Location
    Bristol, England (but heart is in Virginia)
    Posts
    2,949
    Hi,

    Have you found out which object is at the root of the problem?

    Try putting a breakpoint at the line where the error occurs. Check this out on both computors (one which works and one which does not). Then check the status of the relevant objects at that point.

    If the error occurs in the code section you posted, which line?

    I recall that once (not in VB) I had a similar unsolvable problem, which I got round by inserting some extra unnecessary code just before the error arose. This apparently had the efect of altering a sequence which "upset" the host computor - I never found out why. (All I did was to execute a print- one- character- to -the -console instruction)
    Taxes
    The more I learn about VB.NET the more I like dBaseIII Plus

    The foregoing, whilst believed to be correct, is given without guarantee as to it's accuracy and entirely without recourse. You are required to decide for yourself whether or not it is suitable for your purposes and no liability for loss of any nature can be entertained.

  6. #6
    Hyperactive Member
    Join Date
    Nov 2003
    Location
    Connecticut
    Posts
    257
    I am having a related problem. I've created several small programs in vb.net that are all being run on computers in my office with windows 98 and the .net framework installed. Every program that doesn't have a crystal report embedded in it works fine. Every program that has a crystal report gives a process id and thread error before it even starts. I am assuming it's the crystal report that's causing this error since it's the only common denominator between all the programs that won't load.

    Any ideas?

  7. #7

    Thread Starter
    Member Redeye44us's Avatar
    Join Date
    Apr 2003
    Posts
    50
    I have put a breakpoint at the line which sets the datasource for the viewer. I am able to step through the code until it set the reportsource for the viewer and then the viewer starts up and I lose control. The error occurs once the reportsource is set. I have tried to put an handleexception sub for the viewer to get more info about the error, but it doesn't seem to do anything. Any other ideas?

    Thanks for your help,
    Joe

  8. #8
    Frenzied Member
    Join Date
    Nov 2003
    Posts
    1,489
    when you say
    VB Code:
    1. dim x as AnObject
    you are merely allocating an address in memory for future use. you have nothing in there yet.

    you have to instantiate it next:
    VB Code:
    1. x = new AnObject

    that way the program takes that class and creates an empty object for you. It equals NOTHING now. if you want to refer to an existing object to manipulate it, you leave off the NEW keyword.

    that's just my.02 you may have already known that.

  9. #9
    PowerPoster
    Join Date
    Dec 2003
    Location
    Bristol, England (but heart is in Virginia)
    Posts
    2,949
    HI,

    It sounds like your problem could lie in the database. It may be slightly different in the computor which gives the error message. Is that computor using the same version of Access as the others? Has the user modified the database without your knowledge? To check this you could try altering a few database items on a machine where your programme works and try to replicate the error message. By the way, check to see you are not using any reserved words as field names etc. (e.g. NAME)

    The other thought is Crystal Reports. If you search through this forum for threads on Crystal reports, you will find several problems have arisen. I did this yesterday and was surprised to notice the large number of threads on the subject which had no responses!
    Last edited by taxes; Mar 23rd, 2004 at 03:25 PM.
    Taxes
    The more I learn about VB.NET the more I like dBaseIII Plus

    The foregoing, whilst believed to be correct, is given without guarantee as to it's accuracy and entirely without recourse. You are required to decide for yourself whether or not it is suitable for your purposes and no liability for loss of any nature can be entertained.

  10. #10

    Thread Starter
    Member Redeye44us's Avatar
    Join Date
    Apr 2003
    Posts
    50
    Thanks for the reply,

    The computer that is not working is using a UDL file to point to the shared database on the computer that is working. The error occurs both when accessing the shared database and when the UDL file points to it's own database.

    I have also noticed the number of problems people are having with Crystal. I posted this problem in another forums and it seems like people try to avoid even reading it.

    It seems to have something to do with some Win98 computers. All Win2000 and XP work fine as well as several Win98.

    I'll keep diggin. Thanks for your help,
    Joe

  11. #11
    PowerPoster
    Join Date
    Dec 2003
    Location
    Bristol, England (but heart is in Virginia)
    Posts
    2,949
    Hi,

    It's beyond my knowledge, but surely there is some way of getting the precise abject name which is causing the error? I know you cannot do this in normal .NET coding, but I would have thought that information was residing somewhere in the computor memory. Hopefully one of the experts will comment.
    Taxes
    The more I learn about VB.NET the more I like dBaseIII Plus

    The foregoing, whilst believed to be correct, is given without guarantee as to it's accuracy and entirely without recourse. You are required to decide for yourself whether or not it is suitable for your purposes and no liability for loss of any nature can be entertained.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width