Try Catch errors locking Excel

R

Rob

Environment...
Visual Studio 2005
VSTO 2005 SE
MS Office 2003 Professional (SP3)

So here's the thing. We had some old OBA's over Excel that we updated from
..net 1.1 to .net 2.0. In the update, we found that the "ThisWorkbook" class
was moved to a new class file, and the new "ThisWorkbook" class for VSTO 2005
over .Net 2.0 was implemented. The previous "ThisWorkbook" class was named
"OldWorkbook" or something to that effect and with in the new
"ThisWorkbook"'s Open event event, "OldWorkbook" as instantiated and brought
up.

Now our Excel OBA has an action where it has to make remote calls to a web
service and retrieve some data. I'm finding that my Catch portions of my Try
Catch Finally block are, in a way, being skipped. It's freakishly odd.

Example:

Public Class OldWorkBook

Public Sub ReadSomeData(byval args() as object)
Dim myData As String = "My Starting."
Try

'Here is where i use a controller object (MyController = Global Var)
'and call the webservice expecting to get some data back.
myData = MyController.CallWebService(args)

Catch mySoap As SoapException
messagebox.show(mysoap.message)
messagebox.show(mysoap.tostring)
Catch myError As Exception
messagebox.show(myError.message)
messagebox.show(myError.tostring)
Finally
'and I do some clean up, for example
myData = nothing
End Try

End Class

The problem here is that the Messagebox.Show calls in my Catches only some
times get called. Other times, the Messagebox.show calls don't seem to get
hit at all. However the Finally block always gets hit. MyData will always
come back as nothing.

I've even tried to declare exception variables outside of the Try Catch
statement, and set them with in the catch blocks. But for some reason even
those variables don't get populated on exception. I'm at a complete loss
here.

Other example
dim MyOuterEx as Exception
dim MyOuterSoapEx as SoapException
Try

'Here is where i use a controller object (MyController = Global Var)
'and call the webservice expecting to get some data back.
myData = MyController.CallWebService(args)

Catch mySoap As SoapException
myOuterSoapEx = mySoap
messagebox.show(mysoap.message)
messagebox.show(mysoap.tostring)
Catch myError As Exception
myOuterEx = myError
messagebox.show(myError.message)
messagebox.show(myError.tostring)
Finally
'and I do some clean up, for example
'myOuter exception variables are nothing even though an exception has occured.
myData = nothing
End Try

I know that an exception is occuring because "Sometimes" I get the
messagebox.show calls to fire and show me an error. But even then "myOuter"
exceptions aren't getting populated.

Other Symptoms:

Excel it self does a kind of partial lock up. Nothing in excel is usable
until I change my active screen to another application then back to excel
again

The MessageBox.Show calls get shown out of order every other attempt to run
this procedure.

If I put the Try Catch statement into the CallWebService call of my
Controller class, the messagebox calls show exactly correct every time and I
get no issue with Excel. However this breaks the MVC pattern that my company
tries to adhere to.

Any suggestions here would be great.
 
R

Rob

Just to add to this, the issue, after further research points to an issue
where I simply can't reliably pass back an exception from a controller class.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top