Flow-Launcher / Flow-Launcher/Flow.Launcher

BUG: Plugins Loading Different Versions of Same Dependency Causes Init Failure

Open
#4,258 0 comments 0 reactions 0 assignees View on GitHub
bug help wanted keep-fresh
Dominant language
C#
Stars
15.6k
Forks
644
Avg merge
3d 14h
Merged PRs (30d)
4

Description

### Checks

- [x] I have checked that this issue has not already been reported.

- [x] I am using the latest version of Flow Launcher.

- [ ] I am using the prerelease version of Flow Launcher.

### Problem Description

When two plugins use the same dependency but with different versions, it can break one of the plugins.

This seems to be due to two DLLs being loaded and in my specific case it seems to try to cast a matching class between the different dependency versions and crash.

This issue was first reported on my plugin AppAudioManger here:
https://github.com/DavidGBrett/Flow.Launcher.Plugin.AppAudioManager/issues/8
by @Jack251970

The other conflicting plugin was AudioDeviceSelector:
https://github.com/attilakapostyak/Flow.Launcher.Plugin.AudioDeviceSelector

In this case my plugin was using NAudio version 2.2.1, while AudioDeviceSelector was using 2.1.0

From my brief research, you may be able to fix this by isolating the plugins / their dependencies using:
System.Runtime.Loader.AssemblyLoadContext

Though I don't know enough about that to be certain.

### To Reproduce

1. pm install AppAudioManger
2. pm install AudioDeviceSelector

### Screenshots

_No response_

### Flow Launcher Version

2.0.3

### Windows Build Number

26200.7705

### Error Log

```shell

18:57:23.8853+01:00 - ERROR - PluginManager.InitializePluginsAsync - Fail to Init plugin: Audio Device Selector
EXCEPTION OCCURS: System.InvalidCastException: Unable to cast object of type 'NAudio.CoreAudioApi.Interfaces.MMDeviceEnumeratorComObject' to type 'NAudio.CoreAudioApi.Interfaces.MMDeviceEnumeratorComObject'.
at new NAudio.CoreAudioApi.MMDeviceEnumerator()
at new Flow.Launcher.Plugin.AudioDeviceSelector.Audio.AudioDevicesManager() in D:/a/Flow.Launcher.Plugin.AudioDeviceSelector/Flow.Launcher.Plugin.AudioDeviceSelector/src/Flow.Launcher.Plugin.AudioDeviceSelector/Audio/AudioDevicesManager.cs:line 17
at void Flow.Launcher.Plugin.AudioDeviceSelector.Main.Init(PluginInitContext context) in D:/a/Flow.Launcher.Plugin.AudioDeviceSelector/Flow.Launcher.Plugin.AudioDeviceSelector/src/Flow.Launcher.Plugin.AudioDeviceSelector/Main.cs:line 162
at Task Flow.Launcher.Plugin.IPlugin.Flow.Launcher.Plugin.IAsyncPlugin.InitAsync(PluginInitContext context)+() => { } in /_/Flow.Launcher.Plugin/Interfaces/IPlugin.cs:line 33
at async Task Flow.Launcher.Infrastructure.Stopwatch.DebugAsync(string className, string message, Func action, string methodName) in C:/projects/flow-launcher/Flow.Launcher.Infrastructure/Stopwatch.cs:line 31
at async Task Flow.Launcher.Core.Plugin.PluginManager.InitializePluginsAsync()+(?) => { } in C:/projects/flow-launcher/Flow.Launcher.Core/Plugin/PluginManager.cs:line 252

```

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.