SQLProvider icon indicating copy to clipboard operation
SQLProvider copied to clipboard

... Unable to load one or more of the requested types ...

Open travis-leith opened this issue 5 years ago • 4 comments
trafficstars

Description

I am trying to get a basic demo working against MariaDB10 using MySqlConnector but can't get it to compile. The advice given in this related issue doesn't seem to help.

Repro steps

Create a project with the following code

open FSharp.Data.Sql

[<Literal>]
let connString  = "Server=***;Database=market_data;Uid=***;Pwd=***;Port=3307;AllowLoadLocalInfile=true"

[<Literal>]
let dbVendor    = Common.DatabaseProviderTypes.MYSQL


[<Literal>]
let connString2 = @"Server=DESKTOP-7N1E2PV;Database=factor_investments;User Id=Travis;Password=welcome123;"

[<Literal>]
let resPath = __SOURCE_DIRECTORY__ + "/DLLs"

[<Literal>]
let useOptTypes = true

type sql = 
    SqlDataProvider<
        Common.DatabaseProviderTypes.MYSQL,
        connString,
        ResolutionPath = resPath,
        UseOptionTypes = useOptTypes>

//let ctx = sql.GetDataContext()

[<EntryPoint>]
let main argv =
    printfn "Hello World from F#!"
    0 // return an integer exit code

and the following libraries

<ItemGroup>
    <PackageReference Include="MySqlConnector" Version="0.61.0" />
    <PackageReference Include="SQLProvider" Version="1.1.76" />
    <PackageReference Include="System.Console" Version="4.3.1" />
    <PackageReference Include="System.Data.Common" Version="4.3.0" />
    <PackageReference Include="System.Reflection" Version="4.3.0" />
    <PackageReference Include="System.Reflection.TypeExtensions" Version="4.7.0" />
    <PackageReference Include="System.Runtime" Version="4.3.1" />
    <PackageReference Include="System.Runtime.Extensions" Version="4.3.1" />
    <PackageReference Include="System.Runtime.Serialization.Formatters" Version="4.3.0" />
    <PackageReference Include="System.Threading.Tasks.Extensions" Version="4.5.3" />
  </ItemGroup>

Place the MySqlConnector.dll in the 'DLLs' folder and try to build.

Expected behavior

Successful build

Actual behavior

The following compile error is given

Severity	Code	Description	Project	File	Line	Suppression State
Error	FS3033	The type provider 'FSharp.Data.Sql.SqlTypeProvider' reported an error: Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information.
Details: 
Could not load type 'System.ICloneable' from assembly 'System.Runtime, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'.
Could not load type 'System.Data.Common.DbCommandBuilder' from assembly 'System.Data.Common, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'.
Could not load type 'System.Data.Common.DbDataAdapter' from assembly 'System.Data.Common, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'.
Could not load type 'System.Data.Common.RowUpdatingEventArgs' from assembly 'System.Data.Common, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'.
Could not load type 'System.Data.Common.RowUpdatedEventArgs' from assembly 'System.Data.Common, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'.
Could not load file or assembly 'System.Runtime.Extensions, Version=4.2.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.
Could not load file or assembly 'System.Net.Primitives, Version=4.1.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.
Could not load type 'System.ReadOnlyMemory`1' from assembly 'System.Runtime, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'.
Could not load type 'System.IO.Stream' from assembly 'System.Runtime, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'.
Could not load type 'System.ReadOnlySpan`1' from assembly 'System.Runtime, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'.
Could not load file or assembly 'System.Memory, Version=4.2.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51' or one of its dependencies. The system cannot find the file specified.
Could not load file or assembly 'System.Transactions.Local, Version=4.0.1.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51' or one of its dependencies. The system cannot find the file specified.
Could not load type 'System.Runtime.CompilerServices.IAsyncStateMachine' from assembly 'System.Runtime, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'.
Could not load type 'System.Memory`1' from assembly 'System.Runtime, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'.	Analytics	xxx\Program.fs	20	Active

Related information

  • MariaDb
  • Windows 10
  • .NET Core 3.1

travis-leith avatar Jan 28 '20 06:01 travis-leith

I think with type providers you should use compiletime the full .NET framework dll and runtime the Core dll.

Thorium avatar Jan 28 '20 14:01 Thorium

See: https://github.com/fsprojects/SQLProvider/tree/master/tests/SqlProvider.Core.Tests/MySql

Thorium avatar Jan 28 '20 14:01 Thorium

@Thorium the instructions given in your link almost worked; they were able to remove errors visible in VS, but upon building I get the following error The type provider 'FSharp.Data.Sql.SqlTypeProvider' reported an error: Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information.Details: Could not load file or assembly 'System.Memory, Version=4.0.1.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51' or one of its dependencies. The system cannot find the file specified.Could not load file or assembly 'System.Threading.Tasks.Extensions,...

So I added the package System.Memory and copied the dll to the libraries folder, then upon building I get

The type provider 'FSharp.Data.Sql.SqlTypeProvider' reported an error: Could not load file or assembly 'System.Runtime.CompilerServices.Unsafe,...

I have tried adding the packing System.Runtime.CompilerServices.Unsafe and copying the dll but no change in error.

Also, the test project in this repo does not work for me. Trying to build results in

Severity	Code	Description	Project	File	Line	Suppression State
Error	FS3033	The type provider 'FSharp.Data.Sql.SqlTypeProvider' reported an error: Exception has been thrown by the target of an invocation.	SqlProvider.Core.Tests	C:\repos\New folder\SQLProvider\tests\SqlProvider.Core.Tests\MySql\Program.fs	30	Active

travis-leith avatar Jan 29 '20 08:01 travis-leith

Hi, I upgraded few system references, to SQLProvider 1.1.79, hope that helped.

Thorium avatar Feb 04 '20 15:02 Thorium

This is fixed

Thorium avatar Nov 17 '23 08:11 Thorium