Solved

vb.net splash screen invoke error

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

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

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…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
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…

743 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

16 Experts available now in Live!

Get 1:1 Help Now