question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Runtime Error] MissingMethodException caused by using ToHashSet method

See original GitHub issue

Today we crashed in too unpleasant bug in .NET Standard + Linq.Extras:

System.MissingMethodException Method not found: 'System.Collections.Generic.HashSet`1<!!0> Linq.Extras.XEnumerable.ToHashSet(System.Collections.Generic.IEnumerable`1<!!0>, System.Collections.Generic.IEqualityComparer`1<!!0>)'.

To reproduce it:

  1. Create a project NetStandartProject targeted to .netstandard2.0
  2. Add a method void SomeMethod(int[] a) => a.ToHashSet();
  3. Create a second project NetCoreProject targeted to .netcoreapp2.1 or higher
  4. Add NetStandartProject into NetCoreProject dependencies
  5. Call SomeMethod from NetCoreProject
  6. Get System.MissingMethodException

Here is a complete example solution: https://github.com/rodion-m/LinqExtrasRuntimeException. Just run NetCoreProject.

I suggest to delete all methods like ToHashSet from .netstandart target and let the developer write new HashSet(a) instead of a.ToHashSet() than crash in runtime with MissingMethodException. I think you just should make .netstandart version of Linq.Extras equal to .netcore version of Linq.Extras.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
thomaslevesquecommented, Jun 23, 2021

@rodion-m I published a new release: 5.0.0-beta.1, in which I removed the problematic methods. I also changed the TFMs (removed old ones, added new ones). Please let me know if it fixes the problem for you.

0reactions
rodion-mcommented, Nov 11, 2021

@rodion-m FYI I just published 5.0.0, using the approach described above

Great, thank you! I think we can close the issue then.

Read more comments on GitHub >

github_iconTop Results From Across the Web

System.MissingMethodException: Method not found?
It all compiles without error, but it gave a mysterious "Method not found" error when I tried to use the package.
Read more >
View Results Error - Missing Method Exception
MissingMethodException : Method not found: 'System.Collections.Generic.HashSet`1<!!0> System.Linq.Enumerable.ToHashSet(System.Collections.
Read more >
Enumerable.ToHashSet Method (System.Linq)
Creates a HashSet<T> from an IEnumerable<T> using the comparer to compare keys.
Read more >
https://raw.githubusercontent.com/dotnet/samples/m...
Numerics Quaternion operator overloads should be using the respective methods Quaternion declares a handful of methods to perform addition, subtraction and ...
Read more >
Changelog for Groovy 2.0.0
[GROOVY-5063] - Cannot set "-Werror" javac option when using Groovyc ant task. [GROOVY-5076] - the shorthand notation for Grab isn't working correctly; [GROOVY- ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found