Skip to content

Compatibility issues Nuget restore #2

Open

Description

@awesomeinsight

Hi and thanks for providing this Draco wrapper!

I did some experiments with the Nuget package and got the following warning during build (using .net 8 console application):

[NU1701] Package 'Draco_transcoder 3.3.4' was restored using '.NETFramework,Version=v4.6.1, .NETFramework,Version=v4.6.2, .NETFramework,Version=v4.7, .NETFramework,Version=v4.7.1, .NETFramework,Version=v4.7.2, .NETFramework,Version=v4.8, .NETFramework,Version=v4.8.1' instead of the project target framework 'net8.0'. This package may not be fully compatible with your project.

Is it possible that you support .net standard (2.0) for this package?
https://learn.microsoft.com/de-de/dotnet/standard/net-standard?tabs=net-standard-2-0

Or do you think that there is any other easy fix for this problem?

Maybe this is also related to an x86 <--> x64 issue.
Currently I cannot use the Nuget at all when I for example try to execute the code from your documentation I get a:
Unhandled exception. System.BadImageFormatException: Could not load file or assembly '*/bin/Debug/net8.0/DracoWrapper.dll'. An attempt was made to load a program with an incorrect format.

Activity

  1. changed the title [-]Compatibility issues NuGet restore[/-] [+]Compatibility issues Nuget restore[/+] on Feb 20, 2024
  2. rosend commented on Apr 22, 2024

    @rosend

    i had the same problem :(

  3. xiaoyuvax commented on Jun 17, 2024

    @xiaoyuvax

    same problem
    Can this project owner make it compatible with net core and above?

  4. vnoves commented on Jul 11, 2024

    @vnoves
    Member

    @awesomeinsight I have already updated the package to work with .net core, but the issue that you are mentioning is not due to the framework version but a problem related to the mixed-use of unmanaged Code(c++) and managed Code(C#).

    I experienced the same problem and endep up solving it in the following way:

    public class NonCollectibleAssemblyLoadContext : AssemblyLoadContext
        {
            public NonCollectibleAssemblyLoadContext() : base(isCollectible: false)
            {
            }
        }
    
    
            var loadContext = new NonCollectibleAssemblyLoadContext();
                var assemblyPath = @"C:\location\of\your\dll\DracoWrapper.dll";
                Assembly mixedModeAssembly = loadContext.LoadFromAssemblyPath(assemblyPath);
    
                var gltfDecoderType = mixedModeAssembly.GetType("dracowrapper.GltfDecoder");
                var gltfDecoderInstance = Activator.CreateInstance(gltfDecoderType);
    
                var decodeFromFileToSceneMethod = gltfDecoderType.GetMethod("DecodeFromFileToScene");
                var res = decodeFromFileToSceneMethod.Invoke(gltfDecoderInstance, new object[] { fileToCompress });
                var resType = res.GetType();
                var valueMethod = resType.GetMethod("Value");
                var scene = valueMethod.Invoke(res, null);
    
                var dracoCompressionOptionsType = mixedModeAssembly.GetType("dracowrapper.DracoCompressionOptions");
                var dracoCompressionOptionsInstance = Activator.CreateInstance(dracoCompressionOptionsType);
    
                var sceneUtilsType = mixedModeAssembly.GetType("dracowrapper.SceneUtils");
                var setDracoCompressionOptionsMethod = sceneUtilsType.GetMethod("SetDracoCompressionOptions");
                setDracoCompressionOptionsMethod.Invoke(null, new object[] { dracoCompressionOptionsInstance, scene });
    
                var gltfEncoderType = mixedModeAssembly.GetType("dracowrapper.GltfEncoder");
                var gltfEncoderInstance = Activator.CreateInstance(gltfEncoderType);
                var encodeSceneToFileMethod = gltfEncoderType.GetMethod("EncodeSceneToFile");
                encodeSceneToFileMethod.Invoke(gltfEncoderInstance, new object[] { scene, fileToCompressTemp });
    
    

    I hope this helps

  5. vnoves commented on Jul 11, 2024

    @vnoves
    Member

    @xiaoyuvax I have already updated the NuGet version 3.5.0 to be compatible with .net core

  6. xiaoyuvax commented on Jul 11, 2024

    @xiaoyuvax

    thanks anyway!
    yes, the limitation is due to the mix compilation, as i've mentioned in #4 , which makes this wrapper not-so-ideally works under windows only.

    Recently i've already seen pure C# port of Google Draco (only Draco, not Draco-ed glTF), check it out here: https://github.com/fileformat-drako/FileFormat.Drako-for-.NET, and it is hopefully to be a more cross-platform-able solution.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions