awesome-inc / FontAwesome.Sharp

A library for using Font Awesome in WPF & Windows Forms applications
Apache License 2.0
384 stars 89 forks source link

FontAwesome.Sharp.FormsIconHelper #52

Closed Alerinos closed 3 years ago

Alerinos commented 3 years ago

Hi, I have a problem. One of my testers launched the application and threw this error out of him. Can I ask for help? I'm just learning C #. Thank you

System.TypeLoadException: Nie można załadować typu 'System.Runtime.CompilerServices.ExtensionAttribute' z zestawu 'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.

at System.ModuleHandle.ResolveMethod(RuntimeModule module, Int32 methodToken, IntPtr typeInstArgs, Int32 typeInstCount, IntPtr methodInstArgs, Int32 methodInstCount) at System.ModuleHandle.ResolveMethodHandleInternalCore(RuntimeModule module, Int32 methodToken, IntPtr[] typeInstantiationContext, Int32 typeInstCount, IntPtr[] methodInstantiationContext, Int32 methodInstCount) at System.ModuleHandle.ResolveMethodHandleInternal(RuntimeModule module, Int32 methodToken, RuntimeTypeHandle[] typeInstantiationContext, RuntimeTypeHandle[] methodInstantiationContext) at System.Reflection.CustomAttributeData..ctor(RuntimeModule scope, CustomAttributeRecord caRecord) at System.Reflection.CustomAttributeData.GetCustomAttributes(RuntimeModule module, Int32 tkTarget) at System.Reflection.CustomAttributeData.GetCustomAttributesInternal(RuntimeAssembly target) at System.Reflection.RuntimeAssembly.GetCustomAttributesData() at System.Reflection.CustomAttributeData.GetCustomAttributes(Assembly target) at System.Resources.ManifestBasedResourceGroveler.GetNeutralResourcesLanguage(Assembly a, UltimateResourceFallbackLocation& fallbackLocation) at System.Resources.ResourceManager.CommonSatelliteAssemblyInit() at System.Resources.ResourceManager..ctor(String baseName, Assembly assembly) at MS.Internal.Resources.ResourceManagerWrapper.get_ResourceManager() at MS.Internal.Resources.ResourceManagerWrapper.GetStream(String name) at MS.Internal.AppModel.ResourcePart.GetStreamCore(FileMode mode, FileAccess access) at System.IO.Packaging.PackagePart.GetStream(FileMode mode, FileAccess access) at System.IO.Packaging.PackagePart.GetStream() at System.Windows.Application.GetResourceStream(Uri uriResource) at FontAwesome.Sharp.FormsIconHelper.GetFontBytes(String fontFile, Assembly assembly, String path) at FontAwesome.Sharp.FormsIconHelper.AddFont(PrivateFontCollection fonts, String fontFile, Assembly assembly, String path) at FontAwesome.Sharp.FormsIconHelper.InitializeFonts() at FontAwesome.Sharp.FormsIconHelper..cctor()

System.TypeInitializationException: Inicjator typów zgłosił wyjątek dla typu 'FontAwesome.Sharp.FormsIconHelper'.

at FontAwesome.Sharp.FormsIconHelper.FontFamilyFor(IconChar iconChar) at FontAwesome.Sharp.IconButton..ctor() at Launcher.WindowInstall.InitializeComponent() at Launcher.WindowInstall..ctor() at Launcher.Program.Main(String[] args)

System Information Application Launcher
Version 1.0.0.0
Date 2020-10-16 16:34:43Z
OS Windows 7 Service Pack 1
CLR 4.0.30319.1
CrashReporter.NET Version 1.5.8.0
mkoertgen commented 3 years ago

Hi @Alerinos , this seems to be a known issue with legacy net-framework installations. You will probably need to

  1. either install a windows KB-update or
  2. downgrade the target framework of your app from .net 4.5 -> .net 4.0

Let me know if this helps.

mkoertgen commented 3 years ago

Even better, just use netcoreapp and use multi-targeting. Ship the net40-build to your tester, cf.:

Alerinos commented 3 years ago

Hi, unfortunately I can't test this problem again because the tester is on vacation. Do version 4.0 for users below windows 10 and 4.5 for windows 10 users?

mkoertgen commented 3 years ago

Exactly, that should be it.

mkoertgen commented 3 years ago

Closed for inactivity