CSharp sample gives AccessViolationException

I am running VS2010 Pro with Windows 7 Pro 64-bit, with version 6.7.0 of OpenCascade.

I rebuilt the OCCT libraries in debug mode, win32. No reported problems during the lengthy rebuild.

Then I rebuilt the CSharp sample solution, excluding the WPF project. In order to do this, I had to change the .NET framework version of Winforms to 4.0 because that was the version specified by the OCCTProxy project and VS2010 would not allow me to proceed with mismatched versions as specified in the downloaded sample project (I see no way to change the .NET framework version of the OCCTProxy project).

Then I invoked the compiled sample program and, after minimal activity, I get AccessViolationException when I exit the program. The exception occurs at line 88 of Handle_Standard_Transient.hxx ("EndScope()" in a destructor).

I get this error even if all I do is create a new document (via File/New) and then immediately exit the program.

The relevant output states:

TKOpenGl.WinSystem | Type: Error | ID: 6 | Severity: High | Message:
wglMakeCurrent() has failed. The handle is invalid.

A first chance exception of type 'System.AccessViolationException' occurred in OCCTProxy.dll

Forum supervisor's picture

Dear Michael,
We confirm that the problem (exception on application exit due to incorrect order of destruction of OpenGl-related objects, reported by debugger) exists in OCCT 6.7.0. It should not appear in Release builds.
It is fixed in current master (tested on vc10 x64), hence the fix will be in the next version of OCCT.
Best regards
FSR

dev5000's picture

I'm experiencing this bug in OCCT 6.7.1. Is the fix supposed to be in there? If not, can you provide the code change that would prevent this problem from happening?

Thank you!

dev5000's picture

Never mind -- I think the problem was on my end. Everything seems to be OK with 6.7.1.

haidong ma's picture

I got same issue.

I'm in C++ win10 enviroment . when I click "exit" button,I got  this error too.

finally, before "exit", I call V3d_view::Remove ().

It solved my problem.