Getting memory interop error in unity when loading mesh.

Issue #44 resolved
Usman Mehmood created an issue

I have build Dll for assimpNet and assimp native working fine in the vs project but getting this error in unity I have searched for a solution but no luck so far.

NotImplementedException: The method or operation is not implemented.
Assimp.MemoryInterop.ReadInline[T] (System.Void* pSrc) (at <01c4c61de25241cab0e7b484060311bb>:0)
Assimp.MemoryHelper.Read[T] (System.IntPtr pSrc, T& value) (at <01c4c61de25241cab0e7b484060311bb>:0)
Assimp.MemoryHelper.FromNativePointer[Managed,Native] (System.IntPtr ptr) (at <01c4c61de25241cab0e7b484060311bb>:0)
Assimp.Scene.FromUnmanagedScene (System.IntPtr scenePtr) (at <01c4c61de25241cab0e7b484060311bb>:0)
Assimp.AssimpContext.ImportFile (System.String file, Assimp.PostProcessSteps postProcessFlags) (at <01c4c61de25241cab0e7b484060311bb>:0)
AssimpManager.LoadMesh (System.String fileName) (at Assets/Scripts/AssimpManager.cs:58)
AssimpManager+<ShowLoadDialogCoroutine>d__11.MoveNext () (at Assets/Scripts/AssimpManager.cs:37)
UnityEngine.SetupCoroutine.InvokeMoveNext (System.Collections.IEnumerator enumerator, System.IntPtr returnValueAddress) (at C:/buildslave/unity/build/Runtime/Export/Scripting/Coroutines.cs:17)

Comments (9)

  1. Nicholas Woodfield repo owner

    As the Readme states, there is a build time dependency on ILPatcher that injects the implementation for the interop methods. You'd need to run that on the AssimpNet DLL you're building (not sure why you're not just using the output from building with VS though…)

  2. Nicholas Woodfield repo owner

    ILPatcher is a msbuild task that runs as a post-compile step in the visual studio setup.

  3. Usman Mehmood reporter

    Here is the log from VS Build.

    1>------ Build started: Project: AssimpNet, Configuration: Debug Any CPU ------
    1>AssimpNet -> C:\Projects\VS\AssimpDotNet\Downloaded\Starnick-assimpnet-35ca5a2b84f3\AssimpNet\bin\Debug\net35\AssimpNet.dll
    1> >> INFO: BEGIN patching assembly 'AssimpNet.dll'
    1> >> INFO: Symbols file found, will write out a new PDB file.
    1> >> INFO: Strong name key found. Signing assembly with 'AssimpKey.snk'.
    1>AssimpNet -> C:\Projects\VS\AssimpDotNet\Downloaded\Starnick-assimpnet-35ca5a2b84f3\AssimpNet\bin\Debug\net4\AssimpNet.dll
    1> >> INFO: Resolved AsssemblyReference 'mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'
    1> >> INFO: BEGIN patching assembly 'AssimpNet.dll'
    1> >> INFO: Symbols file found, will write out a new PDB file.
    1> >> INFO: Strong name key found. Signing assembly with 'AssimpKey.snk'.
    1> >> INFO: Removing Type 'Assimp.MemoryInterop'
    1> >> INFO: Resolved AsssemblyReference 'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'
    1> >> INFO: Removing Type 'Assimp.MemoryInterop'
    1> >> INFO: DONE patching assembly 'AssimpNet.dll'
    1> >> INFO: DONE patching assembly 'AssimpNet.dll'
    1>AssimpNet -> C:\Projects\VS\AssimpDotNet\Downloaded\Starnick-assimpnet-35ca5a2b84f3\AssimpNet\bin\Debug\netstandard1.3\AssimpNet.dll
    1> >> INFO: BEGIN patching assembly 'AssimpNet.dll'
    1> >> INFO: Symbols file found, will write out a new PDB file.
    1> >> INFO: Strong name key found. Signing assembly with 'AssimpKey.snk'.
    1> >> INFO: Resolved AsssemblyReference 'System.Runtime, Version=4.0.20.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'
    1> >> INFO: Removing Type 'Assimp.MemoryInterop'
    1> >> INFO: DONE patching assembly 'AssimpNet.dll'
    1>Successfully created package 'C:\Projects\VS\AssimpDotNet\Downloaded\Starnick-assimpnet-35ca5a2b84f3\AssimpNet\bin\Debug\AssimpNet.4.1.0.nupkg'.
    1>C:\Program Files\dotnet\sdk\3.0.100\Sdks\NuGet.Build.Tasks.Pack\buildCrossTargeting\NuGet.Build.Tasks.Pack.targets(198,5): warning NU5125: The 'licenseUrl' element will be deprecated. Consider using the 'license' element instead.
    1>C:\Program Files\dotnet\sdk\3.0.100\Sdks\NuGet.Build.Tasks.Pack\buildCrossTargeting\NuGet.Build.Tasks.Pack.targets(198,5): warning NU5048: The 'PackageIconUrl'/'iconUrl' element is deprecated. Consider using the 'PackageIcon'/'icon' element instead. Learn more at https://aka.ms/deprecateIconUrl
    1>Done building project "AssimpNet.csproj".
    ========== Build: 1 succeeded, 0 failed, 0 up-to-date, 0 skipped ==========

  4. Usman Mehmood reporter

    Also can you please point me to steps for building universal dll and dylib for assimp.

  5. Nicholas Woodfield repo owner

    That log output looks like what it should be doing when compiling from VS…are you sure you’re using that DLL in unity? I’m not sure what you mean by universal DLL. If you want to build a new dylib for assimp native, refer to the native documentation → https://github.com/assimp/assimp/blob/master/Build.md

    Why are the binaries (both managed and native) from the nuget not good enough to use?

  6. Usman Mehmood reporter

    Thanks, Solved the issue, i was required to build for x64 release plus the dll that I was using from unity plugin folder was not updated for me and sorry I forgot to mention that I was trying to build for version 5.0 and as far as i’v searched there is no 5.0 nuget version yet.
    also thanks for point me to the documentation I am try to build fat/universal dylib for mac this will help.

  7. Log in to comment