Solved

vb.net splash screen invoke error

Posted on 2014-03-04
4
628 Views
Last Modified: 2014-03-21
Hi,

I have a splash screen in my vb.net app, when I install the program on other computers, I randomly get this error right after the splash screen: ".net framework Unhandled exception : invoke or beginInvoke cannot be called on a control until the window handle has been created."

I know this error is associated to the splash screen because when I bypass it the error never occurs. I've tried some solutions online regarding this issue but I can't seem to get it working.

Thanks for the help
0
Comment
Question by:FCapo
  • 2
4 Comments
 
LVL 83

Expert Comment

by:CodeCruiser
ID: 39904157
You probably have some code in Load event of the main form which may need to be moved to Shown event instead.
0
 
LVL 85

Expert Comment

by:Mike Tomlinson
ID: 39904176
How is your splash screen displayed?  Are you using the default mechanism thru Project --> Properties?...or are you doing it manually?
0
 

Author Comment

by:FCapo
ID: 39904229
Hi,

Yes, I'm using the the default mechanism through Project --> Properties

Here's the code in my load event on my main form, the splash screen has absolutely no code in the load event :

        prjAccessData = New project
        prjManagDataSet = prjAccessData.getPrjAccessDataSet
        prjManagBindingsource = New BindingSource

        prjbudgetData = New project
        prjbudgetDataSet = prjbudgetData.getPrjbudgetDataSet
        prjBudgetBindingsource = New BindingSource

        hoursData = New project
        hoursDataSet = hoursData.getHoursDataSet
        hoursBindingsource = New BindingSource

        With prjManagBindingsource
            .DataSource = prjManagDataSet
            .DataMember = "projets"
        End With

        With hoursBindingsource
            .DataSource = hoursDataSet
            .DataMember = "FeuillesDeTemps"
        End With

        With prjBudgetBindingsource
            .DataSource = prjbudgetDataSet
            .DataMember = "budget"
        End With

        Label4.DataBindings.Add("text", prjManagBindingsource, "prjNumber")
        Label5.DataBindings.Add("text", prjManagBindingsource, "Mandats")
        Label7.DataBindings.Add("text", prjManagBindingsource, "prjAddr")
        Label8.DataBindings.Add("text", prjManagBindingsource, "cliName")
        Label9.DataBindings.Add("text", prjManagBindingsource, "prjContact")

        TabControl1.SelectedIndex = 2
        TabControl1.SelectedIndex = 1
        TabControl1.SelectedIndex = 0

        heuresTotal.DataBindings.Add("text", prjBudgetBindingsource, "heuresTotal")
        chargeTxt.DataBindings.Add("text", prjBudgetBindingsource, "bossHours")
        revTxt.DataBindings.Add("text", prjBudgetBindingsource, "revHours")
        dessTxt.DataBindings.Add("text", prjBudgetBindingsource, "dessHours")
        directTxt.DataBindings.Add("text", prjBudgetBindingsource, "directHours")
        techTxt.DataBindings.Add("text", prjBudgetBindingsource, "techHours")
        rechNotesTxt.DataBindings.Add("text", prjBudgetBindingsource, "notes")

        forageTxt.DataBindings.Add("Text", prjBudgetBindingsource, "forage", True, DataSourceUpdateMode.OnValidation, 0, "C")
        analTxt.DataBindings.Add("Text", prjBudgetBindingsource, "analyse", True, DataSourceUpdateMode.OnValidation, 0, "C")
        TextBox4.DataBindings.Add("Text", prjBudgetBindingsource, "recherche", True, DataSourceUpdateMode.OnValidation, 0, "C")

        Thread.CurrentThread.CurrentCulture = New CultureInfo("en-US", False)
        FeuillesDeTempsDataGridView.AllowUserToAddRows = False

        'Check if the computer is assigned :
        If My.Settings.empName = "" Then
            If MessageBox.Show("There is no Employee assigned to this workstation, would you like to assign one now?", "Feuille De Temps", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1) = Windows.Forms.DialogResult.Yes Then
                Form4.ShowDialog()
            Else
                Me.Close()
            End If
        Else
            ' if it is assigned then load up the employee information : 
            empName = My.Settings.empName
            Me.Text = My.Settings.empName
            Me.EmployeesTableAdapter1.FillBy(NCLDataSet.Employees, empName)
            empRate = NCLDataSet.Employees.Rows(0)(2)
        End If
     

Open in new window

0
 
LVL 83

Accepted Solution

by:
CodeCruiser earned 500 total points
ID: 39904245
I suspect it may be line 58

Me.Close()

You are closing current form before it even has finished loading. I would suggest you move all this code to Shown event which would also make you main form appear quicker (as it would show up quickly).
0

Featured Post

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

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

For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK (http://www.microsoft.com/en-us/download/details.aspx?id=27876) for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

919 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now