Greetings,
Recently i come cross a problem while developing a cross platform project.
In this project, I have to support android, ios, and wp7, what I did is to create 3 projects for these 3 platforms, and I have another project which can be shared among the 3 target platform.
So I created this project as a "Portable Library", and add reference to this project in the other projects. It worked, I can use Class defined in this shared project in the other 3 projects, but the problem is, in the portable library project, the "References" folder, "System", "System.Core", and "System.Xml" are red, when I unfold it, it says "assembly not available for .NETPortable 4.0 Profile1 Profile (in Mono 2.10.9)". I googled this piece of information, but none gave me the satisfying answer.
http://monotouch.2284126.n4.nabble.com/cross-platform-library-code-td4656600.html
So, how can fix it? What are these "System", "System.Xml", "System.Core" for? Are they files? Or within a file?
You can ignore the references being red for now. That just indicates that you don't have the PCL assemblies on your system (which you won't have unless you are on Windows), however Xamarin is working on generating PCL assemblies and hopes to have them "soon" (by May?).
In the meantime, this is "ok" because when you are targeting Mono for Android or MonoTouch on Mac OS X w/ MonoDevelop, what MonoDevelop does is link with the Mono for Android or MonoTouch frameworks instead, which is good enough for what you want do to.
Things to consider:
You won't be able to share the assembly with your WP7 app (because the assembly built by MonoDevelop won't be a true PCL assembly), but you'll be able to share the Portable Library project - i.e. just make sure to do a fresh build of the project for each platform. (you can share between MonoTouch and Mono for Android, but not with WP7)
Since the referenced assemblies are red, as you've noticed, it means that MonoDevelop won't be able to do proper code-completion. If you're a Windows guy, you could just develop the Portable Library in Visual Studio and then just share it with your iOS and Android projects. Once Mono has real PCL assemblies, this problem will go away.
There are some bugs in the current public releases of MonoDevelop and Xamarin Studio where it doesn't like certain profiles. Both of the following custom builds address this issue, depending on whether you want MonoDevelop or the sexier Xamarin Studio:
https://files.xamarin.com/~jeff/MonoDevelop-3.1.1.dmg
https://files.xamarin.com/~jeff/XamarinStudio-4.0.2442.dmg
Keep in mind that neither of these custom builds have been QA'd. the XamarinStudio link was just sent off to the QA team last night (hot off the press!) for what will become Xamarin Studio 4.0.2 (once any regressions / critical bugs that QA turn up in that build have been fixed).
Related
I'm working on a UWP application that has both a UWP app and a small Win32 program, linked from a UWP packaging project. My solution looks something like this:
OneLocker (UWP)
OneLocker.AutoTyper (Win32, WinForms in particular)
OneLocker.Package (with references to the two above)
This all works fine, and if I try to create an app package just for the UWP application, I see all the various ARM/ARM64/x86/x64 options (enter image screen here), as I've followed the guide here to add the new ARM64 configuration.
The problem is that when I try to build the whole Package, including both the UWP app and the Win32 program, I only see the x86/x64 options (enter image screen here). Here is the complete .csproj file for the Win32 program in the package.
Now, I'm not 100% sure here, but from what I understand it should be possible to also build a UWP package project for ARM64 now, so that it'll run on devices with Windows on ARM without the need for the x86 to ARM emulation, right?
If so, is there something specific I need to add to my projects, or something to configure, in order to enable the ARM64 build configuration for the packaging project as well? Or, is this even supported already at the moment?
The only blog post I found about this (this one) only mentiones C++ UWP/Win32 applications, and not UWP packaging projects.
Thanks!
EDIT: here's some clarification on what I'm trying to do. The main point for me is: I want to be able to build the app package (UWP + Win32) for ARM64 as well, so that users running Windows on ARM can use that instead of either the x86 package (which would be slower, as it'd be emulated), or the standalone UWP app in ARM64 (which would run fine, but lack the additional features of the package).
As I've mentioned earlier, this is what I see from the build window for the packaging project. I'm aware that WinForms doesn't support ARM64, and in fact I'd be perfectly fine having just the UWP app in the package built for ARM64, and the Win32 part in Any CPU. The thing is that if I pick the Neutral/ARM64 combo from the first line (see the linked image), I then can't also pick the x86/x64 targets, as VS tells me I can't mix specific and neutral architectures in the same package.
To recap, here's what I'd want, in theory:
x86 package (x86 UWP and WinForms) ✔
x64 package (x64 UWP and WinForms) ✔
ARM64 package (ARM64 UWP and Any CPU WinForms) ❌
ARM standalone UWP app ✔
Is there any way to achieve this?
The Windows Packaging Project will produce ARM64 packages if the referenced projects support this architecture. Actually WinForms, or any other .NET Framework, do not support ARM64.
You can produce a bundle supporting different architectures that will optimize your UWP components and use the AnyCPU version for the WinForms.
Can you describe your application requirements and which architectures would you like to support in your packages?
Thanks,
Rido
I decided to give Cross Platform Apps a go. I have been searching for tutorials for hours. A lot of them look interesting but i hit a problem at the start every time. Every tutorials tells me : File -> New Project -> Visual C# -> Cross-Platform -> Cross-Platform App (Xamarin.Forms). When i do this, i have to choose some settings, including "Blank App" and the Code Sharing Strategy. And that's where it goes wrong.
I should be able to choose Portable Class Library but it's not there. I can choose between "Shared Project" and ".NET Standard". Did I forget to install something or has the Code Sharing Strategy changed?
With Visual Studio 2017.5 they removed the option to create PCL option from the cross platform app. The standard class library is a better option than the PCL because the PCLs only allowed you to use the framework functions all the targeted platforms support. With standard libraries you have a list of functions it must support on all the platforms so you have much more available to you in the standard library than a PCL
I'm working on an Android project in Xamarin for Visual Studio.
I'm getting an error whereby the Xamarin.Facebook.Android SDK targets the 5.1 framework, which is what my
Target Framework(Compile using), Target Android version and Minimum Android version are all set to(Have tried different variants of higher and lower).
The package in question has a dependency of Android V7, which I have installed.
Have an added an image for good measure.
This is a fresh project, and i've tried rebuilding the solution after any trial-and-error changes to the project's properties.
Screenshot: https://ibb.co/jOtfKk
Is this a bug, or has someone else encountered this scenario?
Created another project and it miraculously worked this time.
Man I hate the VS, C# and Xamarin world.
I am working with the GoPro camera and trying to run a library made by r1pper. The project is described as
A lightweight c# library to access and control GoPro HERO Action cameras
It has a functional media browser based on Ambarella and GoPro App, it has also the full control of the camera, and live preview.
I am having trouble when trying to compile on the Xamarin IDE:
/Library/Frameworks/Mono.framework/Versions/3.10.0/lib/mono/4.5/Microsoft.Common.targets: Error:
Unsupported PCL Profile '.NETPortable,Version=v4.0,Profile=Profile96'. (GoPro.Hero)
I have looked at a couple of forums and blogs that mention there is no fix for this bug:
http://forums.xamarin.com/discussion/164/pcl-build-problems
http://forums.xamarin.com/discussion/6334/problem-with-pcl-support-after-update
Is there really no workaround to this bug? Or am I misunderstanding something?
It looks like Profile 96 is not available in Mono.
I would change the Portable Class Library (PCL) project so it targets a different profile that is available on Mono. I would pick Profile 78 or Profile 259 since these are the ones generally recommended by Xamarin. You can do this in the Project Options under Build - General.
You may need to reinstall/retarget the NuGet packages after changing the project's PCL profile. If you are using a recent version of Xamarin Studio then it should tell you if this is the case in the Package Console window.
If I'm not mistaken you didn't install Visual Studio 2012/2013 (which Automatically configure MSBuild for PCL usage), in this case you should install and configure PCL on your system manually (it is only needed for development, not for distribution)
Here are the steps based on this Guide
1- Install .NET Framework 4.5.1
2- Install Mono MDK
3- Install PCL Library Tools : it will install MSBuild tools and Profile96
4-(Optional) Install PCL Reference Assemblies for newer PCL profiles
after installation copy 4.6 PCL assemblies from
C:\Program Files (x86)\Microsoft .NET Portable Library Reference Assemblies 4.6\PortableReferenceAssemblies.zip
to
C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETPortable
5-Reinstall Xamarin Suite
In Visual Studio 2012 in a blank new Class Library I am trying to add reference to an existing project in the solution, also a Class Library, MonoGame.Framework.Windows8 (https://github.com/mono/MonoGame), but get the error:
Unable to add reference to Project MonoGame.Framework.Windows8
I have built the existing library, MonoGame, successfully and made it a dependency of the new one. What could be the problem?
(It's extremely annoying the error message does not give a reason!)
Trying to add the built dll has a reference gave a more explicit error message which has solved the problem for me, it said:
“A reference to ‘x’ could not be added. The project targets ‘.NetFramework’ while the file reference targets ‘.NetCore’. This is not a supported scenario”
The MonoGame Class Library is a Class Library (Windows Store apps) type! (The bit in parenthesis is important! Presumably the difference is the Windows Store apps type use .Net Core which is not the same as .Net Framework).
So to get it working your project must be a Class Library (Windows Store apps) which is available under the Windows Store option in Add New Project.
I suspect the problem is to do with the 'Target Framework' in project options.
I don't know how MonoGame works for Windows 8 but when you're developing for Android the target framework options are the different versions of Android [e.g. Android 2.2 (Froyo)]. When you create a regular class library you have choices between the different versions of the .NET framework or Mono [e.g. Mono / .NET 4.0].
Unfortunately, these frameworks are not compatible with each other. You can't add a project reference for Android to a .NET framework class library and visa-versa.
The solution is to use a Portable Class Library. They are specifically designed to deal with this issue. The downside is that you will only have access to the subset of assemblies provided in the lowest denominator you choose to target.
You might also want to consider code sharing between projects using linked files. It can make maintenance a little trickier but gives you a little more control over code that should compile in both target frameworks but doesn't fit into the portable class library. Here's a related question:
Project reference vs. file links in Mono multi-target projects
The key to all of this once you understand what's going on here is how you structure your solution. With a little care you can have nearly all your code shared across different platforms.
I might be because of both projects are using different Framework versions and change the Framework versions in both Projects of properties section then your problem might solve.
Same question I guess here:
Visual Studio 11 metro apps unable to add reference?
The answer was:
What are you adding a reference to? Metro style apps can only add references to other Metro style class libraries or portable class libraries