PCLStorage in Windows Phone 8 - c#

I'm using PCLStorage for a Win8/Wp8 project I'm working on. I'm using it within a PCL itself, and have it referenced in my Win8, Wp8 and PCL projects. Everything is working great in Win8.
In Wp8 however, once I hit my PCL for storage which uses PCLStorage, I'm getting a NotImpmlementedException when I call FileSystem.Current;
"This functionality is not implemented in the portable version of this assembly. You should reference the PCLStorage NuGet package from your main application project in order to reference the platform-specific implementation."
But like I said, I have the PCLStorage NuGet package referenced in my Wp8 project AND the PCL project the same way I do in my Win8 project.
Any idea what's happening?
(I should also note that PCLStorage is working fine if I use it in a new Wp8 project)

Try uninstalling the PCLStorage NuGet package from all projects and then reinstalling it in all of them.
If it still doesn't work, try checking the references to the PCLStorage DLLs in the WP8 project and make sure they are coming from the wp8 folder in the package.
If that doesn't lead anywhere, try setting copy local to false in the references from your PCL to the PCL Storage DLLs. If you have to do that it's an issue that needs to be fixed, so please file a bug for it.
EDIT: There is a bug in VS 2013 Update 2 RC that can cause this problem. This NuGet package is supposed to fix the issue if you reference it in your Windows Phone app: SuppressPackagingPclFacades. Alternatively setting Copy Local to false for the reference from your PCL library to the PCL Storage assemblies should also fix the issue.

Related

(Nuget PackageReference) Xamarin app builds even when I don't add a reference to Xamarin.Forms

I have a solution with a bunch of Xamarin.Forms cross-platform apps. I'm in the middle of a refactoring where I'm migrating things to Nuget PackageReferences. While doing so I encountered a few problems with portable app projects that referenced Xamarin.Forms, so I decided to uninstall the package from these apps and re-install it, then everything worked perfectly. While doing so, however, I realized that if I didn't reinstall Xamarin.Forms on the portable app package, things would still compile and work.
Can someone please explain to me how it's possible that a C# project that contains Xamarin.Forms code in it doesn't need to have a reference to the Xamarin.Forms package to compile? And does this have to do with Nuget PackageReferences?
Syncfusion.Xamarin.SfChart has a Xamarin.Forms dependency and thus it is auto-added to your project.
Dependencies
Syncfusion.Xamarin.Core (>= 18.2.0.54)
Xamarin.Forms (>= 3.6.0.344457)
re: https://www.nuget.org/packages/Syncfusion.Xamarin.SfChart
as it is well explained before another package has a reference to Xamarin.Forms, but... that's my addition to the response. I see in your code that you have a using Xamarin.Forms; statement, you are adding it as an indirect reference and then you are adding it to that part of code in a using statement that is not erroring. If that should not be added, then it will show with an underlying red mark, then in an error.
For more information about references, please go to https://learn.microsoft.com/en-us/visualstudio/ide/managing-references-in-a-project?view=vs-2019

Nuget Hell: Cannot reference NuGet package in UWP application due to public key difference

I have a UWP app and a bunch of NETStandard 2.0 libraries. The libraries contains a lot of logic and communication interfaces that I am using in ASP.NetCore and Desktop WPF applications, so I am not going to change them.
I use NuGet packages in the libraries so I could reference those in NetCore and NetFramework projects as well. I would like to reference these packages in the UWP project - cause this is the whole point of this standardization concept isn't it?
For the UWP project this does not work. I have the latest Nuget package of System.ServiceModel.Primitives which is 4.5.3 (DLL version 4.5.0.3 - don't ask why) and PublicKeyToken is b03f5f7f11d50a3a - this can be referenced in every project except UWP.
Regardless of every attempt:
- I have installed the Nuget package for the project
- I have referenced the version explicitly in the CSPROJ file
- I have removed every other reference to SDK file version
But still, the UWP project looks for the dll in
C:\Program Files (x86)\Microsoft SDKs\UWPNuGetPackages\microsoft.netcore.universalwindowsplatform\6.2.8\ref\uap10.0.15138\System.ServiceModel.Primitives.dll
That DLL has version of 4.2.1.1 and the PublicKeyToken is cc7b13ffcd2ddd51
Because the two tokens are different - binding redirects does not work - or maybe I am missing something. Does anyone have a workaround for this?
The whole solution is in VS2019 and I have the latest Win10 SDK installed 10.0.18362.1.
Thank you in advance.
EDIT: I forgot to mention, I have a repro on GitHub
You can create a separate .NET Standard project and incapsulate all your logic (and usage of System.ServiceModel.Primitives assembly) into this project. Then you can add it as a reference to the project with UWP executable.
Also you can setup a binding redirect for strongly-named assemblies by specifying codebase according to this article

Unable to install System.Net.Http in Xamarin portable project

Hello I'm new to Xamarin,
I'm trying to install the System.Net.Http to a Xamarin portable project using NuGet Package Manager.
However, whenever I try to download it I get this error
Could not install package 'System.Net.Http 4.3.1'. You are trying to install this package into a project that targets '.NETPortable,Version=v4.5,Profile=Profile259', but the package does not contain any assembly references or content files that are compatible with that framework. For more information, contact the package author
I tried every possible version of the package with no use. Could anybody provide some assistance?
Actually the way I managed to solve this problem was weird
I found a referenced assembly called
.NET --> right click View in object browser --> select System.Net.Http --> clicked add reference to the selected project
and the reference is added
Have you tried to install Microsoft.Net.Http? I use it in my PCL Xamarin Forms apps.
This can be resolved by changing the profile number for the PCL project.
Personally, i would untick all the unneeded target frameworks by going to: Project Options -> Build - General - Change Targets.
In my case i have unticked Windows Phone silverlight 8 and the profile number got changed from PCL 4.5 Profile 259 to PCL 4.5 Profile 111 as shown in this screenshot:
After doing so System.Net.Http can be added easily.

Xamarin Studio cross platform app error

At the moment I'm trying to launch empty app with cross-platform solution in Xamarin Studio.
I've tried make app with empty library project and shared library, both has same errors. Now unresolved problems are:
1) Build error:
Error XA5207: Please install package: 'Android Support Library' available in SDK installer. Java library file classes.jar doesn't exist. (XA5207) (*projectName*)
Error XA5207: Please install package: 'Android Support Library' available in SDK installer. Java library file libs/internal_impl-21.0.3.jar doesn't exist. (XA5207) (*projectName*)
This question didn't help me.
2) Some links says it could be because of old Mono.Android.Support.v4 component. My component version is 21.0.3.0. After clicking for update it says:
You are trying to install this package into a project that targets 'MonoAndroid,Version=v4.0', but the package does not contain any assembly references or content files that are compatible with that framework.
My Mono.Android assembly version is 0.0.0.0 and I dodn't know how to update it.
I've tried PCL project with PCL 4.5 - profile7. New projects builds normal, but after first project clean it gives me error about not found classes.jar file like described above. Another new PCL project still builds fine.
UPDATE
Error in PCL project occures not after clean - it occures with included Xamarin.Forms NuGet to Android project.
UPDATE
After rising target framework of android project to v4.0.3 I successfuly updated Mono.Android.Support.v4 component, but it still show me error about Please install package.
UPDATE
I'm using Windows 7 OS, same problem with all users including new user. But on another computer with Windows 8 it works. It is not a solution for me, but it can somehow help someone.
i think your java JDK and JRE not install properly and your path not set in your environment variable you must add your jdk path in that and if you are make application using cross platform then also add path SDK in your computer environmental variable. using CMD throw creating project.

Azure Mobile Services in a PCL project that includes WP8

Is it possible to inlcude AzureMobileServices client in a PCL that includes WP8?
I used to have a PCL project that had it up until I upgraded it to VisualStudio 2013.
The required PCL is profile78: .NET4.5, Windows Store apps (Win8), WP8, and the Xamarin twins.
I tried following this recommendation from Xamarin to reference the component's DLL directly, however the DLL was compiled for profile7 (that does not include WP8).
Yes. Make sure you are using at least version 1.1.5 of the Mobile Services NuGet package or Xamarin Component and you will be able to successfully use it from a PCL that includes WP8. For a tutorial on how to do this, see here.
It looks like their nuget package only includes directories for Store, .Net 4.5, Wp8, and Portable-Store+.Net 4.5. However if I ildasm the dll in the portable folder I see it was built for Profile78, which does support phone.
This looks like a bug with the WindowsAzure.MobileServices.nupkg nuspec authoring.

Categories