Two libraries with the same libraries but different version of it
Hi,
I've been banging my head on my desk for 3 days straight trying to make this work but I have to submit and ask for help at this point as I have no more ideas.
The situtation.
I'm trying to use "ImageSharp" to draw and create images and produce a png that's going to be mainly for debugging purpose for now. (Basically just drawing the debug version of a procedurally generated map)
ImageSharp has 3 libraries I need.
It was working just fine in my side project to code the generator in vscode (outside of unity) but once I integrated evreything in unity, ImageSharp return an error saying "System.Runtime.CompilerServices.Unsafe" reference is the wrong version.
Problem is that 2 of the libraries use a version of unsafe that is different from the third. It was managed in vscode automatically and worked just fine but unity doesn't like it and it seems to conflict with some unity librairies. (I'm not too sure if it's still relevant but I've seen post on the forum about this)
What I've tried
So I have tried a lot of stuff over the last few days but here's the gist of what I've tried:
- Installing ImageSharp through NugetForUnity but I basically got the same thing.
- Another nuget manager from someone internal at unity but only a few packages were available (Including unsafe and imagesharp) but only the main imageSharp was there since the other two are preview packages
- Compile every .dll, including both imageSharp(s) and unsafe both version. Create two folder in plugin with their respective dll
- Tried to create an assembly reference for those imageSharp dll so they could point to their respective dll
- Re-organize my whole project in sub-section with assembly, so the assembly that needs imageSharp could reference it. However, it was requiring that I override the reference, which seems to make it worse.
They all failed and I'm not sure if I was close to the solution at some point or not.
Current Situation
I have this right now:
- ImageSharp.dll
- ImageSharp.Font.dll
- ImageSharp.Drawing.dll
- System.Runtime.CompilerServices.Unsafe_4.0.6.0.dll (font)
- System.Runtime.CompilerServices.Unsafe_5.0.0.0.dll (base + drawing)
How do I organise this so they can both use they're own dll?
One thing I want to make clear. If I delete one of the dll, the errors for the other dll go away as they now have the right one, but other is missing it's dll and vice-versa. So I know they'll work If I just manage to force them to use the right one.
Thanks for anyone who can help clean this up for me.
Edit: I don't know if it's just me but actually using the editor for post is not very intuitive. I needed to add "br" tag everything just so my text could breathe a litle.
I once encounter a similar issue, I tried using this repository, but never managed to make it work but consider giving it a try
That script implies that I have control over the script itself but I have the dll so I can’t modify them to specifie the alias.
If these were my scripts, I’d be using one library and that’d be it. :)
How did you end ip solving solving yours?
The alias is ment for that use case, in which you have 2 dlls that you can edit, wrapping both dlls in 'alias' so you could specify the alias from the script to tell which dll use. It ended up being fairly easy, I decompiled the dll, saw that for any reason the library creator compiled a third party dll into his own dll, but I manage to found the original unmodified version of the library
Your answer

Follow this Question
Related Questions
Using #if UNITY_DEBUG in DLLs 0 Answers
Placeholder dll with different dependency results in build-error on target platform (WSA) 0 Answers
Managed Plugins Unity Manual example not working, needed for Google Cloud Storage API 0 Answers
Invalid IL Code in Build 1 Answer
Why does VR not work the second time I run the project? 0 Answers