MvvmCross actual SQLite plugin to use in .NET Standard project - c#

I am developing an app with .NET Standard 2.0 project as core project, so bumped into the fact, that I am not sure how I should (can) handle the famous easy-to-access-and-setup approach with MvvmCross.
Search for Cirrious.MvvmCross.Plugins.Sqlite plugin in Nuget doesn't return anything (apparently it's been a while and it's not supported).
SQLite-PCL doesn't seem like sound .NET Standard-ish, plus there is a whole bunch of different packages with similar name (and with no any close reference to MvvmCross actually) appear.
There is also a reference to sqlite-pcl-net plugin in release notes for MvvmCross 5, but it also "doesn't smell" Mvx-y.
So, what's going on with MvvmCross SQLite these days? What should I use? Any ideas?

There used to be an official MvvmCross Plugin for SQLite but it was dropped sometime around early 2017 because the plugin was redundant. SQLite is probably the most popular database used in MvvmCross applications, but there is nothing in MvvmCross requiring this. You are still free to use Realm, Entity Framework Core, etc.
You should be using the praeclarum/sqlite-net version of SQLite since Android 7.0. Here is the NuGet feed for the package. This version supports .NET Standard and PCL. Other forks are not maintained as much, or stopped working reliably on Android due to the changes to the way SQLite was changed in Android 7.0.
I've also recently provided another answer to a question asking how to add SQLite to an MvvmCross application since the plugin was removed. I provided some sample code for Android in the answer. The old MvvmCross SQLite Plugin source code is also still available.

Related

Xamarin.Forms - "Target .NET Platform Standard" option not appearing

I'm currently using a PCL in my Xamarin.Forms project and would like to change it to a .NET Standard library. I've looked up tutorials and as far as I understand the first step is to click the "Target .NET Platform Standard" option in the PCL project's properties. The issue is this option is not shown to me, instead, to me, there's a text saying "Learn More" which when clicked takes me to a page comparing .NET Standard to PCL and more https://learn.microsoft.com/en-us/dotnet/standard/net-standard#comparison-to-portable-class-libraries. What should I do?
I did run into the same problem. We tried to convert all our PCLs to .NET Standard. And we thought, that let them "Target .NET Standard" makes them pure .NET Standard libs, but this assumption was wrong. We ran into several problems, untill we realized, that there are some small differences between a PCL Targeting .NET Standard and a pure .NET Standard library.
The Solution was to create new libraries for every PCL and copy the files into the .NET Standard libraries. We are working on .NET Standard 2.0 libs in our Xamarin project now and everything works as expected. Atleast after we updated our VisualStudio to the newest version and after updating resharper to an EAP Release.
So i'd recommend you to go the same way and just create new .NET Standard libraries for your PCL projects and copy the contents.
Additional Information
Microsoft.NetCore.CompatibilityPack
You will run into issues of incopatibility with nuget Packages that do not support .NET Standard yet. You will need this package
Channel9 How To
The following links provides a Channel9 video showing how to migrate to .NET Standard. The guy also talks about the CompatibilityPack and fallback targets https://channel9.msdn.com/Shows/XamarinShow/Snack-Pack-15-Upgrading-to-XamarinForms-to-NET-Standard

Can I reference a .NetStandard library from my Windows 10 UWP app?

There are TONS of posts, blogs, articles, etc... explaining all of this confusing stuff with regard to .Net/.NetCore/.NetStandard and I have read many of them.
Here is the issue, I have a Windows 10 UWP app and I need to reference a library that I created. I first created the library as a NetCore library but I could not reference that from my UWP app (which is confusing because UWP uses .Net Core but the .Net Core library I created assumed this was for ASP.NET?).
So, then I tried to create the library as a PCL library and targeted ONLY Windows 10 UWP (which it then forces you to Windows 8.1 because they are the same). With this type of library I am confident I would be able to reference it from my UWP app but it caused me to lose too many .Net namespaces that I could not get the library to build.
Finally, I then selected the link, in the project properties, to target the .Net Standard instead. I selected .Net Standard 1.4 and suddenly, I had all the namespaces I needed available to me and I was able to build my library. I am also able to successfully add it as a reference to my UWP app.
However, I am getting the following 6 exceptions and they don't tell me too much about the root cause so I can fix it.
So, my main question is, can you reference a .Net Standard 1.4 library in your UWP app? Second, any ideas what these exceptions mean?
Thanks!
EDIT - I have uploaded both csproj files here:csproj files
Okay, I found that answer but it was based mainly on this answer which I did not see before posting my question due to search terms (I have literally spent over a day searching and trying to find an answer).
Answer that helped:
Here is a summary:
.NetStandard 1.4 is supported by UWP.
By default, VS 2015 Update 3 template for a UWP project imports Microsoft.NetCore.UniversalWindowsPlatform version 5.1.0. I am sure the VS 2017 template will start off with a newer version, 5.1.0 is fairly old. So, based on the answer linked above, I updated (using NuGet) to the newest version allowed by VS 2015 Update 3 which at the time of this answer, is version 5.2.3. There is a 5.3.x version but it requires VS 2017.
Finally, I modified the project.json in my UWP project to import the netstandard1.4 framework. It looks like this:
"frameworks": {
"uap10.0": {
"imports": "netstandard1.4"
}
And, with those simple steps, I can get the UWP project to build and those 6 errors above go away.
Hope this helps!

NuGet and handling updates for Framework and Core

A while back, I experimented with NuGets while I was working on some programs. Recently (especially when I learned how to make a Direct Linking Library, so two of my programs use any code that is identical), I noticed that there are NuGets made by Microsoft that have names, similar to those shown at the start of every cs file (example: System.IO). I recall that Microsoft was going to issue updates for .NET Framework through these, but I never found how to apply them. So, I'd like to ask the following questions:
Does Microsoft distributes .NET updates for programs written for Framework 4.6.x? If yes, how do I apply them to my program?
Do I need to distribute the DLL files as well when I release an update to a program?
In addition, what do NETCore and NETStandard Nugets do exactly? I tried to install a set of NETCore to a 4.6.2 program, but it couldn't install them due to a dependency error.
Thank you in advance.
.NET Framework itself is considered part of Windows, and Microsoft does provide periodical updates via its channels automatically. Usually you should do nothing, but if your apps depend on specific hot fixes, then you have to ship them in your installers.
Anything you added as NuGet packages becomes part of your apps, and you become responsible to keep them up-to-date. So with your own app updates, you should ship new assemblies from updated NuGet packages.
.NET Core apps bundle the runtime, so you are fully responsible to republish your apps with updated runtime frequently. Check Microsoft LTS/Current support policies at http://dot.net

The dependency Twilio in project does not support framework DNXCore, Version=v5.0

I'm interested in figuring out how to use the Twilio API, and I am building an ASP.NET 5 application using the Twilio API with MVC6 (trying to follow this tutorial). So far, I have created an empty ASP.NET 5 application, and I added "Twilio" to the dependencies in project.json. I get the following error:
"The dependency Twilio 4.0.3 in project TwilioTest does not support framework DNXCore, Version v5.0"
I notice that when I remove "dnxcore50" from "frameworks", the error goes away.
I'm not sure what this means or how to approach it. I'm still pretty new to .NET and trying to wrap my head around how all of the pieces fit together. Does it mean that Twilio isn't compatible with DNXCore? Since all I want to do for now is learn how to use Twilio, could I essentially remove the dnxcore50 framework from the project and continue working through building the app?
The Twillio NuGet package is dependent on the full .NET stack, which in project.json frameworks terms is DNX451. What that means is, you can add the Twillio NuGet package and remove the DNXCORE50 reference and your project will run as expected and you will be able to use the Twillio API. As far as I know the only major drawback is that your ASP.NET Core project will no longer be cross platform as you are now dependent on the full .NET Framework stack which is only present in Windows.
In a nutshell, you should be fine unless you are planning to deploy to Linux/OSx. Hopefully as ASP.NET CORE becomes mainstream more 3rd party SDKs will be built to require only DNXCORE50 as a dependency.
Another option don't use the Twillio Libraries and code against their REST API. See documentation here: https://www.twilio.com/docs/api. But I wouldn't recommend this if you are deploying to a Windows environment.
Twilio is working on their .Net Standard (Core) library. In the meantime, I've published a .Net Core port of their library to unblock our current projects until we get the official update. Feel free to take it for a spin:
Install Twilio.NetCore from Nuget.
And you can check out the source on Github.

Prexisiting dlls (.NET 4 framework) issue with mono for android

I am creating a fresh Mono for android application using http://xamarin.com/monoforandroid
I selected Mono for Android Application using Visual C# option.
My Android target version is :
I went to references of the project and tried adding my pre existing dlls (made in .NET 4 Framework)
and I got this error:
The strange stuff is there is no option to change the .NET Framework from project properties. Can you tell me what I am missing?
The problem here is that you're trying to reference a .NET 4 DLL from a project that isn't .NET 4. Mono for Android uses its own profile for .NET, which is very similar to that of Silverlight (but not exactly the same). While it's possible that adding a DLL compiled for a different profile will work, it's very risky as you will probably run into problems at runtime where your app will crash, due to something being missing from the Mono for Android profile.
The best answer right now is to create a Mono for Android class library, link in the appropriate files from the library you want to use, and reference that. This will give you compile-time checking that you're not using anything unsupported by the Mono for Android profile, and help keep you more sane in the long run. I have an old blog post up here that talks about how to link files across projects.
That said, in this case you're in luck because someone else has already done that last part for you! Check out this fork of Json.NET which provides versions for MonoTouch and Mono for Android.
The strange stuff is there is no option to change the .NET Framework from project properties. Can you tell me what I am missing?
It's not particularly strange - that dialog box was written by Microsoft, with its own project types in mind. It sounds like Mono for Android doesn't have the same options available.
I strongly suspect you'll just have to use a version of JSON.NET targeting .NET 3.5.
(Having said that, Mono for Android claims to support "dynamic language features" which sounds like it should be targeting .NET 4. Odd. I suspect the fix is the same though.)

Categories

Resources