I am developing a Xamarin.Forms application for Android and iOS. The pcl project grew quite a lot and has many nuget packages installed like FluentValidation, SQlite and Newtonsoft.Json. The platform specific projects only have a few lines of code like custom renderer and stuff. The only references they have, is SQlite.
Now this works just fine when compiling for Android. However, when trying to build for iOS, I get an error -> Can not resolve reference (System.EnterpriseServices.Wrapper.dll).
My question is not specific to this dll, furthermore I'd like to know how it really works. I was assuming, I can install whatever package I want into the pcl project. Is there a limitation? Do the packages have to be compatible with Xamarin.iOS / Xamarin.Android? How am I able to track, where the dll actually comes from?
Why does it work in Android but not in iOS?
Yes, there are limitations between the platforms. The different assemblies and/or nuget-packages you use in the PCL-project, need to be comaptible for the platforms you are targeting.
The reason is quite simple: When you build your iOS-project, the PCL project is also building for the iOS target, and therefore the assemblies need to be compatible. The assemblies are just a subset.
Xamarin.iOS, Xamarin.Android, and Xamarin.Mac all ship with over a
dozen assemblies. Just as Silverlight is an extended subset of the
desktop .NET assemblies, Xamarin platforms is also an extended subset
of several Silverlight and desktop .NET assemblies.
When you want to use an assembly, which is only compatible for android, then add it in the android-project and not in the PCL project.
You can find a list with supported assemblies over the platforms on the Xamarin Developer page.
On this list you can see, that System.EnterpriseServices.dll is only available for android and not for iOS. Additionaly you cand find some limitations using SQLite/System.Data on the iOS platforms on this page.
Related
I am developing a Xamarin.Forms app in Visual Studio and I need to use an external SDK that is dedicated for Windows Form apps. I have been trying to add a reference to System.Windoes.Form but it doesn't appear in the assemblies.
I know it wouldn't make sense using windows forms in a Xamarin project, but I am creating the user interface with Xamarin graphics, I just need to add the reference to Windows.Forms to get rid of the following error:
Can not resolve reference: System.Windows.Forms, referenced by MY DLL. Please add a NuGet package or assembly reference for System.Windows.Forms, or remove the reference to MYDLL.
Is there a way to do so?
Thanks
.NET can be categorized into three and those are, .NET Core, .NET Framework and Xamarin.
The .NET Framework supports Windows and Web applications.
.NET Core is the new open-source and cross-platform framework to build applications for all operating system including Windows, Mac, and Linux.
When you want to build mobile (iOS, Android, and Windows Mobile) apps using C#, Xamarin is your only choice.
You cannot use System.Windows.Forms inside a Xamarin Project and it is incompatible.
I'm new in Xamarin, Xamarin.Forms and C# platform.
I'm starting the development of an app that should support Android and iOS devices. I'm using a PCL project for code sharing. Currently this project is using the profile111 because Visual Studio has selected it by default for me. But when I try to install some NuGet packages I'm getting a message saying the package is not compatible. Something like:
Could not install package 'DocsBrStandard 2.0.1'. You are trying to
install this package into a project that targets
'.NETPortable,Version=v4.5,Profile=Profile111', but the package does
not contain any assembly references or content files that are
compatible with that framework.
I believe this message is related with the profile I'm using, right?
So which profile should I use for my app that should support only iOS and Android devices? Is profile111 the more appropriate for this scenario?
At least, how can I identify if a package is compatible or not with my Xamarin.Forms app?
Thanks.
You need to target .NET Standard to be able to use the DocsBrStandard package. So you can't work with profile based PCL if you want to use that package.
Check out this article about targeting .NET Standard with Xamarin.Forms:
https://blog.xamarin.com/building-xamarin-forms-apps-net-standard/
I tried both the .NET Standard and the Class Library (Xamarin.Forms) projects and didn't get any project for iOS and Android. I then tried Cross Platform App (Xamarin) and had to manually change the target to .NET Standard, which forced me to first remove the original NuGet packages. And now the project is littered with red squiggly lines.
So how do I create a Xamarin.Forms project targeting .NET Standard, for iOS and Android (and UWP)?
For now, you'll need to do it manually as you described above, because there is no template available.
The current release of Xamarin.Forms, v2.3.4, doesn't support NET Standard. However, Xamarin.Forms v2.3.5 does support NET Standard, and it is currently available on NuGet as a pre-release.
After manually converting your PCL to NET Standard, add Xamarin.Forms v2.3.5 to it.
I don't think there is a template for that at the moment.
If you want to put all the platform independent code into the NetStandard project create one using Cross Platform App (Xamarin) - then select Xamarin.Forms and Portable Class Library (PCL)
Then delete the PCL and (from the solution and the folder) and add a netstandard library in it's place (and reference it in the platform projects)
I'm always using the 'Shared Project' approach and adding everything non Xamarin.Forms (like ViewModels) in a separate PCL / netstandard library.
On http://docs.xamarin.com/ios/about/assemblies it says that if I want to provide my code as an assembly to other MonoTouch developers: "You must recompile your source code to generate assemblies targeting the MonoTouch profile".
How do I do that?
How do I do that with Visual Studio?
How do I do that with msbuild?
I found MonoDevAssist at http://monodevassist.codeplex.com/documentation, but the instruction there said I should copy a bunch of DLLs from "your Mac". I don't have a Mac. I have installed MonoTouch for Android on my Windows machine, but I can't find a directory like the one in that description.
I have installed MonoTouch for Android on my Windows machine
What you likely have is Mono for Android which runs fine on Windows and targets Android.
MonoTouch is another product from Xamarin, targeting iOS (iPhones, iPod, iPads) and it requires a Mac computer.
Even if there's quite a bit of features shared between the two products, in general, you need to look at the documentation for the product you have.
How do I do that?
Simply re-compile your existing source code including reference(s) to the assemblies that are shipped with Mono for Android.
How do I do that with Visual Studio?
Create a new project, e.g. a library, for Mono for Android. Add your source code to the project. Add references to the SDK assemblies you requires. Rebuild your code.
Hi there I am new to the windows phone development and I am trying to build a data driven application in which I have Created my BLL and EL and DAL ,which are all of windows phone class library type project.
I have also an extra project of type class library in my solution in which I have added the Reference to "MyGeneration.dOOdads.dll" file .
Now I want this project to be referenced in the windows phone app project.But when I try to add a reference ,The VS 2010 says...."Unable to add the selected project refernce.The project reference must be another silver light for windows phone project that is the same or the lower version ".
.
.
.
Kindly help me in this scenario. Thanks
That can't and won't work. The phone runtime only has access to a timy subset (well, sort-of) of the full .NET libraries, so any non-phone-7 library is extremely unlikely to operate at all. To stop this surprising people, only libraries built against that runtime are allowed to be referenced.
If possible, create a new project with the same c# files, targeting the phone 7 framework. Now reference this project. It is quite likely that some bits will fail to compile (demonstrating the fact that it also wouldn't have run), which can be rectified in a number if ways (#if blocks, alternative .cs files, etc).
You might also have some luck by making the existing project a "portable class library" - this, however, is the most restrictive subset of all the common frameworks, and is even less likely to still compile (without changes).
Using the Portable Class Library project, you can build portable assemblies that work without modification on the .NET Framework, Silverlight, Windows Phone 7, or Xbox 360 platforms.
(from MSDN)