adamhathcock / sharpcompress

SharpCompress is a fully managed C# library to deal with many compression types and formats.
MIT License
2.29k stars 482 forks source link

macOS crash on start #575

Open ivanlabsii opened 3 years ago

ivanlabsii commented 3 years ago

I get this: Could not load the file 'System.Runtime.CompilerServices.Unsafe'

at System.AppDomain.Load (System.Reflection.AssemblyName assemblyRef, System.Security.Policy.Evidence assemblySecurity) [0x00073] in /Library/Frameworks/Xamarin.Mac.framework/Versions/Current/src/Xamarin.Mac/mcs/class/corlib/System/AppDomain.cs:758 at System.AppDomain.Load (System.Reflection.AssemblyName assemblyRef) [0x00000] in /Library/Frameworks/Xamarin.Mac.framework/Versions/Current/src/Xamarin.Mac/mcs/class/corlib/System/AppDomain.cs:724 at (wrapper remoting-invoke-with-check) System.AppDomain.Load(System.Reflection.AssemblyName) at System.Reflection.Assembly.Load (System.Reflection.AssemblyName assemblyRef) [0x00000] in /Library/Frameworks/Xamarin.Mac.framework/Versions/Current/src/Xamarin.Mac/mcs/class/corlib/System.Reflection/Assembly.cs:440 at ObjCRuntime.Runtime.CollectReferencedAssemblies (System.Collections.Generic.List1[T] assemblies, System.Reflection.Assembly assembly) [0x00085] in /Users/builder/azdo/_work/1/s/xamarin-macios/src/ObjCRuntime/Runtime.cs:545 at ObjCRuntime.Runtime.CollectReferencedAssemblies (System.Collections.Generic.List1[T] assemblies, System.Reflection.Assembly assembly) [0x00085] in /Users/builder/azdo/_work/1/s/xamarin-macios/src/ObjCRuntime/Runtime.cs:545 at ObjCRuntime.Runtime.RegisterEntryAssembly (System.Reflection.Assembly entry_assembly) [0x00032] in /Users/builder/azdo/_work/1/s/xamarin-macios/src/ObjCRuntime/Runtime.cs:506 at ObjCRuntime.Runtime.RegisterAssemblies () [0x00001] in /Users/builder/azdo/_work/1/s/xamarin-macios/src/ObjCRuntime/Runtime.cs:482 at AppKit.NSApplication.Init () [0x00022] in /Users/builder/azdo/_work/1/s/xamarin-macios/src/AppKit/NSApplication.cs:56 at ....MainClass.Main (System.String[] args) [0x00001] in /Users/ivanicin/Projects/.../Main.cs:9

Everything works in the version 0.26.

It is possible that it is a bug in Xamarin.Mac, as there are no problems in Xamarin.iOS but I would need some confirmation to submit it there.

adamhathcock commented 3 years ago

Honesty, not really sure.

I'm unfamiliar with what library targets Xamarin.Mac would use. Must be NET Standard 2.0.

Looks like I updated to CodePages 5.0.0 with 0.27 but also added more Unsafe and memory/span usage.

I'm guessing Xamarin.Mac isn't updated as quickly as Xamarin.iOS. Hopefully, MAUI will fix a possible out of date issue.

tlecomte commented 3 years ago

I had the same error (Could not load the file 'System.Runtime.CompilerServices.Unsafe') on Windows, and in my case the problem was that I did not have the correct binding redirects. I guess Xamarin.Mac also relies on binding redirects the same way ?

ivanlabsii commented 3 years ago

As advised in the related issue on Xamarin Github I have installed System.Runtime.CompilerServices.Unsafe nuget and now it works. However it should work out of the box so possibly you should add this to the list of dependencies. My personal opinion is that this should come with Xamarin.Mac, but as they deny that I guess this should be the solution then.