0

I am using vtk in c#. Access violation exception occured while i was executing a line of code such as "this.SetMinimumU(0.0);"

Error detail and code snippet is below mentioned. Please suggest me if anyone faced this issue.

An unhandled exception of type 'System.AccessViolationException' occurred in Kitware.VTK.dll

Additional information: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.

Code snippet is below

public class AcessViolation : vtkParametricFunction     
    { 
        static IntPtr ptr=new IntPtr(); 
        public AcessViolation():base(ptr,true,true) 
       { 
           try 
           {                 
               this.SetMinimumU(0.0);             
           } 
           catch (Exception ex) 
           { 
           } 
       } 
    }
nicolezk
  • 106
  • 1
  • 6

2 Answers2

0

See How to handle AccessViolationException

You may need to use the

HandleProcessCorruptedStateExceptions

decorator

But of course it will be better to avoid triggering the exception...

Community
  • 1
  • 1
maazza
  • 7,016
  • 15
  • 63
  • 96
0

From the documentation, vtkParametricFunction is an abstract class, so you can try to instantiate one of the derived classes http://www.vtk.org/Wiki/VTK/Examples/CSharp/GeometricObjects/ParametricObjects or create a new derived class from it (I have no idea if it's possible with wrapping though).

Remember also to instantiate the vtk classes with New, like in the linked example (I don't recognize the constructor in your code snippet, but also I am not familiar with c#, so excuse me if it was already correct)

lib
  • 2,918
  • 3
  • 27
  • 53