Receiving an error message while finding a length of a Bspline curve

Hi ,
I have written the following code to find the length a BSpline curve .
Handle(Geom2d_BSplineCurve) SPL3 = .......
.
.
.
GProp_GProps myProps;
BRepGProp::LinearProperties(edge2, myProps);
Standard_Real fLength = myProps.Mass();

but while debugging , i am receiving the following error message ..

---------------------------
Microsoft Visual C++
---------------------------
Unhandled exception in Sampel_OCCSDI.exe (TKG3D.DLL): 0xC0000005: Access Violation.
---------------------------
OK
---------------------------

Can any one provide the right solution to fix the problem.

Regards
Senthil

P Dolbey's picture

I have to say that I've seen this type of "Access Violation" message so many times and for so many reasons. From your message you provide no useful information to help diagnose this problem. Yet you have one of the best debuggers available in your hands.

But here's some advice.

First ensure that have a version of OCC compiled with your target compiler.
Next ensure you have a debug version of OCC complied - this will enable you to single step through the OCC source.
Now run the program in debug mode. When it breaks use the call stack to find the lowest calling routine IN YOUR CODE to the function with the access violation - this can help overcome loosing your way via exception handlers. Of course if the access violation is in your own code, you'll need to fix it yourself!
Put a break point here.
Re-run the application till you hit the break point.
Now single step your way though the offending function until it breaks, looking for possible problems - the "Auto's" window helps you with this.
If you can determine the cause of the problem in the OCC code, and can fix it then publish it here for the benefit of the community - the webmasters monitor this forum for such fixes.
If you can't, then ask for help, but now show where the code has broken and any additional information you have identified - this will give people half a chance to help diagnose.

Best I can do with the information given.

Pete