Hi all, I am developing .Net plugin for Grasshopper and unit tests for it.
When I try to create NurbsSurface within my unit tests, I get an AccessViolationException.
Result Message:
Test method Geometry_09 threw exception:
System.AccessViolationException: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
Result StackTrace:
at UnsafeNativeMethods.ON_NurbsSurface_SurfaceFromPoints(Point3d[] _array_pts, Int32 uCount, Int32 vCount, Int32 uDegree, Int32 vDegree)
at Rhino.Geometry.NurbsSurface.CreateFromPoints(IEnumerable`1 points, Int32 uCount, Int32 vCount, Int32 uDegree, Int32 vDegree)
The same situation is when I try to open .gh document. Any calls to rhino unsafe methods or constructors cause this exception.
Result Message:
Test method TestMethod1 threw exception:
System.AccessViolationException: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
Result StackTrace:
at UnsafeNativeMethods.CRhinoPlugInManager_PlugInCount()
at Rhino.PlugIns.PlugIn.GetInstalledPlugInFolders()
at Grasshopper.Folders.get_AssemblyFolders()
at Grasshopper.Kernel.GH_ComponentServer.ExternalFiles(Boolean testGrasshopperCollisions, Boolean testExternalCollisions)
at Grasshopper.Kernel.GH_ComponentServer.LoadExternalFiles()
at Grasshopper.Instances.get_ComponentServer()
at Grasshopper.Kernel.GH_Document.ReadObjectList(GH_IReader reader, String collection, List`1 libraries)
at Grasshopper.Kernel.GH_Document.Read(GH_IReader reader)
at GH_IO.Serialization.GH_Archive.ExtractObject(GH_ISerializable target, String target_name)
at Grasshopper.Kernel.GH_DocumentIO.OpenInternal(String filePath)
at Grasshopper.Kernel.GH_DocumentIO.Open(String filePath)
I’m seeing this issue only within unit tests. I copied RhinoCommon and its 8 dependencies to my output folder and run unit test using visual studio (vstest.console.exe).
When I run the same code within my plugin, it works fine.
How can I fix this AccessViolationException, to make my test run successfully ?
What I am doing wrong?
Maybe anybody has been faced with such a problem.
Any help would be appreciated.