Solved

vb.net splash screen invoke error

Posted on 2014-03-04
4
631 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

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

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

Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

773 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