You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Xamarin.Android] System.PlatformNotSupportedException: System.Runtime.Caching is not supported on this platform #28686
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?
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.
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.
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).
@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.
The options to make this work are one of two things:
Add a non-throwing implementation to the package that will apply to xamarin. IOW make netstandard2.0 a real implementation.
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.
@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.
@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?
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.
Activity
stephentoub commentedon Feb 14, 2019
@marek-safar, I assume System.Runtime.Caching for a Xamarin.Android project is coming from mono?
marek-safar commentedon Feb 14, 2019
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.
dehghani-mehdi commentedon Feb 16, 2019
@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:
marek-safar commentedon Feb 18, 2019
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.
dehghani-mehdi commentedon Feb 18, 2019
@marek-safar don't worry, thanks for your time.
I replaced
System.Runtime.CachingwithMicrosoft.Extensions.Caching.Memory, and seems works almost the same asSystem.Runtime.Caching. I'm just worry about package size,Microsoft.Extensions.Caching.Memoryhave some dependencies.I'm not sure why Microsoft published 2 packages with same job.
danmoseley commentedon Feb 19, 2019
@KKhurin owns S.R.C.
KKhurin commentedon Feb 22, 2019
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).
danmoseley commentedon Jun 10, 2019
@KKhurin we are ZBB'ing this month, is this on track or should you move to Future?
KKhurin commentedon Jun 10, 2019
@StephenMolloy could you please take a look?
ericstj commentedon Jul 12, 2019
@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:
danmoseley commentedon Jul 13, 2019
@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.
marek-safar commentedon Jul 16, 2019
@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?
ericstj commentedon Jul 16, 2019
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.0reference, 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.
dehghani-mehdi commentedon Jul 27, 2019
@StephenMolloy what should I do now? I see you closed the issue.
karelz commentedon Jul 28, 2019
@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.
karelz commentedon Aug 7, 2019
Fixed in 3.0 in PR dotnet/corefx#39822 and in master (5.0) in PR dotnet/corefx#39556