Azure Function App using SQLite M1 Macbook - Unable to load shared library 'e_sqlite3' or one of its dependencies - sqlite

Running MacOS Monterey version 12.1
IDE Jetbrains Rider version 2021.3.2
Using Microsoft EF Core version 6.0.1 on Macbook Pro M1. Trying to save to the database using EF Core but getting the following error message back.
It's an Azure Functions App that I am running locally and attempting to connect locally.
I've got Migrations working through EntityFramework but just cannot see to get the dbContext to connect to the DB when a function is called through the app.
'System.DllNotFoundException: Unable to load shared library 'e_sqlite3' or one of its dependencies. In order to help diagnose loading problems, consider setting the DYLD_PRINT_LIBRARIES environment variable: dlopen(libe_sqlite3, 0x0001): tried: 'libe_sqlite3' (no such file), '/usr/local/lib/libe_sqlite3' (no such file), '/usr/lib/libe_sqlite3' (no such file), '/Users/<name>/RiderProjects/API/project.API.Admin/bin/Debug/net6.0/libe_sqlite3' (no such file), '/usr/local/lib/libe_sqlite3' (no such file), '/usr/lib/libe_sqlite3' (no such file)'
I've tried installing 'SQLitePCLRaw.bundle_e_sqlite3 2.0.8-pre20220111224339' package but I still get the same problem.
Here is my CSPROJ file
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<AzureFunctionsVersion>V4</AzureFunctionsVersion>
<LangVersion>preview</LangVersion>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Azure.Functions.Extensions" Version="1.1.0" />
<PackageReference Include="Microsoft.Azure.WebJobs.Extensions.OpenApi" Version="1.0.0" />
<PackageReference Include="Microsoft.NET.Sdk.Functions" Version="4.0.1" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="6.0.0" />
</ItemGroup>
<ItemGroup>
<None Update="host.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="local.settings.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<CopyToPublishDirectory>Never</CopyToPublishDirectory>
</None>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\iAi.Services\iAi.Services.csproj" />
</ItemGroup>
</Project>
Any help on how to get SQLite working on Mac using EntityFramework and .NET 6 is greatly appreciated.

Try to add Nuget package SQLitePCLRaw.bundle_e_sqlite3 2.0.7

Related

Upgrade my Azure Function from .net Core 3.1 to .net Core 7.0. Error "'Could not load file or assembly 'Microsoft.Extensions.Configuration.Abstraction

I have an Azure Function which run on .net core 3.1, but when i change the .net version from 3.1 to 7 i got this error:-
System.IO.FileNotFoundException: 'Could not load file or assembly 'Microsoft.Extensions.Configuration.Abstractions, Version=7.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'. The system cannot find the file specified.'
here is a screen shot:-
here is my csproj file:-
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<AzureFunctionsVersion>v4</AzureFunctionsVersion>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.ApplicationInsights.WorkerService" Version="2.15.0" />
<PackageReference Include="Microsoft.Azure.Functions.Extensions" Version="1.1.0" />
<PackageReference Include="Microsoft.NET.Sdk.Functions" Version="3.0.11" />
<PackageReference Include="PnP.Core.Auth" Version="1.8.0" />
</ItemGroup>
<ItemGroup>
<None Update="host.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="local.settings.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<CopyToPublishDirectory>Never</CopyToPublishDirectory>
</None>
</ItemGroup>
</Project>
Any advice on this please?
I have installed Install-Package Microsoft.Extensions.Configuration.Abstractions -Version 7.0.0 but this did not fix the issue either.
.NET 3.1 is in-process and .NET 7 is Isolated Worker Process type.
I can see your .csproj file code given in the question that you changed only .NET Framework and Azure Functions Version which is not complete configuration code for .NET 7 Isolated Process Azure Function and also you're missing few Function Worker package references in the .csproj file code.
Basic/Default .NET 7 Isolated Azure Functions Project contains the below code in .csproj file:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<AzureFunctionsVersion>v4</AzureFunctionsVersion>
<OutputType>Exe</OutputType>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Azure.Functions.Worker" Version="1.8.0" />
<PackageReference Include="Microsoft.Azure.Functions.Worker.Sdk" Version="1.7.0" />
<PackageReference Include="Microsoft.Azure.WebJobs.Extensions.Http" Version="3.2.0" />
<PackageReference Include="Microsoft.Extensions.Http" Version="7.0.0" />
</ItemGroup>
<ItemGroup>
<None Update="host.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="local.settings.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<CopyToPublishDirectory>Never</CopyToPublishDirectory>
</None>
</ItemGroup>
<ItemGroup>
<Using Include="System.Threading.ExecutionContext" Alias="ExecutionContext" />
</ItemGroup>
</Project>
.NET 7 In-Process is not yet released and to convert from .NET 3.1 (In-Process Model) to .NET 7 (Isolated Worker Process), you need to write the .NET 7 Isolated Compatible NuGet Packages, code changes in the Function Code, program.cs file, etc.,
Refer to this MS Doc for Migration Steps & Checks of Azure Functions V3 to V4 and One of the my answers SO #74428448 states the update of the supported available version in Azure Functions C#.

Error scaffolding identity in blazor webassembly app

I am building a webassembly project in Razor using Visual Studio 2019 (version 16.9.4) and whenever I try to scaffold the identity I get an error saying that a package restore did not work, and everything is rolled back.
My question is twofold:
How do I solve this error?
Are there any alternatives to the scaffolding of the identity?
Grtz,
Iede Snoek
There is an offical page about this but I found it a little confusing. The Blazor WebAssembly UI is not supported, that makes sense. But the Hosted variation should be just like a Blazor Server project. I think that is what is being said there and that makes sense.
But whewn I gave it a try I got the same error as you did, with packages getting rolled back. And no info on what packages.
So I gave Blazor Server a go, and I kept a watch on the changes. The scaffolding worked and it downgraded some packages from 5.0.5 to 5.0.4 .
After editing the MyProject.Server.csproj the same way scaffolding worked like a charm. The "Manage Packages" UI did not work and I did have to Clean the solution first.
The altered parts of my csproj file:
<Project Sdk="Microsoft.NET.Sdk.Web">
...
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.Server"
Version="5.0.4" />
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design"
Version="5.0.2" />
</ItemGroup>
<ItemGroup>
...
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore"
Version="5.0.5" />
<PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore"
Version="5.0.4" />
<PackageReference Include="Microsoft.AspNetCore.Identity.UI"
Version="5.0.4" />
<PackageReference Include="Microsoft.AspNetCore.ApiAuthorization.IdentityServer"
Version="5.0.4" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer"
Version="5.0.4" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools"
Version="5.0.4">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
</ItemGroup>
</Project>
The small version steps make me think this is a very temporary problem.

Process creation failed with error: Access is denied when starting project in debug mode

I have an ASP.NET Core project targeting net4.6.1
The following error is thrown every time I try to start the project with debugging, from both VS2017 and command line using dotnet run.
The csproj is the following:
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net461</TargetFramework>
<Platforms>x64</Platforms>
<AspNetCoreHostingModel>OutOfProcess</AspNetCoreHostingModel>
<AspNetCoreModuleName>AspNetCoreModule</AspNetCoreModuleName>
<StartupObject></StartupObject>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore" Version="2.2.0" />
<PackageReference Include="Microsoft.AspNetCore.HttpsPolicy" Version="2.2.0" />
<PackageReference Include="Microsoft.AspNetCore.Mvc" Version="2.2.0" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\pathToAnotherProject\myproject.csproj" />
</ItemGroup>
</Project>
I can mention that I have a single startup project created as an ASP.NET Core project and multiple .net core class library projects targeting net461.
Any idea where the problem comes from?
Have you tried to enable 'use managed compatibility mode' in the debugging>general section of VS2017 options.

Create a Nuget package without adding that dependency to the current project?

Using .NET Core, I'm trying to create a new Nuget without it installing the it's own dependencies.
This is my new NuGet package csproj:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup Label="Globals">
<TargetFrameworks>net461</TargetFrameworks>
<PackageId>MyFirstNuget</PackageId>
<Version>1.0.1-prerelease</Version>
<Authors></Authors>
<Company></Company>
<Description></Description>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<SccLocalPath>.</SccLocalPath>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="SomePackage" Version="7.12.4" />
</ItemGroup>
</Project>
When I install the package on a project it installs the package "SomePackage"
Is there an option not to install all the dependencies?
When working with PackageReference there are some ways to control dependency assets.
As stated here:
IncludeAssets: These assets will be consumed
ExcludeAssets: These assets will not be consumed
PrivateAssets: These assets will be consumed but won't flow to the parent project
In your case you need to use PrivateAssets like this:
<ItemGroup>
<PackageReference Include="SomePackage" Version="7.12.4">
<PrivateAssets>all</PrivateAssets>
</PackageReference>
</ItemGroup>
since your project uses SomePackage, but you don't want SomePackage installed when you use your new NuGet package.
I think PrivateAssets can help you. Try changing your PackageReference to
<PackageReference Include="UmbracoCms" Version="7.12.4">
<PrivateAssets>all</PrivateAssets>
</PackageReference>

newtonsoft.json 9.0.1 not compatible with netcoreapp1.1 in newly created Visual Studio Project

I created a new ASP.NET Core Web Application in Visual Studio 2017 and immediately got the following error:
Restoring NuGet packages...
Package Newtonsoft.Json 9.0.1 is not compatible with netcoreapp1.1 (.NETCoreApp,Version=v1.1). Package Newtonsoft.Json 9.0.1 supports:
- net20 (.NETFramework,Version=v2.0)
- net35 (.NETFramework,Version=v3.5)
- net40 (.NETFramework,Version=v4.0)
- net45 (.NETFramework,Version=v4.5)
- netstandard1.0 (.NETStandard,Version=v1.0)
- portable-net40+sl5+win8+wp8+wpa81 (.NETPortable,Version=v0.0,Profile=Profile328)
- portable-net45+win8+wp8+wpa81 (.NETPortable,Version=v0.0,Profile=Profile259)
One or more packages are incompatible with .NETCoreApp,Version=v1.1.
NuGet package restore failed.
It seems that Newtonsoft.Json is not compatible with netcoreapp, but why would VisualStudio include it if that is the case? I'm pretty new to ASP.NET so maybe there is something I am missing? I followed the steps from the ASP.NET Core Docs.
While searching I found some similar issues, but none seem to be compatible with VS 2017.
Also here is my .csproj file if it helps:
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>netcoreapp1.1</TargetFramework>
</PropertyGroup>
<PropertyGroup>
<PackageTargetFallback>$(PackageTargetFallback);portable-net45+win8+wp8+wpa81;</PackageTargetFallback>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.ApplicationInsights.AspNetCore" Version="2.0.0" />
<PackageReference Include="Microsoft.AspNetCore" Version="1.1.1" />
<PackageReference Include="Microsoft.AspNetCore.Mvc" Version="1.1.2" />
<PackageReference Include="Microsoft.AspNetCore.StaticFiles" Version="1.1.1" />
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="1.1.1" />
<PackageReference Include="Microsoft.VisualStudio.Web.BrowserLink" Version="1.1.0" />
</ItemGroup>
<ItemGroup>
<DotNetCliToolReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Tools" Version="1.0.0" />
</ItemGroup>
</Project>
Ok, I just reinstalled Visual Studio, repaired it from the installer and cleared the NuGet Cache and now it's working. Seems like something wasn't setup correctly.

Resources