Results 1 to 13 of 13

Thread: VB.NET app won't run correctly the first run

  1. #1

    Thread Starter
    New Member
    Join Date
    Jun 2012
    Posts
    8

    VB.NET app won't run correctly the first run

    Hello, I work in VB.NET and I really need help.

    In brief, the program that I'm working with is designed to run different machines. To test the machines, the user uses program's testgraph. The issue is that sometimes the testgraph won't work (shows blank fields). I noticed, that the graph won't work only the first time the program runs after I reboot PC. However, if I exit the program after the first run and run the program again (without restarting pc), the issue goes away and the test graph works.

    Inside a program there are many forms such as frmmain.frm, frmtestgraph.frm etc. It seems like the first time the program runs testgraph form won't load. But it loads after I manually click the button "Test Graph" and then it sits in the memory which allows it to work on the second launch of the program. After rebooting the PC, memory clears and testgraph won't work.

    I tried to use breakpoints to compare what code runs when it works and when it doesn't. In two cases the program goes the same paths. However, on the one that works I can see changes when the particular line of code is executed. On the other one, it just goes over the line without making any changes. For example, the following line makes the testgraph button enabled in the working case: frmtestgraph.btntestraph.enabled = true

    In the not working case, the same line will still be executed but won't make that button enabled. In other words, I can see that it runs over it by pressing f8 and it won't make any change.

    I'm confused and don't know what to do. Any ideas will be greatly appreciated.

    Thank you,

    Paul.

  2. #2
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    40,104

    Re: VB.NET app won't run correctly the first run

    frmTestGraph sounds like the name of the form rather than an instance. If that is the case, you are using default instances, and much (though not all) of what you describe sounds like a symptom of using default instances....which are evil because of the confusion they cause.

    Another question would be: Is this running on a 64-bit OS, and if so, how much is happening in the Load event of the form, especially the startup form?
    My usual boring signature: Nothing

  3. #3

    Thread Starter
    New Member
    Join Date
    Jun 2012
    Posts
    8

    Re: VB.NET app won't run correctly the first run

    Thanks for quick reply!

    yes, frmTestGraph is the name of the form and the instance name of the form at the same time, so they both the same. Whenever I write code in one form and refer to some object in the other form I write like that for example:
    frmTestGraph.buttonGraph.Enabled = True

    And it works, I never had any problems with the names. But for some reason during the first run of the program, not all components are loading (probably).

    yes, it's running on 64 OS. In the startup form program sets several variables, checks for the connection of some devices and starts timers (1 timer runs continuously, and few more being enabled when needed)

  4. #4

    Thread Starter
    New Member
    Join Date
    Jun 2012
    Posts
    8

    Re: VB.NET app won't run correctly the first run

    One more thing,
    I looked in the System event log and found an error saying that one of the drivers for my device fails to load. Probably, this is my issue. Gonna be keep looking.

  5. #5

    Thread Starter
    New Member
    Join Date
    Jun 2012
    Posts
    8

    Re: VB.NET app won't run correctly the first run

    Still having the same issue. Please help!

  6. #6
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    40,104

    Re: VB.NET app won't run correctly the first run

    Could you explain this a bit more? Are you still getting this when you get the error about the device failing to load? Do you know what device, or anything about it?
    My usual boring signature: Nothing

  7. #7

    Thread Starter
    New Member
    Join Date
    Jun 2012
    Posts
    8

    Re: VB.NET app won't run correctly the first run

    It's still not loading correctly the first run. But I don't see any errors in the system log anymore, so probably this is not it. I read online and found that this is a known bug of vb.net when vb skips the lines of code. For instance, when stepping through, it's going over the line which says: Me.Graph.PlotY(plotData), but the graph field will still be empty
    However, in my case, it does it only on the first run after rebooting the PC.
    Is it possible to fix it but making the automatic restart of the program. For example, if the program was launched the first time since the computer was turned on? If so, then how can I code it?

  8. #8

    Re: VB.NET app won't run correctly the first run

    Do you have any Exception handling in your load event? If not, you really really should. You should also not be using default instances (if you actually are). That is a dreaded curse of a "feature" that causes more problems than its actually worth in .NET (I think default instances carried over from the VB era).

  9. #9

    Thread Starter
    New Member
    Join Date
    Jun 2012
    Posts
    8

    Re: VB.NET app won't run correctly the first run

    yes, I have some try blocks in my forms, however, the code doesn't seem to hit it.
    No, default instances are not being used. Everything has its own specific name like btnGraph etc.
    Also, I ran the task manager during the first run and during the second run to compare the services. All of the services are the same, nothing new being opened during the second run. So it leaves me with an idea that the problem is caused by the executable file only.

  10. #10

    Thread Starter
    New Member
    Join Date
    Jun 2012
    Posts
    8

    Re: VB.NET app won't run correctly the first run

    yes, I have some try blocks in my forms, however, the code doesn't seem to hit it.
    No, default instances are not being used. Everything has its own specific name like btnGraph etc.
    Also, I ran the task manager during the first run and during the second run to compare the services. All of the services are the same, nothing new being opened during the second run. So it leaves me with an idea that the problem is caused by the executable file only.

  11. #11

    Re: VB.NET app won't run correctly the first run

    I specifically mention the Load routine because on 64 bit systems, the load routine exceptions (that are not caught) are swallowed by the OS. This is by design (stupid to me, but whatever).

  12. #12

    Thread Starter
    New Member
    Join Date
    Jun 2012
    Posts
    8

    Re: VB.NET app won't run correctly the first run

    Yes, I do have them there too. So it might be a 64bit processor problem?

  13. #13

    Re: VB.NET app won't run correctly the first run

    Quote Originally Posted by paulCWT View Post
    Yes, I do have them there too. So it might be a 64bit processor problem?
    No, if you weren't catching exceptions, then possibly. However, you are so that might rule out the problem. What you should be doing is setting a breakpoint in your form's load routine and see if it gets that far. If it does, step through the entire load routine to see what happens.

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