Click here to Skip to main content
15,914,392 members
Home / Discussions / Visual Basic
   

Visual Basic

 
GeneralRe: URGENT HELP Pin
Christian Graus18-Sep-09 19:19
protectorChristian Graus18-Sep-09 19:19 
AnswerRe: URGENT HELP Pin
Christian Graus18-Sep-09 15:21
protectorChristian Graus18-Sep-09 15:21 
AnswerRe: URGENT HELP Pin
Luc Pattyn18-Sep-09 15:43
sitebuilderLuc Pattyn18-Sep-09 15:43 
QuestionForm that is showing dialog box is disabled - looses behavior of when showing dialogbox Pin
nlarson1118-Sep-09 10:02
nlarson1118-Sep-09 10:02 
AnswerRe: Form that is showing dialog box is disabled - looses behavior of when showing dialogbox Pin
Eddy Vluggen18-Sep-09 10:29
professionalEddy Vluggen18-Sep-09 10:29 
GeneralRe: Form that is showing dialog box is disabled - looses behavior of when showing dialogbox Pin
nlarson1118-Sep-09 10:37
nlarson1118-Sep-09 10:37 
AnswerRe: Form that is showing dialog box is disabled - looses behavior of when showing dialogbox Pin
nlarson1118-Sep-09 11:13
nlarson1118-Sep-09 11:13 
Questionproblem with System.InvalidOperationException - enabling buttons from within event sub Pin
abiemann18-Sep-09 9:03
abiemann18-Sep-09 9:03 
I don't know why I'm getting this InvalidOperationException - so I'm really eager to find an explanation and learn from this bug.

the code:

Imports myprog.Control_DataCapsule 'this is a control containing several text boxes and buttons
Class Window1
Private MSVMobject As ClassMSVM = Nothing

    Private Sub Window1_Loaded()

        Try
            MSVMobject = New ClassMSVM
            AddHandler MSVMobject.VMexited, AddressOf Me.MSVM_VMexited
        Catch
            MsgBox("MSVM is not available on this machine.")
        End Try

    End Sub

    Friend Sub MSVM_VMexited()
        .
        .
        .
        Dim OdataCapsule As Control_DataCapsule 'causes an invalidOperationException
        .
        .
        .
    End Sub

    Private Sub StackPanel_ButtonClick(ByVal sender As Object, ByVal e As RoutedEventArgs)

        MSVMobject.StartVM()

    End Sub

End Class



Public Class ClassMSVM

    Public Event VMexited()

    Public Sub StartVM()
            .
            .
            .
            Dim myProcess As Process = New Process()
            myProcess.StartInfo.FileName = strStartupPath + "vmconnect.exe"
            myProcess.StartInfo.Arguments = "localhost " + VMname
            myProcess.StartInfo.WindowStyle = ProcessWindowStyle.Hidden
            myProcess.StartInfo.CreateNoWindow = True
            myProcess.EnableRaisingEvents = True
            AddHandler myProcess.Exited, AddressOf Me.VMconnectExited
            myProcess.Start()
    End Sub

    Friend Sub VMconnectExited(ByVal sender As Object, ByVal e As System.EventArgs)

        Dim myProcess As Process = DirectCast(sender, Process)
        myProcess.Close()

        'trigger event that will be captured in Window1.xaml.vb
        RaiseEvent VMexited()

    End Sub

End Class

'in a separate vb file...
Partial Public Class Control_DataCapsule

    'member variables
    Public m_iIndexInList As Integer

    Public Sub New()
        ' This call is required by the Windows Form Designer.
        InitializeComponent()

        m_iIndexInList = 0
    End Sub
    '*** SET ***
    Public Sub SetTitle(ByVal strTitle As String)
        Me.TextBoxTitle.Text = strTitle
    End Sub
    .
    .
    .
End Class



What happens is that after I click a button in my stackpanel, MSVM is launched. This works great.
Once I close MSVM, the MSVM_VMexited() sub starts to execute but as soon as it gets to "Dim OdataCapsule As Control_DataCapsule" an InvalidOperation Exception is thrown.

why is it that this exception takes place ?


EDIT:
the purpose of doing the "Dim OdataCapsule As Control_DataCapsule" is so that I can DirectCast() each control in my StackPanel and enable buttons.
AnswerRe: problem with System.InvalidOperationException - enabling buttons from within event sub Pin
abiemann18-Sep-09 9:35
abiemann18-Sep-09 9:35 
AnswerRe: problem with System.InvalidOperationException - enabling buttons from within event sub Pin
abiemann18-Sep-09 9:58
abiemann18-Sep-09 9:58 
AnswerRe: problem with System.InvalidOperationException - enabling buttons from within event sub Pin
Luc Pattyn18-Sep-09 10:22
sitebuilderLuc Pattyn18-Sep-09 10:22 
GeneralRe: problem with System.InvalidOperationException - enabling buttons from within event sub Pin
abiemann21-Sep-09 8:32
abiemann21-Sep-09 8:32 
GeneralRe: problem with System.InvalidOperationException - enabling buttons from within event sub Pin
Luc Pattyn21-Sep-09 8:36
sitebuilderLuc Pattyn21-Sep-09 8:36 
QuestionHelp with RDL report! Pin
bugor7718-Sep-09 5:25
bugor7718-Sep-09 5:25 
QuestionWebBrowser Control Pin
SoftDev4U18-Sep-09 5:01
SoftDev4U18-Sep-09 5:01 
AnswerRe: WebBrowser Control Pin
Dave Kreskowiak18-Sep-09 5:15
mveDave Kreskowiak18-Sep-09 5:15 
GeneralRe: WebBrowser Control Pin
SoftDev4U18-Sep-09 5:22
SoftDev4U18-Sep-09 5:22 
QuestionRE:Missing Oracle InProc server 5.0 type library Pin
Lee Mwangi18-Sep-09 4:32
Lee Mwangi18-Sep-09 4:32 
AnswerRe: RE:Missing Oracle InProc server 5.0 type library Pin
Lee Mwangi18-Sep-09 4:33
Lee Mwangi18-Sep-09 4:33 
QuestionMessage Box Pin
RyJaBy18-Sep-09 2:48
RyJaBy18-Sep-09 2:48 
AnswerRe: Message Box Pin
Johan Hakkesteegt18-Sep-09 3:06
Johan Hakkesteegt18-Sep-09 3:06 
AnswerRe: Message Box Pin
Eddy Vluggen18-Sep-09 10:36
professionalEddy Vluggen18-Sep-09 10:36 
QuestionScroll bar for showing waveform data Pin
D_A_V_E18-Sep-09 2:43
D_A_V_E18-Sep-09 2:43 
AnswerRe: Scroll bar for showing waveform data Pin
Johan Hakkesteegt18-Sep-09 3:17
Johan Hakkesteegt18-Sep-09 3:17 
AnswerRe: Scroll bar for showing waveform data Pin
Dave Kreskowiak18-Sep-09 3:44
mveDave Kreskowiak18-Sep-09 3:44 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.