none
Splash Screen VS2010 - Not working correctly

    Question

  • Hi
    I just upgraded from VS2008 to VS2010 (Service Pack 1).  I have ported a VB.Net project i was working on in VS2008 over to VS2010 and the conversion was reported as being succesful with no errors.
    However, i am now having problems with my splash screen in the VS2010 project.  Basically i want the splash screen to display for 1000ms and then show the main form.  I had this working fine in VS2008, but for some reason it doesnt work properly now in VS2010.  In VS2010, the splash screen doesnt close, it just stays there.  The main form also now displays at virtually the same time as the splash screen, when it should only display after the splash screen is closed.  To further add to the confusion, if i have VS2008 and VS2010 open at the same time, the splash screen works as intended in both VS2008 and VS2010!
    Here is how i set the delay for my splash screens.  Note that the value stored in My.Settings.SplashDelay is an integer of 1000.  I have tried commenting this setting out and just hardcoding an integer value of 1000 here, but i get the same result. 
     
    Partial Friend Class MyApplication
    
            Protected Overrides Function OnInitialize(ByVal commandLineArgs As System.Collections.ObjectModel.ReadOnlyCollection(Of String)) As Boolean
                'Set the splash screen timeout. 
                Me.MinimumSplashScreenDisplayTime = My.Settings.SplashDelay
    
                Return MyBase.OnInitialize(commandLineArgs)
                
            End Function
    
    End Class
    
    Anyone know whats going on here?  Help would be appreciated.

    • Edited by AaRoN_P Tuesday, November 08, 2011 12:12 PM
    Tuesday, November 08, 2011 12:11 PM

Answers

  • Problem solved guys.

    In the Load event of my startup form i had code used to clear the immediate window of Visual Studio.  The method i use to clear the window was this:

    Private Sub ClearImmediateWindow()
            Dim dteObject As EnvDTE.DTE = System.Runtime.InteropServices.Marshal.GetActiveObject("VisualStudio.DTE.9.0") 'vb2008
            Dim currentActiveWindow As Window = dteObject.ActiveWindow
            dteObject.Windows.Item("{ECB7191A-597B-41F5-9843-03A4CF275DDE}").Activate() 'Immediate Window
            dteObject.ExecuteCommand("Edit.SelectAll")
            dteObject.ExecuteCommand("Edit.ClearAll")
            currentActiveWindow.Activate()
        End Sub
    

    The problem was i was still referencing the "VisualStudio.DTE.9.0" which is used in VS2008.  Obviously this is not relevant in VS2010 and hence this method was creating an error (that was not reported to me) which stuffed up the loading of the splash screen and startup form. I changed this to "VisualStudio.DTE.10.0" and the splash screen works again.  This also explains why my splash screen worked when i had VS2008 and VS2010 open and the same time - the VisualStudio.DTE.9.0 would be active in that case so the method would still be valid, although it would clear the wrong immediate window!)

    Thanks to all those who contributed.

    P.S If anyone knows a better way of clearing the Immediate window when you run your application then please let me know!


    • Marked as answer by AaRoN_P Wednesday, November 09, 2011 3:07 AM
    • Edited by AaRoN_P Wednesday, November 09, 2011 3:11 AM
    Wednesday, November 09, 2011 3:06 AM

All replies

  • Yea I get the same behaviour,

    If nobody comes with a solution than this website is for bug reporting

    Http://connect.microsoft.com

     


    Success
    Cor
    Tuesday, November 08, 2011 12:29 PM
  • I created a new 2010 project, and added a splash screen, and set the display time as above.  At least in the debugger it worked correctly. 
    Serial Port      Random      Microsoft® Community Contributor 2011
    Tuesday, November 08, 2011 12:54 PM
  • Mine doesn't work either. Developed a workaround:

            SplashScreen1.Show()
            SplashScreen1.Refresh()
            Threading.Thread.Sleep(5000)
            SplashScreen1.Close()

    Tuesday, November 08, 2011 1:05 PM
  • Was this a new project or a converted project?  I did not have a problem when creating a new project.

    Serial Port      Random      Microsoft® Community Contributor 2011
    • Edited by dbasnett Tuesday, November 08, 2011 1:36 PM
    Tuesday, November 08, 2011 1:35 PM
  • Nice workaround Sergey.  The only downside is that you cannot continue working with the thread when you suspend it (i.e. loading your project resources in the background while the splash screen is displayed).  Unless i am mistaken...

     

    Tuesday, November 08, 2011 1:35 PM
  • @dbasnett: Try creating the same thing in VS2008, then port it over to VS2010 and see what happens.
    • Edited by AaRoN_P Tuesday, November 08, 2011 1:37 PM
    Tuesday, November 08, 2011 1:36 PM
  • Nice workaround Sergey.  The only downside is that you cannot continue working with the thread when you suspend it (i.e. loading your project resources in the background while the splash screen is displayed).  Unless i am mistaken...

     

    Yes. As every workaround it is kind of substitution until you find a correct solution. But lets imagine that you desperately want to show your splash screen for a short time when a small application starts. Then this is not so bad solution at all.
    Tuesday, November 08, 2011 1:55 PM
  • Now it works. Make sure you do set the name of Splash Screen form:

    Tuesday, November 08, 2011 2:55 PM
  • Yes. As every workaround it is kind of substitution until you find a correct solution. But lets imagine that you desperately want to show your splash screen for a short time when a small application starts. Then this is not so bad solution at all.

     

    I agree with you.  Its a nice workaround.

    Tuesday, November 08, 2011 10:30 PM
  • Now it works. Make sure you do set the name of Splash Screen form:


    What do you mean "do" set the name of the splash screen?  Do you mean make sure you set which form is your splash screen in the Application tab as per your posted image?  If so, yes i have done that.  No splash screen would pop up at all if i didn't.

    If you are referring to renaming the splash screen form, then i have tried that also.  No change.  Although in your example the name of your splash screen is the default name so it doesnt look like you renamed it.

     

    Note to all:

    I should like to point out to everyone that if you are trying to recreate my problem you have to create this project in VS2008 and then port it over to VS2010.  If i create a new project in VS2010 from scratch I have no problems with splash screens.

     

    Tuesday, November 08, 2011 11:08 PM
  • Ok i think I'm getting closer to figuring out what the problem is, but i would like some input from people with more knowledge than me on this topic.

    I believe the issue may have to do with my Startup form.  My application uses a few assemblies.  The form i use as my main form is actually an empty class that inherits from a form in one of my assemblies.  i.e.

    Public Class startForm1
        Inherits MyAssembly.MyMainForm
    End Class
    

    Now if I do the same thing, but inherit from a form not located in an external assembly, then the splash screen works as intended.  This still doesn't explain why everything seemed to work if i have VS2008 open at the same time as VS2010.  Perhaps its a problem with the assembly i am inheriting my form from?  Does VS2010 load assembly's or initialize forms in a different order or at different times than VS2008?

    Tuesday, November 08, 2011 11:38 PM
  • Problem solved guys.

    In the Load event of my startup form i had code used to clear the immediate window of Visual Studio.  The method i use to clear the window was this:

    Private Sub ClearImmediateWindow()
            Dim dteObject As EnvDTE.DTE = System.Runtime.InteropServices.Marshal.GetActiveObject("VisualStudio.DTE.9.0") 'vb2008
            Dim currentActiveWindow As Window = dteObject.ActiveWindow
            dteObject.Windows.Item("{ECB7191A-597B-41F5-9843-03A4CF275DDE}").Activate() 'Immediate Window
            dteObject.ExecuteCommand("Edit.SelectAll")
            dteObject.ExecuteCommand("Edit.ClearAll")
            currentActiveWindow.Activate()
        End Sub
    

    The problem was i was still referencing the "VisualStudio.DTE.9.0" which is used in VS2008.  Obviously this is not relevant in VS2010 and hence this method was creating an error (that was not reported to me) which stuffed up the loading of the splash screen and startup form. I changed this to "VisualStudio.DTE.10.0" and the splash screen works again.  This also explains why my splash screen worked when i had VS2008 and VS2010 open and the same time - the VisualStudio.DTE.9.0 would be active in that case so the method would still be valid, although it would clear the wrong immediate window!)

    Thanks to all those who contributed.

    P.S If anyone knows a better way of clearing the Immediate window when you run your application then please let me know!


    • Marked as answer by AaRoN_P Wednesday, November 09, 2011 3:07 AM
    • Edited by AaRoN_P Wednesday, November 09, 2011 3:11 AM
    Wednesday, November 09, 2011 3:06 AM

  • What do you mean "do" set the name of the splash screen?  Do you mean make sure you set which form is your splash screen in the Application tab as per your posted image?  If so, yes i have done that.  No splash screen would pop up at all if i didn't.

     

    By that i mean that 9 out of 10 people forget to do it in the process of setting the splash screen (i am not exception). Just take a look at multiple posts on Internet forums.

    To finish with that, the MSDN recommended procedure to set the splash screen and minimum length of time, in milliseconds, for which the splash screen is displayed:

    1. First, specify the splash screen "How to: Specify a Splash Screen for an Application (Visual Basic)": http://msdn.microsoft.com/en-us/library/bfkbc5a3(v=VS.80).aspx

    And here, do not forget to set splash screen's name explicitly in Application tab (see post with picture above).

    2. Then, use "WindowsFormsApplicationBase.MinimumSplashScreenDisplayTime Property" and follow instructions in the corresponding article:http://msdn.microsoft.com/en-us/library/microsoft.visualbasic.applicationservices.windowsformsapplicationbase.minimumsplashscreendisplaytime.aspx

    Note that "you must enter this code in the Code Editor window".

    Now, everything supposed to work fine (unless you mess it up with some wrong code).  

     

    Wednesday, November 09, 2011 6:07 AM
  • The problem with errors in the load event is a 64 bit problem(doesn't happen on 32 bit systems).  It has been argued on this forum that this is a bug, but some seem to think it is OK.  I think only those that have not spent hours tracking these sorts of thing down think that it is not a bug.
    Serial Port      Random      Microsoft® Community Contributor 2011
    Wednesday, November 09, 2011 1:12 PM
  • Definately agree dbasnett.  The solution to my problem was a simple typo that was fixed in less than a second, but finding out what the problem was did take hours.  Massive waste of time!

    Wednesday, November 09, 2011 9:59 PM
  • I was came across with the same problem with Visual Basic .NET 2010.

    In my situation the problem was that the startup form was never shown on screen (it was hidden by code). I was hiding the form with the command Me.Hide(). In that case if the startup form never manage to shown on screen then the splash screen never goes away!

    I've made same modifications to my code, i placed a progress bar to my startup form, instead of Me.Hide() now i'm showing the form (and splash form disappears).

    Best regards

    Isidoros


    Isidoros MCTS VB.NET

    Friday, November 23, 2012 10:19 AM