Portable class library for MonoDroid and MonoTouch

2019-02-02 13:02发布

问题:

I want to create PCL for MonoDroid and MonoTouch, to share code AES encryption (RijndaelManaged), but Visual Studio wouldn't let me to do so, instead it forces me to add all other frameworks, message is following:

The following frameworks will be selected automatically because they support all of the available functionality that is portable between the other frameworks you have selected: .NET for Windows Store apps, .NET Framework 4.5, Windows Phone 8.

and those frameworks doesn't support System.Security.Cryptography namespace.

Files for MonoDroid and MonoTouch are placed in C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework.NETPortable\v4.5\Profile\Profile78\SupportedFrameworks, witch already contained .NET for Windows Store apps.xml, .NET Framework 4.5.xml, Windows Phone 8.xml.

Can somebody please advice how to isolate Mono frameworks from others, do I need new profile or something else.

回答1:

Afaik has Visual Studio no PCL profile for the Xamarin products. So you cant select it.

You may want to try to enable: .NET >= 4.0.3 and Silverlight 5 to get a Profile that should be compatible with the Xamarin products.



回答2:

EDIT

This is now automatically done by the installer. You will also need the latest version of nuget.


In fact, all you need to do is add an xml file to the correct folder. Magically a PCL profile called "Mono for Android" will appear.

File name:

MonoAndroid,Version=v1.6+.xml

Put in folder:

C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETPortable\v4.0\Profile\Profile104\SupportedFrameworks

File content:

<?xml version="1.0" encoding="utf-8"?>
<Framework DisplayName="Mono for Android"
  Identifier="MonoAndroid"
  Profile="*"
  MinimumVersion="1.6"
  MaximumVersion="*" />

For more information look at the mvvmcross project https://github.com/slodge/MvvmCross