dotnet / dotnet/reactive

Conflicting dependency with System.Threading.Tasks.Extensions causes MissingMethodException

Open
#1,507 0 comments 2 reactions 0 assignees View on GitHub
[area] Rx
Dominant language
C#
Stars
7.2k
Forks
798
PR merge metrics
No merged PRs in 30d

Description

#### Bug

> Which library version?

5.0.0

> What are the platform(s), environment(s) and related component version(s)?

Windows, .NET Framework

> What is the use case or problem?

If I refererence System.Linq.Async package version 5.0.0, it references Microsoft.Bcl.AsyncInterfaces package version 1.1.0. However, Microsoft.Bcl.AsyncInterfaces 1.1.0 references System.Threading.Tasks.Extensions 4.5.2. But System.Linq.Async 5.0.0 somehow references System.Threading.Tasks.Extensions 4.5.4.

![image](https://user-images.githubusercontent.com/17556515/112676884-41df8080-8e26-11eb-9c39-b713f343d513.png)

But Microsoft.Bcl.AsyncInterfaces has a runtime dependency on System.Threading.Tasks.Extensions 4.2.0.0
![image](https://user-images.githubusercontent.com/17556515/112676989-663b5d00-8e26-11eb-8096-bd21b6d3ea34.png)

When you have an EXE that loads a DLL as a plug-in, meaning it has no compile time dependency, you get a MissingMethodException if your DLL is referencing Microsoft.Bcl.AsyncInterfaces and doesn't have binding redirects.

```
MissingMethodException: Method not found: 'System.Collections.Generic.IAsyncEnumerable`1 System.Linq.AsyncEnumerable.Concat(System.Collections.Generic.IAsyncEnumerable`1, System.Collections.Generic.IAsyncEnumerable`1)'
```

It looks like the dependency was already updated in https://github.com/dotnet/reactive/pull/1420 so I think we just need a new release.

> What is the expected outcome?

Dependent assemblies are loaded side-by-side, System.Linq.Async does not have conflicting dependencies

> What is the actual outcome?

MissingMethodException due to conflicting types

> What is the stacktrace of the exception(s) if any?

> Do you have a code snippet or project that reproduces the problem?

Create a console app that references Microsoft.Bcl.AsyncInterfaces 1.1.0 and has no binding redirects:

```


Exe
net472
Latest



```

Create a class library that references System.Linq.Async 5.0.0:
```


net472
latest



```

Load the class library as a plug-in and try to execute it (I'm using `IDisposable` here as just a way to simplify the plug-in interface):

```C#
Assembly assembly = Assembly.UnsafeLoadFrom(@"D:\Temp\SystemLinqAsyncTask\MyTask\bin\Debug\net472\MyTaskLibrary.dll");

IDisposable obj = assembly.CreateInstance("MyTask.MyTask") as IDisposable;

obj.Dispose();
```

The only workaround is to add binding redirects to the EXE. But if System.Linq.Async didn't have conflicting dependencies that wouldn't be needed.

```xml




```

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.