xamarin / Xamarin.Forms

Xamarin.Forms is no longer supported. Migrate your apps to .NET MAUI.
https://aka.ms/xamarin-upgrade
Other
5.63k stars 1.87k forks source link

NSApplication.Init isn't working with Xamarin.Forms.Platform.GTK because OpenTK.GLControl assembly is missing #3591

Closed ylatuya closed 1 year ago

ylatuya commented 6 years ago

Description

The NSApplication initialization fails with Xamarin.Forms.Platform.GTK because of a missing assembly in the nuget package.

Steps to Reproduce

  1. Create a Xamarin.Forms app with the GTK+ backend in macOS
  2. Call NSApplication.Init after the Forms initialization
  3. An exception is thrown because of a missing OpenTK.GLControl assembly.

Expected Behavior

No exception is thrown and NSApplication's initialization works as expected

Actual Behavior

The following exception is thrown

Could not find `OpenTK.GLControl` referenced by assembly `SkiaSharp.Views.Desktop, Version=1.60.0.0, Culture=neutral, PublicKeyToken=0738eb9f132ed756`.
Could not find `OpenTK.GLControl` referenced by assembly `SkiaSharp.Views.Gtk, Version=1.60.0.0, Culture=neutral, PublicKeyToken=0738eb9f132ed756`.
Could not find `OpenTK.GLControl` referenced by assembly `VAS.UI.Forms.GTK, Version=1.0.6802.33149, Culture=neutral, PublicKeyToken=null`.
Could not find `OpenTK.GLControl` referenced by assembly `RiftAnalyst.UI, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null`.
Could not find `OpenTK.GLControl` referenced by assembly `RiftAnalyst, Version=1.6.0.101, Culture=neutral, PublicKeyToken=null`.
[1 Warn  18:25:16.413] Caught an exception - System.IO.FileNotFoundException: Could not load file or assembly 'OpenTK.GLControl' or one of its dependencies (in `mscorlib')
  at System.AppDomain.Load (System.Reflection.AssemblyName assemblyRef, System.Security.Policy.Evidence assemblySecurity) [0x0006f] in /Users/builder/jenkins/workspace/build-package-osx-mono/2017-12/external/bockbuild/builds/mono-x64/mcs/class/corlib/System/AppDomain.cs:746 
  at (wrapper remoting-invoke-with-check) System.AppDomain.Load(System.Reflection.AssemblyName,System.Security.Policy.Evidence)
  at System.AppDomain.Load (System.Reflection.AssemblyName assemblyRef) [0x00000] in /Users/builder/jenkins/workspace/build-package-osx-mono/2017-12/external/bockbuild/builds/mono-x64/mcs/class/corlib/System/AppDomain.cs:714 
  at (wrapper remoting-invoke-with-check) System.AppDomain.Load(System.Reflection.AssemblyName)
  at System.Reflection.Assembly.Load (System.Reflection.AssemblyName assemblyRef) [0x00000] in /Users/builder/jenkins/workspace/build-package-osx-mono/2017-12/external/bockbuild/builds/mono-x64/mcs/class/corlib/System.Reflection/Assembly.cs:600 
  at ObjCRuntime.Runtime.CollectReferencedAssemblies (System.Collections.Generic.List`1[T] assemblies, System.Reflection.Assembly assembly) [0x0006d] in <4038e84c0daf42429d15d7404249453d>:0 
  at ObjCRuntime.Runtime.CollectReferencedAssemblies (System.Collections.Generic.List`1[T] assemblies, System.Reflection.Assembly assembly) [0x0006d] in <4038e84c0daf42429d15d7404249453d>:0 
  at ObjCRuntime.Runtime.CollectReferencedAssemblies (System.Collections.Generic.List`1[T] assemblies, System.Reflection.Assembly assembly) [0x0006d] in <4038e84c0daf42429d15d7404249453d>:0 
  at ObjCRuntime.Runtime.CollectReferencedAssemblies (System.Collections.Generic.List`1[T] assemblies, System.Reflection.Assembly assembly) [0x0006d] in <4038e84c0daf42429d15d7404249453d>:0 
  at ObjCRuntime.Runtime.CollectReferencedAssemblies (System.Collections.Generic.List`1[T] assemblies, System.Reflection.Assembly assembly) [0x0006d] in <4038e84c0daf42429d15d7404249453d>:0 
  at ObjCRuntime.Runtime.RegisterEntryAssembly (System.Reflection.Assembly entry_assembly) [0x00033] in <4038e84c0daf42429d15d7404249453d>:0 
  at ObjCRuntime.Runtime.RegisterAssemblies () [0x00006] in <4038e84c0daf42429d15d7404249453d>:0 
  at AppKit.NSApplication.Init () [0x00022] in <4038e84c0daf42429d15d7404249453d>:0 
  at VAS.Core.GtkOSXApplication..ctor () [0x00020] in /Users/andoni/git/vasone-forms/VAS/VAS.UI.Helpers.Gtk2/GtkOSXApplication.cs:31 
  at RiftAnalyst.MainClass.ConfigureOSXApp () [0x0001b] in /Users/andoni/git/vasone-forms/riftanalyst/RiftAnalyst/Main.cs:298 
  at RiftAnalyst.MainClass+<Init>d__11.MoveNext () [0x00694] in /Users/andoni/git/vasone-forms/riftanalyst/RiftAnalyst/Main.cs:269 

Basic Information

HelenMamalaki commented 4 years ago

can anyone advise on how we can bypass this

System.IO.FileNotFoundException: Could not load file or assembly XX

for libraries that do not support Mac and cannot be installed on Mac such as PCLCrypto. I get that I need to find a different solution for whatever the library is doing (e.g. crypto stuff) but how can I get past it trying to find the assembly on the platform project on initialisation.

jfversluis commented 1 year ago

Taking into consideration the remaining lifetime of Xamarin.Forms, the platform this is about, the age of this issue and the traction this issue has seen I think it's unlikely that this will get fixed. If it is something that you still would like to have, please consider opening a PR. Thanks!