-
Notifications
You must be signed in to change notification settings - Fork 146
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Could not load file or assembly 'Microsoft.Extensions.Logging.Abstractions, Version=8.0.0.0 #808
Comments
Is this duplicate of #807 ? |
seems like, see i was able to open Microsoft.Extensions.Logging.Abstractions above at the top |
This should help: #807 (comment) |
i read the above, do you suggest to add System.Text.Json ? dont you think it makes sense to move this whole solution to NET6+ (or NET8+) why support older targets? we are soon in NET9, supporting netstandard is not needed anymore since NET5+ ... maybe removing netstandard makes all deps behave consistently for NET6+ versions (would honestly do NET8+ as its latest LTS) found this but seems like a windows test, trying to see if i mistook anything... |
If you use the latest Postgres drivers, yes, you need that. Either to ResolutionPath or as direct reference to your project.
The comment had a working zip-file as example. That is not updated to the test-samples: All these DB drivers change so often that it's hard to keep the samples up-to-date. But I'm accepting PRs if anyone wants to update the samples in the solution.
It seems most of the type-providers target .NET Standard 2.0 and .NET Standard 2.1. Besides of that, SQLProvider is used by some enterprises (like US Navy, I've heard) and many large enterprises still use the legacy .NET Framework, which has Microsoft guaranteed support longer than any of the new existing .NET. So I'm not seeing to break the backward-compatibility any time soon. |
thanks, trying to update this branch of an old project/showcase here, and got a bit stuck |
still not working with above suggestions, i add the zip here if interested (based on linked script) / macos gives an error in see REPRO folder here > |
tried this script, but i notice on MAC i cannot find that Microsoft.Bcl even after adding the library in my project? <ItemGroup>
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="8.0.0" />
<PackageReference Include="Npgsql" Version="8.0.1" />
<PackageReference Include="SQLProvider" Version="1.3.23" />
<PackageReference Include="System.Text.Json" Version="8.0.1" />
<PackageReference Include="Microsoft.Bcl.AsyncInterfaces" Version="8.0.0" />
</ItemGroup> |
The ReferencePath you probably need .NET Standard 2.0 version of the library and not the .NET8 version, because your VSCode is likely not running on .NET8 yet! Don't worry, the ReferencePath is just for the IDE and compiler, it's not the executable runtime code. So if you target for the .NET8 then the .NET8 libraries should go to the bin-folder (as they go if they are references in the project), but the ReferencePath you need different versions. |
cannot make it work i tried copying only netstandard2.0 libs as well... |
I was testing your .fsx with my Mac and a few notes:
#r "nuget:Npgsql"
#r "nuget:SQLProvider"
#r "nuget:System.Threading.Channels"
#r "nuget:Microsoft.Bcl.AsyncInterfaces"
#r "nuget:System.Memory.Data"
#r "nuget:Microsoft.Extensions.Logging.Abstractions"
#r "nuget:System.Text.Json"
#r "nuget:System.Diagnostics.DiagnosticSource" Edit: My Mac doesn't have PostgreSql installed but executing the FSX in FSI got as far as "couldn't connect to localhost" |
I was thinking if this is an alternative workaround: add the following entry in your Nuget.config and try to build your solution just once:
(And of course use paths starting with |
sorry if i havent replied earlier, i will follow up and test again, thanks for takng this time! @Thorium @knocte , In general yes would be much better if this package could all somehow work normally also for beginners is not very easy to use this package correctly, maybe ease of use can be improved with some brainstorming with other F# devs.. maybe is possible to do >multitarget builds/publish packages, and also build for NET8 with simplified dependencies? |
I'm all for that! Especially considering that because of this kind of issues with SqlProvider, my teammates have already been researching for alternatives. But IMO rewriting our data layer is a bigger effort than fixing the root cause of these issues in SqlProvider repo itself. Let's work together to iron this out.
Good question for Thorium, do we want a SqlProvider nuget package that targets more than one framework version? |
You want to target .NetStandard 2.0 and 2.1 otherwise the TypeProvider will not work. But separating multiple packages having different databases (SQLProvider.Oracle and so on) could be possibility, then you could easier keep proper driver dependencies. But I'd still keep the current one too, as the dynamic loading with whatever versions is beneficial on some cases. |
@Thorium still get error, the error mention connection but right below mention Microsoft.Extensions.Logging.Abstractions ,in my case i have pgsql running locally from docker and connection works perfectly fine, so the problem is def not connection would you mind trying run DOCKER desktop with PGSQL in it? here tested connection works fine still looks like an assembly issue to me, connection seems fine... here full .fsx script #r "nuget:Npgsql"
#r "nuget:SQLProvider"
#r "nuget:System.Threading.Channels"
#r "nuget:Microsoft.Bcl.AsyncInterfaces"
#r "nuget:System.Memory.Data"
#r "nuget:Microsoft.Extensions.Logging.Abstractions"
#r "nuget:System.Text.Json"
#r "nuget:System.Diagnostics.DiagnosticSource"
open System
open FSharp.Data.Sql
open Npgsql
[<AutoOpen>]
module Settings =
[<Literal>]
let resPath =
"""
~/.nuget/packages/npgsql/8.0.2/lib/netstandard2.0;
~/.nuget/packages/system.text.json/8.0.0/lib/netstandard2.0;
~/.nuget/packages/system.threading.channels/8.0.0/lib/netstandard2.0;
~/.nuget/packages/microsoft.bcl.asyncinterfaces/8.0.0/lib/netstandard2.0;
~/.nuget/packages/microsoft.extensions.logging.abstractions/8.0.0/lib/netstandard2.0;
~/.nuget/packages/system.memory.data/8.0.0/lib/netstandard2.0;
~/.nuget/packages/system.diagnostics.diagnosticsource/8.0.0/lib/netstandard2.0
"""
// [<Literal>]
// let resolutionPath = __SOURCE_DIRECTORY__ + "/libraries"
[<Literal>]
let connStr = "Host=localhost;Username=postgres;Password=postgres;Database=postgres"
module TestConnectionString =
let test () =
let conn = new Npgsql.NpgsqlConnection(connStr)
conn.Open()
let command = new Npgsql.NpgsqlCommand("select 100;", conn);
command.ExecuteScalar() :?> int
TestConnectionString.test()
printfn $"{resPath}"
type HR =
SqlDataProvider<
Common.DatabaseProviderTypes.POSTGRESQL,
connStr,
ResolutionPath=resPath,
Owner="public">
[<EntryPoint>]
let main arg =
let ctx = HR.GetDataContext()
let employeesFirstName =
query {
for emp in ctx.Public.Employees do
select emp.FirstName
}
|> Seq.head
printfn "Hello %s!" employeesFirstName
0 // return an integer exit code |
Uhmm, there was no .Trim() of these paths when using |
i added the missing dependencies, still does not load
reloaded multiple times, error is still on logging abstractions, not dependency injection or buffer or memory deps: https://www.nuget.org/packages/Microsoft.Extensions.Logging.Abstractions/ is there a way to get this right, Thank you so much for your help |
Yes I think we can improve the error message. I'll create SQLProvider 1.3.32 and hope that helps. Btw your path has system.memory/4.5.1/ where it should be system.memory/4.5.5/ |
@jkone27 were you able to test/fix both things above? |
will check again as last time wasnt able to fix actually, thanks a lot for taking this time! but no i wasn't able to fix yet : / |
I just released 1.3.36 containing another similar kind of small fix for some other database, but it's common code. so it could help here too. |
I am having the same problem with .NET 8 and Intellij Rider |
Describe the bug
The type provider 'FSharp.Data.Sql.SqlTypeProvider' reported an error: Could not create the connection, most likely this means that the connectionString is wrong. See error from Npgsql to troubleshoot: Could not load file or assembly 'Microsoft.Extensions.Logging.Abstractions, Version=8.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'. Could not find or load a specific file. (0x80131621)F# Compiler3033
To Reproduce
.net8, updating an old project to use pgsql instead of mssql
Expected behavior
i would expect it to read the connection, but seems some internal dll library load issue
Screenshots
Desktop (please complete the following information):
The text was updated successfully, but these errors were encountered: