MissingMethodException when Standard library is called by Net8 Library

,

MissingMethodException when Standard library is called by Net8 Library · Issue #341 · specklesystems/speckle-sharp-sdk

I have a dotnet standard library that uses speckle objects 3.4.2 as a dependency.

I have a net8.0 testing application that tests that library, and another 8.0 docker image that uses the library.

When I call any Speckle functionality from within either library, I get the message

System.MissingMethodException : Method not found: 'System.Collections.Generic.IEnumerable`1<!!0> Speckle.Sdk.Dependencies.EnumerableExtensions.DistinctBy(System.Collections.Generic.IEnumerable`1<!!0>, System.Func`2<!!0,!!1>)'.

I’ve tracked it down to here:

[speckle-sharp-sdk/src/Speckle.Sdk.Dependencies/Collections.cs](https://github.com/specklesystems/speckle-sharp-sdk/blob/05f73539251de803f21f9d2dd8fd27019e2c4e73/src/Speckle.Sdk.Dependencies/Collections.cs#L26-L43)

Lines 26 to 43 in [05f7353](https://github.com/specklesystems/speckle-sharp-sdk/commit/05f73539251de803f21f9d2dd8fd27019e2c4e73)

#if NETSTANDARD2_0
  public static IEnumerable<TSource> DistinctBy<TSource, TKey>(
    this IEnumerable<TSource> source,
    Func<TSource, TKey> keySelector
  )
  {
    var keys = new HashSet<TKey>();
    foreach (var element in source)
    {
      if (keys.Contains(keySelector(element)))
      {
        continue;
      }
      keys.Add(keySelector(element));
      yield return element;
    }
  }
#endif

Updating the standard library to dotnet 8 fixes the issue but that also means cutting off a huge swathe of our 2.0 libraries from being able to use the Speckle functionality we’ve been building.

This smells to me like a runtime DLL conflict.

Like your application is referencing both the netstandard version of objects, and the net8.0 version.

You should get a compiler warning about this when you build (unless your doing something weird like dynamically loading assemblies at runtime)

What does the csproj files look like for both your library code and your net8 assembly?
You may have some unnecessary package references that are causing this conflict.

Hey Jedd, convo is continuing in the repo issue so I’ll close this thread - but it is definitely weirder than that - no shared references, a single direct chain back to the standard 2.0

1 Like

Can confirm this is fixed in 3.5

1 Like