Eto: Extracting dependencies broke XAML loading on non-Windows platforms

Created on 24 Oct 2020  ·  4Comments  ·  Source: picoe/Eto

Without changing anything in my code, after updating to the latest "nightly" build, the app crashes on linux with the exception:

System.IO.FileNotFoundException: Could not load file or assembly 'PresentationFramework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies.
File name: 'PresentationFramework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'
  at (wrapper managed-to-native) System.MonoCustomAttrs.GetCustomAttributesInternal(System.Reflection.ICustomAttributeProvider,System.Type,bool)
  at System.MonoCustomAttrs.GetCustomAttributesBase (System.Reflection.ICustomAttributeProvider obj, System.Type attributeType, System.Boolean inheritedOnly) [0x00013] in /builddir/build/BUILD/mono-6.12.0.102/mcs/class/corlib/System/MonoCustomAttrs.cs:128 
  at System.MonoCustomAttrs.GetCustomAttributes (System.Reflection.ICustomAttributeProvider obj, System.Type attributeType, System.Boolean inherit) [0x00037] in /builddir/build/BUILD/mono-6.12.0.102/mcs/class/corlib/System/MonoCustomAttrs.cs:163 
  at System.Reflection.RuntimeAssembly.GetCustomAttributes (System.Type attributeType, System.Boolean inherit) [0x00000] in /builddir/build/BUILD/mono-6.12.0.102/mcs/class/corlib/System.Reflection/RuntimeAssembly.cs:520 
  at System.Attribute.GetCustomAttributes (System.Reflection.Assembly element, System.Type attributeType, System.Boolean inherit) [0x0005c] in /builddir/build/BUILD/mono-6.12.0.102/mcs/class/referencesource/mscorlib/system/attribute.cs:866 
  at System.Attribute.GetCustomAttributes (System.Reflection.Assembly element, System.Type attributeType) [0x00000] in /builddir/build/BUILD/mono-6.12.0.102/mcs/class/referencesource/mscorlib/system/attribute.cs:851 
  at System.Reflection.CustomAttributeExtensions.GetCustomAttributes (System.Reflection.Assembly element, System.Type attributeType) [0x00000] in /builddir/build/BUILD/mono-6.12.0.102/mcs/class/referencesource/mscorlib/system/reflection/CustomAttributeExtensions.cs:92 
  at Portable.Xaml.XamlSchemaContext.FillCompatibilities (System.Reflection.Assembly ass) [0x00000] in <16c90363778e4b50b411e4917b044d09>:0 
  at Portable.Xaml.XamlSchemaContext.TryGetCompatibleXamlNamespace (System.String xamlNamespace, System.String& compatibleNamespace) [0x00036] in <16c90363778e4b50b411e4917b044d09>:0 
  at Portable.Xaml.CompatibleXmlReader.GetMapped (System.String ns) [0x00012] in <16c90363778e4b50b411e4917b044d09>:0 
  at Portable.Xaml.CompatibleXmlReader.get_NamespaceURI () [0x0000c] in <16c90363778e4b50b411e4917b044d09>:0 
  at Portable.Xaml.CompatibleXmlReader.ProcessStartElement () [0x00000] in <16c90363778e4b50b411e4917b044d09>:0 
  at Portable.Xaml.CompatibleXmlReader.Read () [0x0002f] in <16c90363778e4b50b411e4917b044d09>:0 
  at System.Xml.XmlReader.MoveToContent () [0x0003a] in /builddir/build/BUILD/mono-6.12.0.102/mcs/class/referencesource/System.Xml/System/Xml/Core/XmlReader.cs:728 
  at Portable.Xaml.XamlXmlParser+<Parse>d__13.MoveNext () [0x0002e] in <16c90363778e4b50b411e4917b044d09>:0 
  at Portable.Xaml.XamlXmlReader.Read () [0x00031] in <16c90363778e4b50b411e4917b044d09>:0 
  at Portable.Xaml.XamlServices.Transform (Portable.Xaml.XamlReader xamlReader, Portable.Xaml.XamlWriter xamlWriter, System.Boolean closeWriter) [0x00024] in <16c90363778e4b50b411e4917b044d09>:0 
  at Portable.Xaml.XamlServices.Transform (Portable.Xaml.XamlReader xamlReader, Portable.Xaml.XamlWriter xamlWriter) [0x00000] in <16c90363778e4b50b411e4917b044d09>:0 
  at Eto.Serialization.Xaml.XamlReader.Load[T] (Portable.Xaml.XamlXmlReader reader, T instance) [0x0003c] in <9017e3c4c6ad4d44933e97fb9cb6efcd>:0 
  at Eto.Serialization.Xaml.XamlReader.Load[T] (System.IO.Stream stream, T instance) [0x0002e] in <9017e3c4c6ad4d44933e97fb9cb6efcd>:0 
  at Eto.Serialization.Xaml.XamlReader.Load[T] (T instance) [0x00029] in <9017e3c4c6ad4d44933e97fb9cb6efcd>:0 
  at FPLedit.MainForm..ctor (FPLedit.LastFileHandler lfh, FPLedit.CrashReporting.CrashReporter crashReporter, FPLedit.Bootstrapper bootstrapper) [0x00008] in fpledit-src/FPLedit/MainForm.xeto.cs:57 
  at FPLedit.Program.Main (System.String[] args) [0x0017f] in fpledit-src/FPLedit/Program.cs:76 
[ERROR] FATAL UNHANDLED EXCEPTION: System.IO.FileNotFoundException: Could not load file or assembly 'PresentationFramework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies.
File name: 'PresentationFramework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'
  at (wrapper managed-to-native) System.MonoCustomAttrs.GetCustomAttributesInternal(System.Reflection.ICustomAttributeProvider,System.Type,bool)
  at System.MonoCustomAttrs.GetCustomAttributesBase (System.Reflection.ICustomAttributeProvider obj, System.Type attributeType, System.Boolean inheritedOnly) [0x00013] in /builddir/build/BUILD/mono-6.12.0.102/mcs/class/corlib/System/MonoCustomAttrs.cs:128 
  at System.MonoCustomAttrs.GetCustomAttributes (System.Reflection.ICustomAttributeProvider obj, System.Type attributeType, System.Boolean inherit) [0x00037] in /builddir/build/BUILD/mono-6.12.0.102/mcs/class/corlib/System/MonoCustomAttrs.cs:163 
  at System.Reflection.RuntimeAssembly.GetCustomAttributes (System.Type attributeType, System.Boolean inherit) [0x00000] in /builddir/build/BUILD/mono-6.12.0.102/mcs/class/corlib/System.Reflection/RuntimeAssembly.cs:520 
  at System.Attribute.GetCustomAttributes (System.Reflection.Assembly element, System.Type attributeType, System.Boolean inherit) [0x0005c] in /builddir/build/BUILD/mono-6.12.0.102/mcs/class/referencesource/mscorlib/system/attribute.cs:866 
  at System.Attribute.GetCustomAttributes (System.Reflection.Assembly element, System.Type attributeType) [0x00000] in /builddir/build/BUILD/mono-6.12.0.102/mcs/class/referencesource/mscorlib/system/attribute.cs:851 
  at System.Reflection.CustomAttributeExtensions.GetCustomAttributes (System.Reflection.Assembly element, System.Type attributeType) [0x00000] in /builddir/build/BUILD/mono-6.12.0.102/mcs/class/referencesource/mscorlib/system/reflection/CustomAttributeExtensions.cs:92 
  at Portable.Xaml.XamlSchemaContext.FillCompatibilities (System.Reflection.Assembly ass) [0x00000] in <16c90363778e4b50b411e4917b044d09>:0 
  at Portable.Xaml.XamlSchemaContext.TryGetCompatibleXamlNamespace (System.String xamlNamespace, System.String& compatibleNamespace) [0x00036] in <16c90363778e4b50b411e4917b044d09>:0 
  at Portable.Xaml.CompatibleXmlReader.GetMapped (System.String ns) [0x00012] in <16c90363778e4b50b411e4917b044d09>:0 
  at Portable.Xaml.CompatibleXmlReader.get_NamespaceURI () [0x0000c] in <16c90363778e4b50b411e4917b044d09>:0 
  at Portable.Xaml.CompatibleXmlReader.ProcessStartElement () [0x00000] in <16c90363778e4b50b411e4917b044d09>:0 
  at Portable.Xaml.CompatibleXmlReader.Read () [0x0002f] in <16c90363778e4b50b411e4917b044d09>:0 
  at System.Xml.XmlReader.MoveToContent () [0x0003a] in /builddir/build/BUILD/mono-6.12.0.102/mcs/class/referencesource/System.Xml/System/Xml/Core/XmlReader.cs:728 
  at Portable.Xaml.XamlXmlParser+<Parse>d__13.MoveNext () [0x0002e] in <16c90363778e4b50b411e4917b044d09>:0 
  at Portable.Xaml.XamlXmlReader.Read () [0x00031] in <16c90363778e4b50b411e4917b044d09>:0 
  at Portable.Xaml.XamlServices.Transform (Portable.Xaml.XamlReader xamlReader, Portable.Xaml.XamlWriter xamlWriter, System.Boolean closeWriter) [0x00024] in <16c90363778e4b50b411e4917b044d09>:0 
  at Portable.Xaml.XamlServices.Transform (Portable.Xaml.XamlReader xamlReader, Portable.Xaml.XamlWriter xamlWriter) [0x00000] in <16c90363778e4b50b411e4917b044d09>:0 
  at Eto.Serialization.Xaml.XamlReader.Load[T] (Portable.Xaml.XamlXmlReader reader, T instance) [0x0003c] in <9017e3c4c6ad4d44933e97fb9cb6efcd>:0 
  at Eto.Serialization.Xaml.XamlReader.Load[T] (System.IO.Stream stream, T instance) [0x0002e] in <9017e3c4c6ad4d44933e97fb9cb6efcd>:0 
  at Eto.Serialization.Xaml.XamlReader.Load[T] (T instance) [0x00029] in <9017e3c4c6ad4d44933e97fb9cb6efcd>:0 
  at FPLedit.MainForm..ctor (FPLedit.LastFileHandler lfh, FPLedit.CrashReporting.CrashReporter crashReporter, FPLedit.Bootstrapper bootstrapper) [0x00008] in fpledit-src/FPLedit/MainForm.xeto.cs:57 
  at FPLedit.Program.Main (System.String[] args) [0x0017f] in fpledit-src/FPLedit/Program.cs:76 

Working with version 2.5.7-ci-20201007.292499425
Broken with version 2.5.7-ci-20201021.320816878

Steps to Reproduce the Problem

My project (.NET framework) creates just one executable for all platforms and references both Eto.Wpf.dll as well as Eto.Gtk.dll. No custom platform detection code is used. Forms are created using the XAML reader.

Thoughts

I suppose commit https://github.com/picoe/Eto/commit/2231f4c2a49066a8381a46c6eb64a31d1e32e784 inroduced this problem. From the stack trace it looks like not the actual platform loading is faulty, but like Portable.Xaml tries to load some assemblies present in the application folder(?). As of https://github.com/picoe/Eto/commit/2231f4c2a49066a8381a46c6eb64a31d1e32e784, more files with an explicit dependency to Wpf are present (which is obviously not available nor needed on Linux).

Deleting all files Xceed.*.dll from the build dir removes the crash - but this is obviously no solution as those dependencies are needed on Windows...

Specifications

  • Version: current myget version 2.5.7-ci-20201021.320816878
  • Platform(s): Gtk (only when Wpf dependencies are present)
  • Operating System(s): Fedora 32
bug

Most helpful comment

It did indeed fix the issue :-) It just spits out mono warnings (Can't find custom attr constructor image: ...), but those cannot be disabled by user code (as far as I know).

Thanks!

All 4 comments

Hey @ManuelHu,

Thanks for reporting the issue! We may have to fix this on the Portable.Xaml side by putting in a try/catch in when scanning assemblies for attributes.

Yes, that should prevent it... :+1:

Portable.Xaml 0.26.0 _should_ fix this issue. Please give it a try!

It did indeed fix the issue :-) It just spits out mono warnings (Can't find custom attr constructor image: ...), but those cannot be disabled by user code (as far as I know).

Thanks!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Jojatekok picture Jojatekok  ·  33Comments

Serg-Norseman picture Serg-Norseman  ·  5Comments

TomQv picture TomQv  ·  6Comments

rothomp3 picture rothomp3  ·  15Comments

LaraSQP picture LaraSQP  ·  5Comments