My list box is not showing using v4

Wondering if anyone may be seeing the same... I am trying to pop up a listbox but now with v4 its not showing up... Now the odd thing is if i add something to just throw up a basic message box first then it shows up.

This is what im doing and its not showing up... I know its there because the install process is hanging waiting for a response but im not seeing the listbox.

This is what im using....
#Populate Site list array from Sitelist.txt
$SiteList = Get-Content -Path "$($adtSession.DirFiles)\Sitelist.txt"

    #List box to choose site if app has not already been installed on the machine before.
    Add-Type -AssemblyName System.Windows.Forms
    Add-Type -AssemblyName System.Drawing

    $form = New-Object System.Windows.Forms.Form
    $form.Text = 'Site Picker'
    $form.Size = New-Object System.Drawing.Size(350, 250)
    $form.StartPosition = 'CenterScreen'

    $OKButton = New-Object System.Windows.Forms.Button
    $OKButton.Location = New-Object System.Drawing.Point(130, 160)
    $OKButton.Size = New-Object System.Drawing.Size(75, 23)
    $OKButton.Text = 'OK'
    $OKButton.DialogResult = [System.Windows.Forms.DialogResult]::OK
    $form.AcceptButton = $OKButton
    $form.Controls.Add($OKButton)

    $label = New-Object System.Windows.Forms.Label
    $label.Location = New-Object System.Drawing.Point(10, 20)
    $label.Size = New-Object System.Drawing.Size(320, 30)
    $label.Text = 'A previous version was not detected. Please choose a site from the list.'
    $form.Controls.Add($label)

    $listBox = New-Object System.Windows.Forms.ListBox
    $listBox.Location = New-Object System.Drawing.Point(95, 70)
    $listBox.Size = New-Object System.Drawing.Size(160, 20)
    $listBox.Height = 80

    foreach ($item in ($Sitelist)) {
        $listBox.Items.Add($item)
    }

    $form.Controls.Add($listBox)
    $form.Topmost = $true
    $result = $form.ShowDialog()
    [string]$IMSINIServer = $listBox.SelectedItem

NOW... What is not making sense if i put this first....

System.Windows.MessageBox::Show('Hello')

I get the popup with hello, and then i will see the list box.

Of course i dont want a box and then the listbox, i just want the listbox....

Any help appreciated!

You haven't really said what the problem is, however your code seems to run and work fine:

Yes, it worked fine using 3.10 but with the new 4.1 when i run it on one of my test VMWare machines the box doesn’t show up. If i use a command for a simple message box AND then do the list box it shows up... I guess I’m asking if there is some kind of initialization that’s needed with v4 that v3 didn’t need for things like a list box.

I literally just pasted your code into a new PowerShell window, with my own SiteList definition as that wasn't provided by yourself.

How are you running your code? Given what you're saying, I can only imagine you're running your code as SYSTEM but expecting some automagic to show your UI to the user. This works for our UI as its all routed through our client/server process. It won't work for your UI.