API code crashes
CADForums.net Forum Index CADForums.net
Discussion of AutoCAD and other CAD software.
 
 FAQFAQ   MemberlistMemberlist     RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
 
Google
 
Web cadforums.net
API code crashes

 
Post new topic   Reply to topic    CADForums.net Forum Index -> SolidWorks
Author Message
Guest






Posted: Mon Dec 27, 2004 11:17 pm    Post subject: API code crashes Reply with 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
Evan T. Basalik
Guest





Posted: Tue Dec 28, 2004 12:00 am    Post subject: Re: API code crashes Reply with quote

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 Reply with quote

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 Reply with quote

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
 
Post new topic   Reply to topic    CADForums.net Forum Index -> SolidWorks All times are GMT
Page 1 of 1

 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum




Windows Server DSP VoIP Electronics New Topics
Contact Us
Powered by phpBB