Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compatibility issues Nuget restore #2

Open
awesomeinsight opened this issue Feb 20, 2024 · 5 comments
Open

Compatibility issues Nuget restore #2

awesomeinsight opened this issue Feb 20, 2024 · 5 comments

Comments

@awesomeinsight
Copy link

awesomeinsight commented Feb 20, 2024

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.

@awesomeinsight awesomeinsight changed the title Compatibility issues NuGet restore Compatibility issues Nuget restore Feb 20, 2024
@rosend
Copy link

rosend commented Apr 22, 2024

i had the same problem :(

@xiaoyuvax
Copy link

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

@vnoves
Copy link
Member

vnoves commented Jul 11, 2024

@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

@vnoves
Copy link
Member

vnoves commented Jul 11, 2024

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

@xiaoyuvax
Copy link

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
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants