Results 1 to 3 of 3

Thread: [02/03] ShowDialog crashes in office add-in

  1. #1

    Thread Starter
    New Member
    Join Date
    Mar 2006
    Posts
    2

    Post [02/03] ShowDialog crashes in office add-in

    Hi,

    I created a VB.NET add-in for the ms office applications word, excel and outlook. It creates a toolbar with one button which displays a dialog to store the document in a database. I use VB.NET version 1.1 (2003) and office 2000.

    It works fine when i use the .Show() method on te userform but crashes when i use the .ShowDialog() method. It actually works the first time but crashes the second time AFTER (???) the method has correctly completed. Something with closing the form again i think...

    This is the exact error message: "The exception unknown software exception (0xc015000f) occurred in the application at location 0x77f457b5."Anyone knows what I could be doing wrong?Below my code with the call...

    Also I'm having problems debugging. In word and excel it works but outlook just closes on opening without hitting the OnConnection method. Anyone knows what to try?

    Thanks in advance
    Koen

    -------------------------------------
    VB Code:
    1. Private Shared Sub UploadDocument_Click(ByVal sender As CommandBarButton, ByRef cancel As Boolean) Handles m_Button.Click
    2.   Try
    3.     GenericOfficeApplicationHelper.CheckActiveDocument()
    4.  
    5.     Dim uploadForm As New UploadForm
    6.     Dim result As DialogResult
    7.  
    8.     result = uploadForm.ShowDialog()
    9.  
    10.     If result = DialogResult.OK Then
    11.  
    12.       GUIHelper.ShowMessageBox("Document successfully uploaded", MessageBoxIcon.Information)
    13.     End If
    14.  
    15.   Catch ex As Exception
    16.     GUIHelper.ShowMessageBox("Error: " & ex.Message, MessageBoxIcon.Error)
    17.   End Try
    18. End Sub

  2. #2
    Fanatic Member Andy_P's Avatar
    Join Date
    May 2005
    Location
    Dunstable, England
    Posts
    669

    Re: [02/03] ShowDialog crashes in office add-in

    Try adding a 'Finally' block to your code to dispose of the form:
    VB Code:
    1. Private Shared Sub UploadDocument_Click(ByVal sender As CommandBarButton, ByRef cancel As Boolean) Handles m_Button.Click
    2.   Try
    3.     GenericOfficeApplicationHelper.CheckActiveDocument()
    4.  
    5.     Dim uploadForm As New UploadForm
    6.     Dim result As DialogResult
    7.  
    8.     result = uploadForm.ShowDialog()
    9.  
    10.     If result = DialogResult.OK Then
    11.  
    12.       GUIHelper.ShowMessageBox("Document successfully uploaded", MessageBoxIcon.Information)
    13.     End If
    14.  
    15.   Catch ex As Exception
    16.     GUIHelper.ShowMessageBox("Error: " & ex.Message, MessageBoxIcon.Error)
    17.  
    18.   Finally
    19.      uploadForm.Dispose
    20.   End Try
    21. End Sub
    When you close a form using 'ShowDialog' I believe the form is only hidden and does not actually have its resources released so you need to explicitly 'Dispose' of it when you are finished with it.

    Hope it helps!
    Using Windows XP Home sp3
    Mucking around with C# 2008 Express
    while ( this.deadHorse ) { flog( ); }


  3. #3

    Thread Starter
    New Member
    Join Date
    Mar 2006
    Posts
    2

    Re: [02/03] ShowDialog crashes in office add-in

    I tried disposing the form after i don't need it anymore but it did not change anything.

    Remember that the error occurs after the event handler method is fully executed. It does not show the error message through the messagebox in the catch statement. That happens at a later expression...

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width