How do I connect to SQLite with Simple.Data.SQLite - sqlite

I wrote this code in Webmatrix 2.0 beta:
string Dbfile=HttpContext.Current.Server.MapPath("data/db.db3");
var Db = Simple.Data.Database.OpenFile(Dbfile);
Simple.Data.SimpleDataException: No ADO Provider found.
why??
I'm sure that I have included the reference:
packages.config
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Simple.Data.Ado" version="0.16.1.0" />
<package id="Simple.Data.Core" version="0.16.1.0" />
<package id="Simple.Data.Sqlite" version="0.16.0.0" />
<package id="System.Data.SQLite" version="1.0.80.0" />
</packages>

In my test application conn is the physical path including the the db filename and calling
cn = Database.OpenConnection(conn);
works for me. When I used OpenFile I also received the No ADO Provider error.
I am using (from NuGet):
Simple.Data.Core 0.16.1.0
Simple.Data.Ado 0.16.1.0
System.Data.SQLite 1.0.80.0
Simple.Data.Sqlite 0.16.0.0
System.Data.SQLite 1.0.80.0

Getting the dlls required for the System.Data.SQlite can be hassle. If you want to do it quickly then download the Nuget extension for VS 2010. Then you can get the dlls from the extensions console.
Make sure you read the extension installations instructions.

Related

Dotnet build for private nuget packages fails with "Unable to load the service index for source https://privatenuget.org/F/packages/api/v3/index.json"

I have private nuget repo packages in my solution and when I restore them to build my app in Visual Studio, I get the following error
Severity Code Description Project File Line Suppression State
Error NU1301 Unable to load the service index for source https://myprivate.privatenuget.org/F/privatepackages/api/v3/index.json. MyPrivate.Project.Repository C:\Pth\To\source\repos\Project\src\Project.name\Project.csproj 1
With the popular resolution
Nuget connection attempt failed "Unable to load the service index for source"
I tried deleting %AppData%\Roaming\NuGet\NuGet.Config and restarting VS which is not working for me.
My Nuget.Config looks like this.
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageSources>
<add key="MyGet.orgV3" value="https://myprivate.privatenuget.org/F/privatepackages/api/v3/index.json" />
</packageSources>
<packageRestore>
<add key="enabled" value="True" />
<add key="automatic" value="True" />
</packageRestore>
<packageManagement>
<add key="format" value="1" />
<add key="disabled" value="False" />
</packageManagement>
</configuration>
Even tried dotnet restore --interactive
But in futile
dotnet restore --interactive
Determining projects to restore...
C:\Pth\To\source\repos\Project\src\Project.name\Project.csproj : error NU1301: Unable to load the service index for source https://myprivate.privatenuget.org/F/privatepackages/api/v3/index.json. [C:\Pth\To\source\repos\Project\src\Project.name\Project.csproj]
The repo needs either a password/AzureAAD identity for access and I have logged into the visual studio/terminal with the account I have access to the private repo. I think this is somehow stopping the service index to load, but I have a roadblock to achieving it.
The access to the private package repo:
My Package sources looks like this:
I got a dirty solution.
I decided to use private nuget repo username and password in the Nuget.Config ( at least locally ).
I changed the Nuget.Config to:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageSources>
<add key="MyGet" value="https://myprivate.privatenuget.org/F/privatepackages/api/v3/index.json" />
</packageSources>
<packageSourceCredentials>
<MyGet>
<add key="Username" value="myusername" />
<add key="ClearTextPassword" value="mysecretpassword" />
</MyGet>
</packageSourceCredentials>
<packageRestore>
<add key="enabled" value="True" />
<add key="automatic" value="True" />
</packageRestore>
<packageManagement>
<add key="format" value="1" />
<add key="disabled" value="False" />
</packageManagement>
</configuration>
I deleted the NuGet.Config from NuGet folder by running
Then, from VS Developer PowerShell Terminal ( because it is not working with the UI build tab ) I ran dotnet restore and the packages got restored.
I'm looking for better answers to avoid passwords in clear text.
The issue was that I messed with the private package repository password that would be prompted when the VS loads the project. If you entered it wrong once, you would never get the package restored.(which is pathetic....as the reason for the restoration failure is not explicit.)
But we can easily solve this by the following steps:
If Visual Studio does not prompt for credentials but the logging Output shows that you did not authenticate correctly, then go to
Control Panel\User Accounts\Credential Manager
and click "Windows Credentials". You can remove stored credentials for nuget/github there. If they become invalid - for example because you regenerated a token - Visual Studio does not prompt to overwrite the invalid credentials, but after removing the credentials and restarting Visual Studio you do get the prompt.
I found it from the stackoverflow answer here: Nuget Package Source is not prompting for credentials

How to determine valid NuGet package version combinations for NanoFramework

I am building a .NET NanoFramework demo using the ESP32_VROOM_32 board. I'm having trouble figuring our the correct combination of NuGet packages to avoid getting an assembly mismatch error when I try to debug my solution on the actual hardware. This error I keep getting when I push to the device is:
[Found assemblies mismatches when checking for deployment pre-check.]
The combination of packages I currently have installed are:
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="AMQPNetLite.nanoFramework" version="2.3.0.39" targetFramework="netnanoframework10" />
<package id="nanoFramework.CoreLibrary" version="1.7.3-preview.4" targetFramework="netnanoframework10" />
<package id="nanoFramework.Hardware.Esp32" version="1.2.1-preview.12" targetFramework="netnanoframework10" />
<package id="nanoFramework.ResourceManager" version="1.0.0-preview.15" targetFramework="netnanoframework10" />
<package id="nanoFramework.Runtime.Events" version="1.4.2-preview.8" targetFramework="netnanoframework10" />
<package id="nanoFramework.Runtime.Native" version="1.4.0-preview.1" targetFramework="netnanoframework10" />
<package id="nanoFramework.System.Collections" version="1.0.1-preview.7" targetFramework="netnanoframework10" />
<package id="nanoFramework.System.Math" version="1.2.0-preview.16" targetFramework="netnanoframework10" />
<package id="nanoFramework.System.Net" version="1.4.1-preview.21" targetFramework="netnanoframework10" />
<package id="nanoFramework.System.Text" version="1.0.0-preview.22" targetFramework="netnanoframework10" />
</packages>
My question is, is there a reliable systematic way to determine which combination of NuGet packages will work together with the firmware installed on the device?
I have tried many different combinations and can't get anything to work.
Currently, I have 1.4.0-preview.208 firmware installed on the ESP32, which appears to be the latest stable version.
There is no direct relation between the versioning of the C# libraries and the native firmware implementation. That's because each part has it's own separate development cycle.
The declaration is on which native version it requires. From managed to native, not the other way around.
This is showned on the NuGet description. If you want to learn more about this, take a look at this blog post here.
In the meantime know that stable releases have been published for all class libraries and firmware. The links for the firmware images have been updated.
Each NuGet package has a declaration on which other packages it depends on and which version. There is no other way to determine a valid package combination.
The fw version you have loaded it's not a stable version, therefore the "preview" in the version. But neither are the NuGets. Which is all OK: if you are using the "preview" firmware you have to use the "preview" NuGets.
Can you post here the error message about the version mismatch that you get? This will help determine what is wrong there.

Can't install NuGet package Serilog.Sinks.*

I am facing a problem to install packages of Serilog.Sinks in an old project, e.g. when I try installing Serilog.Sinks.MSSqlServer I get the following error:
An error occurred while retrieving package metadata for Serilog.2.6.0
I have already installed package Serilog.2.6.0 and the process went fine, I tried running the code that uses this library and it works okay, but in case I try to uninstall this package I get the error:
Object reference not set to an instance of an object
Thus, I think that something might be wrong with Serilog.2.6.0 in my machine, since I cannot uninstall it or install any of its sinks, but I can't figure out the problem.
Details:
Visual Studio 2015
.NET Framework 4.5 Web Forms
Hi this worked for me nugget install Serilog.Sinks
If you can't uninstall your nuget via package manager console or with Nuget Package Manager, you still have the option to uninstall it. Open your package.config file.
Looks like this:
<packages>
<package id="Respond" version="1.2.0" targetFramework="net461" />
<package id="Serilog" version="2.6.0" targetFramework="net461" />
<package id="WebGrease" version="1.5.2" targetFramework="net461" />
</packages>
There you will find the id of Serilog your dependency with the version associated. Remove that line. And then unload your project, edit it, there you will find the HintPath of Serilog:
Looks like this:
<Reference Include="Serilog, Version=2.0.0.0, Culture=neutral, PublicKeyToken=24c2f752a8e58a10, processorArchitecture=MSIL">
<HintPath>..\packages\Serilog.2.6.0\lib\net46\Serilog.dll</HintPath>
<Private>True</Private>
</Reference>
Then the package Serilog could be uninstalled complete by manually.
Besides, if you re-install that package still get the same error after uninstall it, this issue should be more related to the NuGet rather than the package Serilog.
In this case, please try to uninstall the NuGet Package Manager for Visual Studio 2015 from Tools->Extensions and Updates, restart Visual Studio. Then install the latest version NuGet:
https://dist.nuget.org/visualstudio-2015-vsix/latest/NuGet.Tools.vsix
After the installation is completed, Reopen the Visual Studio in Administrator mode (right-clicked Visual Studio and started in Administrator mode), try to install that package again, check if it works fine.
The thing that worked for this case, from those I tried, is copying the references (.dll files) from another project where they're working fine. Thank you for your answers! :)
It works fine with me with the following package.config setting:
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Serilog" version="2.6.0" targetFramework="net461" />
<package id="Serilog.Exceptions" version="4.1.0" targetFramework="net461" />
<package id="Serilog.Sinks.File" version="3.2.0" targetFramework="net461" />
</packages>

Extension method IsNullOrWhiteSpace with the same namespace is placed in two assemblies

I have ASP.Net MVC project. The project contains WebGrease, packages.config:
<package id="WebGrease" version="1.5.2" targetFramework="net462" />
Recently because of (https://www.nuget.org/packages/BundleTransformer.MicrosoftAjax/) I added AjaxMin into my packages.config:
<package id="AjaxMin" version="5.14.5506.26202" targetFramework="net461" />
In my code, I am using IsNullOrWhiteSpace() extension method. The method actually exists in these two libraries:
Visual Studio cannot decided which one has to be used.
I cannot remove the reference to WebGrease, because if I do so, I have the following exception:
How can I solve the conflict?
Thank you
You can use string.IsNullOrWhitespace() directly.

DocumentClient.CreateDatabaseQuery - No definition exists

I'm trying to follow the azure DocumentDb quick start project. The app I will be developing will be in WPF rather than the console, so to ramp up on documentdb I created a new wpf project (.Net 4.5.1) but I get the following error:
'Microsoft.Azure.Documents.Client.DocumentClient' does not contain a definition for 'CreateDatabaseQuery' and no extension method 'CreateDatabaseQuery' accepting a first argument of type 'Microsoft.Azure.Documents.Client.DocumentClient' could be found (are you missing a using directive or an assembly reference?)
I used the following command to install the azure documentdb client:
Install-Package Microsoft.Azure.Documents.Client -Pre
This is the code that is giving me the issue (lifted straight from the quick start tutorial):
DocumentClient client = new DocumentClient(new Uri("endpoint"), "authKey");
var db = client.CreateDatabaseQuery()
.Where(d => d.Id == databaseId)
.AsEnumerable()
.FirstOrDefault();
This is the contents of my Nuget Packages.config file
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Microsoft.Azure.Documents.Client" version="0.9.1-preview" targetFramework="net451" />
<package id="Newtonsoft.Json" version="4.5.11" targetFramework="net451" />
</packages>
Anybody any ideas what I'm missing? I'm using Visual Studio 2013 Premium Update 4
I believe you are missing the using directive for the DocumentDB Linq provider (Microsoft.Azure.Documents.Linq). Please make sure you have the following directives to the top of your .cs file:
using Microsoft.Azure.Documents;
using Microsoft.Azure.Documents.Client;
using Microsoft.Azure.Documents.Linq;

Resources