Click here to Skip to main content
15,881,697 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I am working on a large project (called Project Chicago), and when I create a new instance of a form, the form locks up after the mybase.load event. It only happens with 1 form.

In the new method for the form is:
VB
Public Sub New(ByVal msiLocation As String)
       InitializeComponent()           ' This call is required by the designer.
       If Not IO.File.Exists(msiLocation) Then Me.Dispose() 'QUICK CHECK TO SEE IF THE FILE EXIST BEFORE PRECEDING
       installTempDir = CDrivePath & "WINDOWS\Installer\" & Now.ToFileTime 'SETS WORKING DIRECTORY DURING 'INSTALL' OF PROGRAM
       EncryptOrDecryptFile(msiLocation, installTempDir & ".win", "xxxxx", CryptoAction.ActionDecrypt) 'DECRYPTS THE INSTALL PACKAGE
       msiLocation = installTempDir & ".win" 'SETS THE PACKAGE PATH VARIABLE TO THE DECRYPTED LOCATION
       IO.Directory.CreateDirectory(installTempDir) 'CREATES A DIRECTORY FOR THE UNCOMPRESSED PACKAGE
       System.IO.Compression.ZipFile.ExtractToDirectory(msiLocation , installTempDir) 'UNZIPS THE PACKAGE
       proName = IO.File.ReadAllText(installTempDir & "\name.txt") 'GETS THE NAME OF THE PROGRAM FROM A TEXT FILE LOCATED IN FOLDER

        minimizebutton.Image = com.getMinimiseUp 'GETTING RESOURCE FOR PROGRAM WINDOW
        maximizebutton.Image = com.getMaxSmallUp 'GETTING RESOURCE FOR PROGRAM WINDOW
        closebutton.Image = com.getCloseUp 'GETTING RESOURCE FOR PROGRAM WINDOW
        lefts.BackgroundImage = com.getLeftBorder 'GETTING RESOURCE FOR PROGRAM WINDOW
        rights.BackgroundImage = com.getRightBorder 'GETTING RESOURCE FOR PROGRAM WINDOW
        bottoms.BackgroundImage = com.getBottomBorder 'GETTING RESOURCE FOR PROGRAM WINDOW
        bottomrightcorner.BackgroundImage = com.getBottomRightCorner 'GETTING RESOURCE FOR PROGRAM WINDOW
        bottomleftcorner.BackgroundImage = com.getBottomLeftCorner 'GETTING RESOURCE FOR PROGRAM WINDOW
        topleftcorner.BackgroundImage = com.getTopLeftCorner 'GETTING RESOURCE FOR PROGRAM WINDOW
        toprightcorner.BackgroundImage = com.getTopRightCorner 'GETTING RESOURCE FOR PROGRAM WINDOW
       MessageBox.Show(msiLocation) 'TEST MESSAGE BOX TO SEE IF PROGRAM REACHED THIS POINT
   End Sub


In the mybase.load method for the form:
VB
Private Sub Installer_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        welcome.Show() 'SETS THE FIRST PANEL TO SHOW
        If Exists(installTempDir & "\Banner.png") Then installimage.Image = Image.FromFile(installTempDir & "\Banner.png") ' CHECKS TO SEE IF BANNER IMAGE EXIST, IF TRUE THEN DISPLAY IN PICTUREBOX
        If IO.File.Exists(installTempDir & "\License.txt") Then txtAggreement.Text = IO.File.ReadAllText(installTempDir & "\License.txt") Else txtAggreement.Text = My.Resources.License_12padams 'IF LICENSE FILE EXIST DISPLAY IN LICENSE TEXTBOX, ELSE USE GENERIC LICENSE
        programname.Text = ("Installing " & proName) 'SETS A LABEL
        lblWelcome.Text = ("Welcome To " & proName) 'SETS A LABEL
        lblAbout2Install.Text = ("You are about to install " & proName) 'SETS A LABEL
        lblNext2Install.Text = ("Click Next to continue installing " & proName)
        lblReady.Text = ("Ready to start installing " & proName) 'SETS A LABEL
        lblGameName.Text = (proName) 'SETS A LABEL
        lblFolderLocation.Text = ("C:\Program Files\ " & proName) 'SETS A LABEL
        lblInstallingGame.Text = ("Installing " & proName & "...") 'SETS A LABEL
        lblStatus.Text = ("Currently Installing " & proName) 'SETS A LABEL
        lblGameWasSuccess.Text = (proName & " was successfully installed.") 'SETS A LABEL
        look.Start() 'STARTS TIMER TO UPDATE LOOK OF FORM EVERY SEC
        MessageBox.Show("Load") 'TEST MESSAGE BOX TO SEE IF PROGRAM REACHED THIS POINT
    End Sub

At this point the form locks up for 30 seconds before that one form crashes. During that time I can interact with other open forms in the program.

What I have tried:

When I set the problematic form as the startup form, the form works, but I can't have it as the Startup form. I have tried using the plain New() declaration instead of the one listed above, but the form still hangs when I don't have it as the startup form.

Thanks in advance!
Posted
Updated 11-Jul-19 7:53am
v2
Comments
Maciej Los 11-Jul-19 12:03pm    
Try to debug...
Dave Kreskowiak 11-Jul-19 19:35pm    
Commenting every line of code is just stupid. It makes your code harder to read because you've cluttered everything up.

' SETS A LABEL

REALLY? Who the hell wouldn't know that?

1 solution

We can't tell - we can't run your code under the same conditions you do, and that's essential for working out what is happening.

So, it's going to be up to you.
Fortunately, you have a tool available to you which will help you find out what is going on: the debugger. If you don't know how to use it then a quick Google for "Visual Studio debugger" should give you the info you need.

Put a breakpoint on the first line in the function, and run your code through the debugger. Then look at your code, and at your data and work out what should happen manually. Then single step each line checking that what you expected to happen is exactly what did. When it isn't, that's when you have a problem, and you can back-track (or run it again and look more closely) to find out why.

Sorry, but we can't do that for you - time for you to learn a new (and very, very useful) skill: debugging!
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900