Results 1 to 15 of 15

Thread: [RESOLVED] Problem that has me going crazy.

  1. #1

    Thread Starter
    Lively Member crazy1993's Avatar
    Join Date
    Sep 2010
    Location
    Rochester, NY
    Posts
    85

    Resolved [RESOLVED] Problem that has me going crazy.

    Hey VBFROUM!

    I have been working on a program and i am developing the second installment of the beta series. I have a configuration wizard that asks the user some questions then saves the settings when you click finish and restarts the program. When the program restarts, i end up with two instances of my application. i used application.restart()


    EDIT:

    Check out the techjive website. We are releasing 2.0 in a little (like next week maybe by saturday?) Its okay but its only my first beta

    office.techjive.org
    Attached Files Attached Files
    Last edited by crazy1993; Jan 12th, 2011 at 11:19 PM. Reason: Update title
    ~Dustin Schreiber
    Head Developer for TechJive Dev Team - Founder of http://www.thetechsphere.com
    Who *cares* if a laser guided 500 lb bomb is accurate to within 9 feet?
    Teamwork is essential. It gives the enemy someone else to shoot at.
    Retreating?! Hell no, we're just attacking the other direction!

    Please rate posts if you find them helpful
    <--- Over there genius

  2. #2
    PowerPoster Nightwalker83's Avatar
    Join Date
    Dec 2001
    Location
    Adelaide, Australia
    Posts
    13,344

    Re: Problem that has me going crazy.

    Perhaps it would be a good idea if you include which version of vb.net you are using. I tried opening the project in VS2008 and it didn't open.
    when you quote a post could you please do it via the "Reply With Quote" button or if it multiple post click the "''+" button then "Reply With Quote" button.
    If this thread is finished with please mark it "Resolved" by selecting "Mark thread resolved" from the "Thread tools" drop-down menu.
    https://get.cryptobrowser.site/30/4111672

  3. #3

    Thread Starter
    Lively Member crazy1993's Avatar
    Join Date
    Sep 2010
    Location
    Rochester, NY
    Posts
    85

    Re: Problem that has me going crazy.

    Quote Originally Posted by Nightwalker83 View Post
    Perhaps it would be a good idea if you include which version of vb.net you are using. I tried opening the project in VS2008 and it didn't open.
    I'm sorry. I ended fixing my problem i was going to origonally post so i rewrote my psot and i forgot to leave that part - Anyways i use 2010 and you can open it in 2008 by opening OfficeMonkey 2.1 (BETA).sln in notepad and changing

    Microsoft Visual Studio Solution File, Format Version 11.00
    to
    Microsoft Visual Studio Solution File, Format Version 10.00
    I think i got he number write. I'm sorry i forgot to mention this
    ~Dustin Schreiber
    Head Developer for TechJive Dev Team - Founder of http://www.thetechsphere.com
    Who *cares* if a laser guided 500 lb bomb is accurate to within 9 feet?
    Teamwork is essential. It gives the enemy someone else to shoot at.
    Retreating?! Hell no, we're just attacking the other direction!

    Please rate posts if you find them helpful
    <--- Over there genius

  4. #4

    Thread Starter
    Lively Member crazy1993's Avatar
    Join Date
    Sep 2010
    Location
    Rochester, NY
    Posts
    85

    Re: Problem that has me going crazy.

    Did i post this in the wrong forum? I think i may have but not to sure? I have never been clear on what Visual Basic is classified as. Can anyone clarify that for me too?
    ~Dustin Schreiber
    Head Developer for TechJive Dev Team - Founder of http://www.thetechsphere.com
    Who *cares* if a laser guided 500 lb bomb is accurate to within 9 feet?
    Teamwork is essential. It gives the enemy someone else to shoot at.
    Retreating?! Hell no, we're just attacking the other direction!

    Please rate posts if you find them helpful
    <--- Over there genius

  5. #5
    PowerPoster Nightwalker83's Avatar
    Join Date
    Dec 2001
    Location
    Adelaide, Australia
    Posts
    13,344

    Re: Problem that has me going crazy.

    There are two main types of VB com and .net! VB6 is com and VB 2002 to now are .net. They use a different way of doing things.

    Edit:

    I found this code here which, checks for the previous instance of a loaded application.

    VB Code:
    1. Imports System.Threading
    2.  
    3. 'Form level declaration
    4.  
    5.  
    6. Public Class Form1
    7.     Dim objMutex As Mutex
    8.     Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    9.  
    10.         objMutex = New Mutex(False, "SINGLE_INSTANCE_APP_MUTEX")
    11.         If objMutex.WaitOne(0, False) = False Then
    12.             objMutex.Close()
    13.             objMutex = Nothing
    14.             MessageBox.Show("Instance already running")
    15.             End
    16.         End If
    17.         'if you get to this point it's frist instance
    18.         'continue with app
    19.  
    20.  
    21.     End Sub
    22. End Class
    Last edited by Nightwalker83; Jan 12th, 2011 at 08:48 PM. Reason: Adding more!
    when you quote a post could you please do it via the "Reply With Quote" button or if it multiple post click the "''+" button then "Reply With Quote" button.
    If this thread is finished with please mark it "Resolved" by selecting "Mark thread resolved" from the "Thread tools" drop-down menu.
    https://get.cryptobrowser.site/30/4111672

  6. #6

    Thread Starter
    Lively Member crazy1993's Avatar
    Join Date
    Sep 2010
    Location
    Rochester, NY
    Posts
    85

    Re: Problem that has me going crazy.

    Thank you for that. And thank you for that bit of code. I may end up having to do that but I am wondering why its even launching two instances when i want it to restart
    ~Dustin Schreiber
    Head Developer for TechJive Dev Team - Founder of http://www.thetechsphere.com
    Who *cares* if a laser guided 500 lb bomb is accurate to within 9 feet?
    Teamwork is essential. It gives the enemy someone else to shoot at.
    Retreating?! Hell no, we're just attacking the other direction!

    Please rate posts if you find them helpful
    <--- Over there genius

  7. #7
    PowerPoster Nightwalker83's Avatar
    Join Date
    Dec 2001
    Location
    Adelaide, Australia
    Posts
    13,344

    Re: Problem that has me going crazy.

    I'm not sure I have never used the restart method before.
    when you quote a post could you please do it via the "Reply With Quote" button or if it multiple post click the "''+" button then "Reply With Quote" button.
    If this thread is finished with please mark it "Resolved" by selecting "Mark thread resolved" from the "Thread tools" drop-down menu.
    https://get.cryptobrowser.site/30/4111672

  8. #8

    Thread Starter
    Lively Member crazy1993's Avatar
    Join Date
    Sep 2010
    Location
    Rochester, NY
    Posts
    85

    Re: Problem that has me going crazy.

    Okay, I created a quick test porgram with a button that called app to restart. Works like it should closes and reloads. So i am now wondering if its the timer i have in splash scrren? Going to experiment.
    Last edited by crazy1993; Jan 12th, 2011 at 10:19 PM. Reason: Merge posts
    ~Dustin Schreiber
    Head Developer for TechJive Dev Team - Founder of http://www.thetechsphere.com
    Who *cares* if a laser guided 500 lb bomb is accurate to within 9 feet?
    Teamwork is essential. It gives the enemy someone else to shoot at.
    Retreating?! Hell no, we're just attacking the other direction!

    Please rate posts if you find them helpful
    <--- Over there genius

  9. #9

    Thread Starter
    Lively Member crazy1993's Avatar
    Join Date
    Sep 2010
    Location
    Rochester, NY
    Posts
    85

    Re: Problem that has me going crazy.

    Now i got this:

    I skipped the config screen and disable timer and go right to main, then close the splash. i added a button to main and added application.restart to its click event. When i click it here it restarts and i end up with one instance? This is weird. it may be my configuration wizard but i havn't figured out how or whats my prbolem. Going to try the button on welcome screen (initalizer)

    EDIT

    Okay? It works as expected on welcome screen to. I don't understand what I'm doing here that makes it do this? Can anyone offer a suggestion?
    Last edited by crazy1993; Jan 12th, 2011 at 10:20 PM. Reason: Adding
    ~Dustin Schreiber
    Head Developer for TechJive Dev Team - Founder of http://www.thetechsphere.com
    Who *cares* if a laser guided 500 lb bomb is accurate to within 9 feet?
    Teamwork is essential. It gives the enemy someone else to shoot at.
    Retreating?! Hell no, we're just attacking the other direction!

    Please rate posts if you find them helpful
    <--- Over there genius

  10. #10

    Thread Starter
    Lively Member crazy1993's Avatar
    Join Date
    Sep 2010
    Location
    Rochester, NY
    Posts
    85

    Re: Problem that has me going crazy.

    Okay guys i seemed to have found a workaround. I noticed when running debugging and doing line by line when i called app restart it reran the formclosing event and i think thats what causing my problem. But i added an END in after the app restart. some reason the fist time through it gets to app restart and goes back up to start of sub, makes sense because cmd sen is basicly tell the form to close, and this time it goes to the end. somereason i still only end up with one intance now but not sure this is a goo dwork around. sinsee it ends up dong same task twice. so i hink i am going to try and redo the way the form handles closes

    If any one has more suggestions let me know please
    Last edited by crazy1993; Jan 12th, 2011 at 10:56 PM.
    ~Dustin Schreiber
    Head Developer for TechJive Dev Team - Founder of http://www.thetechsphere.com
    Who *cares* if a laser guided 500 lb bomb is accurate to within 9 feet?
    Teamwork is essential. It gives the enemy someone else to shoot at.
    Retreating?! Hell no, we're just attacking the other direction!

    Please rate posts if you find them helpful
    <--- Over there genius

  11. #11
    PowerPoster Nightwalker83's Avatar
    Join Date
    Dec 2001
    Location
    Adelaide, Australia
    Posts
    13,344

    Re: [Somewhat Resolved] Problem that has me going crazy.

    Instead of using End you could also use:

    vb Code:
    1. Application.Exit
    when you quote a post could you please do it via the "Reply With Quote" button or if it multiple post click the "''+" button then "Reply With Quote" button.
    If this thread is finished with please mark it "Resolved" by selecting "Mark thread resolved" from the "Thread tools" drop-down menu.
    https://get.cryptobrowser.site/30/4111672

  12. #12

    Thread Starter
    Lively Member crazy1993's Avatar
    Join Date
    Sep 2010
    Location
    Rochester, NY
    Posts
    85

    Re: [Somewhat Resolved] Problem that has me going crazy.

    Quote Originally Posted by Nightwalker83 View Post
    Instead of using End you could also use:

    vb Code:
    1. Application.Exit
    That may work better to close it more peacefully. I was reading just a minutea go that i shouldn't use END because of messy closes? Anyways. I am going to try that. I am currently trying to....Well i'm not really sure lol
    ~Dustin Schreiber
    Head Developer for TechJive Dev Team - Founder of http://www.thetechsphere.com
    Who *cares* if a laser guided 500 lb bomb is accurate to within 9 feet?
    Teamwork is essential. It gives the enemy someone else to shoot at.
    Retreating?! Hell no, we're just attacking the other direction!

    Please rate posts if you find them helpful
    <--- Over there genius

  13. #13

    Thread Starter
    Lively Member crazy1993's Avatar
    Join Date
    Sep 2010
    Location
    Rochester, NY
    Posts
    85

    Re: [Somewhat Resolved] Problem that has me going crazy.

    vb Code:
    1. If closer = 0 Then 'Sees if we are to the end of the wizard
    2.             Dim int As MsgBoxResult
    3.             int = MsgBox("If you close the configuration wizard you won't be able to use officeMonkey." + vbNewLine + vbNewLine + "Exit?", MsgBoxStyle.YesNo + MsgBoxStyle.DefaultButton2 + MsgBoxStyle.Question, "OfficeMonkey Configuration")
    4.             If int = MsgBoxResult.Yes Then
    5.                 e.Cancel = False
    6.             Else
    7.                 e.Cancel = True
    8.             End If
    9.         ElseIf closer = 1 Then 'if we did then save settings, restart program
    10.             saveloadsettings(0)
    11.             My.Settings.setup = True
    12.             My.Settings.Save()
    13.             closer = 2
    14.             Application.Restart()
    15.         ElseIf closer = 2 Then
    16.             e.Cancel = False
    17.         End If
    Currently working closeing method.

    Going to try app exit now as nightwalker suggested


    EDIT

    Hmm, Well still nothing. I think i get why its doing it the way its doing it. Just thinking that i can prob just change closer to something other then whats in the statements skips the ifs all together 2nd time around so therefore it just closes
    Last edited by crazy1993; Jan 12th, 2011 at 11:14 PM. Reason: Adding - Spell Check a little
    ~Dustin Schreiber
    Head Developer for TechJive Dev Team - Founder of http://www.thetechsphere.com
    Who *cares* if a laser guided 500 lb bomb is accurate to within 9 feet?
    Teamwork is essential. It gives the enemy someone else to shoot at.
    Retreating?! Hell no, we're just attacking the other direction!

    Please rate posts if you find them helpful
    <--- Over there genius

  14. #14

    Thread Starter
    Lively Member crazy1993's Avatar
    Join Date
    Sep 2010
    Location
    Rochester, NY
    Posts
    85

    Resolved Re: [Somewhat Resolved] Problem that has me going crazy.

    Code:
    Private Sub Setup_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
    If closer = 0 Then 'Sees if we are to the end of the wizard
    Dim int As MsgBoxResult
    int = MsgBox("If you close the configuration wizard you won't be able to use officeMonkey." + vbNewLine + vbNewLine + "Exit?", MsgBoxStyle.YesNo + MsgBoxStyle.DefaultButton2 + MsgBoxStyle.Question, "OfficeMonkey Configuration")
    If int = MsgBoxResult.Yes Then
    e.Cancel = False
    Else
    e.Cancel = True
    End If
    ElseIf closer = 1 Then 'if we did then save settings, restart program
    saveloadsettings(0)
    My.Settings.setup = True
    My.Settings.Save()
    closer = 2
    Application.Restart()
    End If
    End Sub
    Final code seems to work as needed. Marking thread as resolved. Thanks guys!
    ~Dustin Schreiber
    Head Developer for TechJive Dev Team - Founder of http://www.thetechsphere.com
    Who *cares* if a laser guided 500 lb bomb is accurate to within 9 feet?
    Teamwork is essential. It gives the enemy someone else to shoot at.
    Retreating?! Hell no, we're just attacking the other direction!

    Please rate posts if you find them helpful
    <--- Over there genius

  15. #15
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,974

    Re: [RESOLVED] Problem that has me going crazy.

    Thread moved from 'VB6 and Earlier' forum to 'VB.Net' (VB2002 and later) forum

    (thanks for letting us know Nightwalker83 )

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