Xamarin-Plugins icon indicating copy to clipboard operation
Xamarin-Plugins copied to clipboard

WPF version throws FileNotFound Exception

Open tkouba opened this issue 4 years ago • 0 comments

WPF version of SimpleAudioPlayer has wrong name of assembly. So on use throws FileNotFoundException with

FileName	"Plugin.SimpleAudioPlayer, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null"	string

But dll name is "Plugin.SimpleAudioPlayer.WPF.dll"

Workaround:

    public partial class App : Application
    {
        protected override void OnStartup(StartupEventArgs e)
        {
            AppDomain.CurrentDomain.AssemblyResolve += new ResolveEventHandler(AssemblyResolver); 
            Xamarin.Forms.Forms.Init();
            base.OnStartup(e);
        }

        private Assembly AssemblyResolver(object sender, ResolveEventArgs args)
        {
            if (args.Name.StartsWith("Plugin.SimpleAudioPlayer", StringComparison.CurrentCultureIgnoreCase))
            {
                return Assembly.LoadFrom("Plugin.SimpleAudioPlayer.WPF.dll");
            }
            return null;
        }
    }

tkouba avatar Aug 15 '19 08:08 tkouba