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.

Reply to
dan9298
Loading thread data ...

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

Reply to
Evan T. Basalik

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?

Reply to
Dan

PolyTech Forum website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.