Skip to content

[Xamarin.Android] System.PlatformNotSupportedException: System.Runtime.Caching is not supported on this platform #28686

Closed
dotnet/corefx
#39556

Description

@dehghani-mehdi

Hi,

I have a class library (.Net Standard) that uses System.Runtime.Caching, I want to use this class library in my Xamarin.Android project, but I got System.PlatformNotSupportedException exception.

Is there any plan to fix this, so we can use System.Runtime.Caching in Xamarin?

Thanks.

Activity

  1. stephentoub commented on Feb 14, 2019

    @stephentoub
    Member

    @marek-safar, I assume System.Runtime.Caching for a Xamarin.Android project is coming from mono?

  2. marek-safar commented on Feb 14, 2019

    @marek-safar
    Contributor

    NetStandard version of System.Runtime.Caching throws PlatformNotSupportedException I suspect you'd need to build Xamarin version of the class library to avoid this indirect dependency issue.

  3. dehghani-mehdi commented on Feb 16, 2019

    @dehghani-mehdi
    Author

    @marek-safar I didn't get you, but I tried to use Android Class Library instead of .Net Standard Class Library, but here is what happened:

    screenshot_7

  4. marek-safar commented on Feb 18, 2019

    @marek-safar
    Contributor

    Sorry, I didn't fully check the files layout. Xamarin.Android does not provide this library at all which is why you get this warning/error.

    We need to remove Xamarin TFM from SupportedFramework of System.Runtime.Caching (https://github.com/dotnet/corefx/blame/master/src/System.Runtime.Caching/pkg/System.Runtime.Caching.pkgproj) to avoid this error.

    @danmosemsft @karelz who does own that part^ now?

    @dehghani-mehdi this package is not supported cross-platform, you will have to find a different solution.

  5. dehghani-mehdi commented on Feb 18, 2019

    @dehghani-mehdi
    Author

    @marek-safar don't worry, thanks for your time.

    I replaced System.Runtime.Caching with Microsoft.Extensions.Caching.Memory, and seems works almost the same as System.Runtime.Caching. I'm just worry about package size, Microsoft.Extensions.Caching.Memory have some dependencies.

    I'm not sure why Microsoft published 2 packages with same job.

  6. danmoseley commented on Feb 19, 2019

    @danmoseley
    Contributor

    @KKhurin owns S.R.C.

  7. KKhurin commented on Feb 22, 2019

    @KKhurin
    Member

    Why 2 packages: dotnet/AspNetCore.Docs#8478 (comment)
    How to make it work on Xamarin - we'd need to look if its possible (e.g. all the dependencies are there).

  8. danmoseley commented on Jun 10, 2019

    @danmoseley
    Contributor

    @KKhurin we are ZBB'ing this month, is this on track or should you move to Future?

  9. KKhurin commented on Jun 10, 2019

    @KKhurin
    Member

    @StephenMolloy could you please take a look?

  10. ericstj commented on Jul 12, 2019

    @ericstj
    Member

    We need to remove Xamarin TFM from SupportedFramework of System.Runtime.Caching (https://github.com/dotnet/corefx/blame/master/src/System.Runtime.Caching/pkg/System.Runtime.Caching.pkgproj) to avoid this error.

    @marek-safar That doesn't do anything it's only validation. It has to be there since System.Runtime.Caching exposes a NETStandard2.0 reference assembly.

    Today System.Runtime.Caching supplies 3 implementations: netstandard2.0 (throws platformnotsupported), netcoreapp2.0-windows, and netcoreapp2.0-unix.

    The options to make this work are one of two things:

    1. Add a non-throwing implementation to the package that will apply to xamarin. IOW make netstandard2.0 a real implementation.
    2. Exclude all xamarin TFMs from getting any asset from the package. This will only work if Xamarin/Mono provide a compatible version of the library in their SDK.
  11. danmoseley commented on Jul 13, 2019

    @danmoseley
    Contributor

    @marek-safar at this point you should also make a call whether this is necessary work for 3.0 as we will lock down shortly. If not, feel free to move to Future.

  12. marek-safar commented on Jul 16, 2019

    @marek-safar
    Contributor

    @ericst I am not sure I follow, if we exclude Xamarin TFMs the netstandard2.0 version will be used. I think that's what we have elsewhere how would we get to Xamarin compatible version without explicit TFMs anyway?

  13. ericstj commented on Jul 16, 2019

    @ericstj
    Member

    The NETStandard2.0 version is already being used for xamarin, but its not a functional implementation, it throws. https://github.com/dotnet/corefx/blob/1acaa2017cfc64ef1aabcf3b19d0e097af692616/src/System.Runtime.Caching/src/System.Runtime.Caching.csproj#L8

    Again, you get compatible version my making this a functional version (option 1), or removing all xamarin assets from the package and having xamarin provide the dll (option 2). In either case Xamarin is "supported" it has to be if the package exposes a netstandard2.0 reference, the difference is just who is responsible for providing the library.

    I'd recommend option 1 to avoid growing Xamarin's SDK. Here's a change that does that: dotnet/corefx#39556

    You could simplify even more by just doing runtime detection for windows rather than cross compiling.

  14. dehghani-mehdi commented on Jul 27, 2019

    @dehghani-mehdi
    Author

    @StephenMolloy what should I do now? I see you closed the issue.

  15. karelz commented on Jul 28, 2019

    @karelz
    Member

    @dehghani-mehdi see how he closed it - it was fixed in master (for 5.0), now there is pending PR for release/3.0 - dotnet/corefx#39822 ... reopening.

  16. reopened this on Jul 28, 2019
  17. karelz commented on Aug 7, 2019

    @karelz
    Member

    Fixed in 3.0 in PR dotnet/corefx#39822 and in master (5.0) in PR dotnet/corefx#39556

  18. transferred this issue fromdotnet/corefxon Feb 1, 2020
  19. added this to the 3.0 milestone on Feb 1, 2020
  20. ghost locked as resolved and limited conversation to collaborators on Dec 14, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions