Visitar URL original
.Net 4.6.2 projects no longer build · Issue #1509 · MessagePack-CSharp/MessagePack-CSharp · GitHub
Skip to content

.Net 4.6.2 projects no longer build #1509

Closed

Description

@joshdean2000

Bug description

Error CS0121 The call is ambiguous between the following methods or properties: 'System.MemoryExtensions.AsSpan(T[], int, int)' and 'System.MemoryExtensions.AsSpan(T[], int, int)'

Repro steps

Simply add the following line of code to any .Net 4.6.2 project.

ReadOnlySpan<byte> value = (new byte[100]).AsSpan(0, 10);
  • Version used: 2.4.35
  • Runtime: .Net 4.6.2

Activity

  1. AArnott commented on Oct 1, 2022

    @AArnott
    Collaborator

    What does this have to do with MessagePack? It doesn't define this method. That's defined in System.Memory, which is a Microsoft package.

  2. joshdean2000 commented on Oct 1, 2022

    @joshdean2000
    Author

    It's the packages it's referencing therefore including in the project.

  3. AArnott commented on Oct 2, 2022

    @AArnott
    Collaborator

    Sure, that's a dependency, but if your project is referencing that assembly twice, that isn't anything MessagePack can help with. You should review your project file and maybe the build logs to find out where the second reference is coming from.

  4. github-actions commented on Jan 1, 2023

    @github-actions
    Contributor

    This issue is stale because it has been open 90 days with no activity. Remove stale label or comment or this will be closed in 5 days.

  5. BrennanConroy commented on Jan 10, 2023

    @BrennanConroy

    Looks like this is an issue with the Microsoft.NET.StringTool package and also referencing System.Memory in the same net462 project. dotnet/msbuild#8295
    And since MessagePack brings in both references (empty console app + MessagePack reference easily shows this), the MessagePack library is no longer usable in net462 apps.

  6. KalleOlaviNiemitalo commented on Jan 10, 2023

    @KalleOlaviNiemitalo

    Could this be fixed by changing MessagePack to use PrivateAssets="compile" in its Microsoft.NET.StringTools reference? https://github.com/neuecc/MessagePack-CSharp/blob/3bc35e3603004c79765746b110f76d0d29ead4eb/src/MessagePack/MessagePack.csproj#L37

  7. AArnott commented on Jan 11, 2023

    @AArnott
    Collaborator

    This is a bug in Microsoft.NET.StringTools, as it introduces a colliding API with System.Memory. I filed dotnet/msbuild#8299.

  8. BrennanConroy commented on Jan 11, 2023

    @BrennanConroy

    I already filed an issue, see my comment above :/

  9. AArnott commented on Jan 11, 2023

    @AArnott
    Collaborator

    I'll whip up a PR to workaround it in MessagePack, since there is no need to add the ref assembly to Net.StringTools.

  10. added a commit that references this issue on Jan 11, 2023
    26135de
  11. lbargaoanu commented on Jan 27, 2023

    @lbargaoanu

    I'm using the CI nuget package with MessagePack.MSBuild.Tasks and I get error CS0433: The type 'MemoryExtensions' exists in both 'Microsoft.NET.StringTools.net35, Version=1.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' and 'System.Memory, Version=4.0.1.2, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'.

  12. AArnott commented on Jan 27, 2023

    @AArnott
    Collaborator

    @lbargaoanu Which version of MessagePack.MSBuild.Tasks exactly are you using? You need exactly v2.4.66 (2.5 doesn't have the change yet).

  13. lbargaoanu commented on Jan 27, 2023

    @lbargaoanu

    Thanks! Yes, I was using the latest, 2.5.67. 2.4.66 works.

  14. added a commit that references this issue on Apr 11, 2023
  15. fedemkr commented on May 10, 2023

    @fedemkr

    Hi there, we're having some trouble updating from 2.4.59 on a Xamarin application and it fails to compile in Android with this same error.
    The shared project is using .Net Standard 2.1 where the package is installed.
    We tried looking for the nugget version of 2.4.66 but couldn't find it, was that version renamed to another one or removed? I see it mentioned that it's not yet implemented in 2.5.*

  16. AArnott commented on May 19, 2023

    @AArnott
    Collaborator

    @fedemkr v2.5.94 and later also has the fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions