assimp-net icon indicating copy to clipboard operation
assimp-net copied to clipboard

AssimpContext.ExportFile broken

Open Xeeynamo opened this issue 5 years ago • 3 comments

Using ExportFile method always results to a crash, regardless the format I am exporting to: using var ctx = new AssimpContext(); ctx.ExportFile(new Scene(), fileName, "obj");

Exception: System.AccessViolationException: 'Attempted to read or write protected memory. This is often an indication that other memory is corrupt.'

I am using .Net Core 3.1 and AssimpNet 4.1.0.

Xeeynamo avatar Aug 09 '20 19:08 Xeeynamo

Hi. It seems that we need at least RootNode:

Scene scene = new Scene();
scene.RootNode = new Node("Root");

using var ctx = new AssimpContext();
ctx.ExportFile(scene, fileName, "obj");

I have found test case that it creats scene from scratch.

https://github.com/assimp/assimp-net/blob/ed18dda93c3654b9c60b68ba8a2f91efdb1e8968/AssimpNet.Test/AssimpContextTestFixture.cs#L75-L101

kenjiuno avatar Aug 13 '20 08:08 kenjiuno

Thank you @kenjiuno , that was definitively the case.

Although it would be very good if this library was throwing a proper exception message for it (eg. ArgumentException rather than AccessViolationException). I am not going to close this issue, unless the maintainer of this repo would think that argument validation is not required.

Xeeynamo avatar Aug 13 '20 09:08 Xeeynamo

Access violation could be the native lib just assumes it exists. More validation and error messages are always welcomed.

This repo isn't the official assimpnet one, and is very old compared to the last few nuget releases. I'm on bit bucket. Several times now I've requested transfer of ownership or admin of this github repo without any action.

Feel free to do a PR for extra validation here https://bitbucket.org/Starnick/assimpnet/src

Starnick avatar Aug 14 '20 02:08 Starnick