SQL Lite states that its added support for Xamrian Forms and .net standard and yet when I rebuild my project all references disappear what it the correct library I need to get SQL lite working in .net standard 2.0 I am using it to sync between a mobile app and the server.
public async Task SyncAllDeliverys()
{
Task<string> callTask = Task.Run(() => GetDeliverysFromAPi());
// Wait for it to finish
callTask.Wait();
// Get the result
string content = callTask.Result;
//Sends a GET request to the specified Uri and returns the response body as a string in an asynchronous operation
deliverysItems = JsonConvert.DeserializeObject<List<DeliverysItems>>(content); //Deserializes or converts JSON String into a collection of Post
SQLiteAsyncConnection conn = new SQLiteAsyncConnection(dbPath);
await conn.InsertAllAsync(deliverysItems);
}
As you see here my project is .net standard 2.0
Edit 2
To show the correct version that I have installed instead of the incorrect one I showed in the first graphic.
Edit 2
It would appear that this is a known bug and xamrian has submitted it as such in 2019 visual studio.
https://github.com/xamarin/Xamarin.Forms/issues/5983
You are looking at the wrong description of dependencies. The dependencies in the first screenshot(you circled in the right bottom) belongs to sqlite-net-pcl instead of SQLite.Net-PCL.
Package 'SQLite.Net-PCL 3.1.1' was restored using
'.NETFramework,Version=v4.6.1'.
You can try uninstall and install sqlite-net-pcl nuget, clean and rebuild your project.
what it the correct library I need to get SQL lite working in .net
standard 2.0
Use sqlite-net-pcl is the right way. (The fourth library in your screenshot).
There are a number of NuGet packages with similar names, the correct package has these attributes:
Created by: Frank A. Krueger
Id: sqlite-net-pcl
NuGet link: sqlite-net-pcl
Refer: databases
Related
In the Validation Result that I get when readying my app for submission to the Microsoft Store (which my app "PASSED WITH WARNINGS"), I got this "Fail" under the "Package Sanity Test" section:
The code which contains such a call is:
private void myMapsHelpToolStripMenuItem_Click(object sender, EventArgs e)
{
System.Diagnostics.Process.Start("https://ramblingnotesofageezer.substack.com/p/map-o-matic-overview");
}
I am using that code due to the recommendation to do so here. How do I start a process from C#?
Is this truly a problem? If so, what should I use instead of the call to System.Diagnostics.Process.Start()?
I find it odd that it is classified as a failed part of the test, yet the overall results are that my app passed (albeit with warnings).
UPDATE
I checked out the link in the comment from Codexer, where it says, "Starting a utility can often provide a convenient way to obtain information from the operating system, access the registry, or access system capabilities. However, you can use UWP APIs to accomplish these sorts of tasks instead."
If this is the solution, do the UWP APIs have an equivalent to System.Diagnostics.Process.Start()?
UPDATE 2
I followed the steps in the answer, but the solution still doesn't compile, due to an error with this line of code:
await Windows.System.Launcher.LaunchUriAsync(uri);
In fact, even when I comment out the offending line, the project will no longer compile, but doesn't give me any information about how to solve the problem, just this:
I set the Package Management Format to PackageReference, and installed version 10.0.18362.2005 of Microsoft.Windows.SDK.Contracts, but it is complaining about needing a package reference...?!? I tried adding using Windows.System;
and using Microsoft.Windows.SDK.Contracts; but neither is recognized.
The package is installed for the project, as you can see here:
UPDATE 3
Regarding the "Must Use Package Reference" err msg, I have three questions revolving around what I see here:
The verbiage below Microsoft.Windows.SDK.Contracts says I can update versions of this package - should I?
I do not see a Reference to Microsoft.Windows.SDK.Contracts in my project's References, although it has been installed. Do I need to add one - if so, from where?
The context menu on my References affords me the ability to "Migrate packages.config to PackageReference..." should I do that?
If you were developing an uwp application, for opening open a web uri, it is recommended to use Launcher.LaunchUriAsync(Uri) method instead, this method starts the default browser to open the specified URI.
For example:
private async void button_Click(object sender, RoutedEventArgs e)
{
Uri uri = new Uri("http://www.google.com");
await Windows.System.Launcher.LaunchUriAsync(uri);
}
Update:
As Codexer mentioned, you could refer to this document to use uwp api in winform app.
I have created a winform project, its target framework is .Net Framework4.8. For earlier versions of .NET(.NET Core 3.x, .NET 5 Preview 7 (or earlier), or .NET Framework), you could refer to my steps.
1.Click Tools->NuGet Package Manager-> Package Manager Settings-> Change Default package management format to PackageReference. As follows:
2.Install the Microsoft.Windows.SDK.Contracts package, note that you need to install the appropriate version. Please check the corresponding version below. (Installation details: Right click Reference-> Manage NuGet Packages->Browse->Search Microsoft.Windows.SDK.Contracts->install)
10.0.19041.xxxx: Choose this for Windows 10, version 2004, version 20H2
10.0.18362.xxxx: Choose this for Windows 10, version 1903.
10.0.17763.xxxx: Choose this for Windows 10, version 1809.
10.0.17134.xxxx: Choose this for Windows 10, version 1803.
3.Run the project
After reviewing my options regarding saving JWT token, I chose Xamarin.Essentials Secure Storage.
Problem being that my app always breaks when trying to save a token within the storage with the following error:
"System.AggregateException has been thrown"
The details are as follow:
"Xamarin.Essentials.NotImplementedInReferenceAssemblyException
This functionality is not implemented in the portable version of this assembly. You should reference the NuGet package from your main application project in order to reference the platform-specific implementation."
This clearly means that something went wrong in the installaion of the nuget package, so I:
Uninstalled and reinstalled the xamarin.essentials package.
Upgraded .Netstandard to 2.0, thinking that 1.6 wasn't compatible.
Checked if the package is referenced within the csproj file.
So forth, nothing.
For now, I have a TokenStorageController with the following lines of codes :
public bool SaveToken(string token)
{
if(token != null)
{
Preferences.Set(key, token);
if(Preferences.ContainsKey(key))
{
return true;
}
}
return false;
}
The RestService class from where the controller gets called looks like this :
//await SecureStorage.SetAsync("oauth_token", "booommmmmm"); // changed to this simply to check if my controller was the problem
TokenStorageController tokenStorage = new TokenStorageController();
await tokenStorage.SaveToken("boommmmm"); // where I get an error
And here is the exact line where the error occurs:
var loginTask = Task.Run(() => restService.LoginAsync(user)).Result;
If no solutions, I will remove all packages and reinstall them all. ONE BY ONE! I swear I'll do it!
And if no solutions at all, I will store the token within SQL as I already have a controller in place to do so.
I am a Xamarin and C# noob so bear with me please.
FYI: I am using a macOS client for testing purposes, as the cause could be that SecureStorage doesn't work for macOS apps.
Thanks!
Xamarin.Mac is not currently a supported platform, just iOS, Android, UWP.
The code is available for review at:
https://github.com/xamarin/Essentials/tree/master/Xamarin.Essentials/SecureStorage
So I'm trying to do some simple Geography stuff in an old .NET 4.6.2 project. I have EF 5 installed (not planning on upgrading to EF 6).
When I try and do some simple DbGeography.PointFromText("POINT 1 1", 4326); I get a Not Implemented Exception thrown.
e.g.
SqlServerTypes.Utilities.LoadNativeAssemblies (AppDomain.CurrentDomain.BaseDirectory);
var xxx = System.Data.Spatial.DbGeography.PointFromText("POINT(1 1)", 4326);
I thought EF 5 has this method in it and it's totally ok to use? (e.g. reference material about using DbGeograpghy).
Am I doing something wrong? Is it possible the wrong (old?) dll is getting used and therefore, thrown?
Update 1 (Possibly not a duplicate).
It was suggested that the issue is because DbGeography requires (from nuget) Microsoft.SqlServer.Types package. So I tried installing that from nuget, then making sure I 'load' these special dll's at the start of my test. Problem still existed.
Update 2
Using NuGet Microsoft.SqlServer.Types version 14.0.314.76 (current version as of the time of this post)
I'm using a PCL version of Sqlite.net from https://github.com/oysteinkrog/SQLite.Net-PCL
However, I'm unable to get the DB connection setup. The SQliteAsyncConnection does unlike the original version not take a string (path to the DB), but a [Func< SQLiteConnectionWithLock>.]2
How can this be used?
In general: how to use this library? I have a core PCL lib which does all the business logic from my iOS, Android and WP8 projects. My understanding was that I can drop the the Sqlite-Net Async PCL into my PCL lib. But it seems like I have to provide some platform specific stuff to get it to work.
You just need to create a function that returns a SQLiteConnectionWithLock and pass that to the SQLiteAsyncConnection constructor.
string databasePath = "path";
var connectionFactory = new Func<SQLiteConnectionWithLock>(()=>new SQLiteConnectionWithLock(new SQLitePlatformWinRT(), new SQLiteConnectionString(databasePath, storeDateTimeAsTicks: false)));
var asyncConnection = new SQLiteAsyncConnection(connectionFactory);
I've had problems with this too. To meet Johnbot's answer which is correct I am adding how I have used this library and got it to work. I did not really understand the NuGet packages, so I did it manually.
Download the project
https://github.com/oysteinkrog/SQLite.Net-PCL
Load the solution in VS2015, set to release mode and create the dlls for:
a) SQLite.Net
b) SQLite.Net.Async
c) SQLite.Net.Platform.WinRT which is for Windows 10 universal apps, or the platform you need.
Ensure you have these references in your project.
SQLIte for Universal App is installed from VS Tools / Extensions and Updates. Once installed it is referenced under Universal Windows / Extensions along with the Visual C++ 2015 which is also required.
Good luck!
I have created a multi-project template and when creating a new project I'm having success installing nuget packages into all my projects when it comes to regular release versions, but I'm trying to grab signalr's prerelease version and it can't find the version '1.0.0-alpha2'. I assume because its a prelease. Although I can grab it from within VS's PM prompt using :
Install-Package Microsoft.AspNet.SignalR.JS -version 1.0.0-alpha2
...Is there something different with the API that I need to do to grab it or what am I doing wrong?
Example within my project templates wizard
var componentModel = (IComponentModel)services.GetService(typeof(SComponentModel));
IVsPackageInstaller installerServices = componentModel.GetService<IVsPackageInstaller();
installerServices.InstallPackage("http://packages.nuget.org", project, "Microsoft.AspNet.SignalR.JS", "1.0.0-alpha2", false);
Okay this works with https://www.nuget.org/api/v2/ as the target, not the older v1 at packages.nuget.org. Found out v2 with fiddler