| Author |
Message |
Guest
|
Posted:
Mon Dec 27, 2004 11:17 pm Post subject:
API code crashes |
|
|
I'm using SW2004 SP4.1 & VB.NET 7.1.3088.
I have written a program that opens several SW drawings and reports
some information to an excel spreadsheet. Sometimes the code functions
correctly, sometimes it crashes. The crashes occur in different parts
of the code (always on a SolidWorks function call).
Does anyone have any suggestions for things that might be causing the
crashes? Are there any best-practices that I might be missing?
Thanks.
|
|
| Back to top |
|
 |
Evan T. Basalik
Guest
|
Posted:
Tue Dec 28, 2004 12:00 am Post subject:
Re: API code crashes |
|
|
Can you post some of your code and where it crashes?
I crash SW regularly while using both VB and VB.NET, but it is usually b/c I
am asking it to do something it does not like to do. I have found them both
to be very stable in production.
Evan
<dan9298@hotmail.com> wrote in message
news:1104171465.228490.247540@f14g2000cwb.googlegroups.com...
| Quote: | I'm using SW2004 SP4.1 & VB.NET 7.1.3088.
I have written a program that opens several SW drawings and reports
some information to an excel spreadsheet. Sometimes the code functions
correctly, sometimes it crashes. The crashes occur in different parts
of the code (always on a SolidWorks function call).
Does anyone have any suggestions for things that might be causing the
crashes? Are there any best-practices that I might be missing?
Thanks.
|
|
|
| Back to top |
|
 |
Dan
Guest
|
Posted:
Tue Dec 28, 2004 12:33 am Post subject:
Re: API code crashes |
|
|
Evan, thanks for the reply.
The code crashes on lines such as these (these are examples, not my
entire code):
bStatus = oDrawingModel.ShowConfiguration2(sConfigName)
oDrawingView = oSwDrawing.GetFirstView()
oSolidWorksApplication.CloseDoc(sConfigName & ".slddrw")
The error I usually get is:
An unhandled exception of type
'System.Runtime.InteropServices.COMException' occurred in
microsoft.visualbasic.dll
Additional information: The server threw an exception.
Using the same test scenarios, it sometimes works, and sometimes
crashes.
Any ideas?
|
|
| Back to top |
|
 |
Paul Delhanty
Guest
|
Posted:
Wed Dec 29, 2004 2:14 am Post subject:
Re: API code crashes |
|
|
Try wrapping your code in a Try, Catch, Finally block:
Try
bStatus = oDrawingModel.ShowConfiguration2(sConfigName)
oDrawingView = oSwDrawing.GetFirstView()
oSolidWorksApplication.CloseDoc(sConfigName & ".slddrw")
Catch excCom As COMException
' TODO: Handle COM exceptions.
Catch exc As Exception
' TODO: Handle errors.
Finally
' TODO: Clean-up code goes here.
End Try
That should stop your application crashing immediately. Then put a break
point on the Catch for COMException and inspect the values of
COMException.Message and COMException.HResult. They should give you some
idea about the type of COM error that you are getting back from SolidWorks.
MSDN Documentation on COMException is here:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfSystemRuntimeInteropServicesCOMExceptionClassTopic.asp?frame=true |
|
| Back to top |
|
 |
|
|
|
|