|
-
Mar 31st, 2006, 10:34 AM
#1
Thread Starter
New Member
[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:
Private Shared Sub UploadDocument_Click(ByVal sender As CommandBarButton, ByRef cancel As Boolean) Handles m_Button.Click
Try
GenericOfficeApplicationHelper.CheckActiveDocument()
Dim uploadForm As New UploadForm
Dim result As DialogResult
result = uploadForm.ShowDialog()
If result = DialogResult.OK Then
GUIHelper.ShowMessageBox("Document successfully uploaded", MessageBoxIcon.Information)
End If
Catch ex As Exception
GUIHelper.ShowMessageBox("Error: " & ex.Message, MessageBoxIcon.Error)
End Try
End Sub
-
Mar 31st, 2006, 11:21 AM
#2
Re: [02/03] ShowDialog crashes in office add-in
Try adding a 'Finally' block to your code to dispose of the form:
VB Code:
Private Shared Sub UploadDocument_Click(ByVal sender As CommandBarButton, ByRef cancel As Boolean) Handles m_Button.Click
Try
GenericOfficeApplicationHelper.CheckActiveDocument()
Dim uploadForm As New UploadForm
Dim result As DialogResult
result = uploadForm.ShowDialog()
If result = DialogResult.OK Then
GUIHelper.ShowMessageBox("Document successfully uploaded", MessageBoxIcon.Information)
End If
Catch ex As Exception
GUIHelper.ShowMessageBox("Error: " & ex.Message, MessageBoxIcon.Error)
Finally
uploadForm.Dispose
End Try
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!
-
Mar 31st, 2006, 12:04 PM
#3
Thread Starter
New Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|