I'm trying to connect to a test database I created for far too long and I finally decided to come for help. I am using F#, Visual Studio Community 2017 and MySQL Database. The server is local (Wamp).
I have this for now:
#r "\...\packages\SQLProvider.1.1.8\lib\FSharp.Data.SqlProvider.dll"
open FSharp.Data.Sql
open FSharp.Data.Sql.Providers
open System.Collections.Generic
open System
[<Literal>]
let connString = "Server=localhost; Database=test1; Uid=root"
let resPath = __SOURCE_DIRECTORY__ + @"..\packages\MySql.Data.8.0.8-dmr\lib\net452"
type sql = SqlDataProvider<
Common.DatabaseProviderTypes.MYSQL,
connString,
ResolutionPath = resPath,
UseOptionTypes = true>
let db = sql.GetDataContext()
And I can't make it work.. 'resPath' gives the error "This is not a valid constant expression or custom attribute value". If I insert a literal '[]' in front of it (see it below), it gives another error: "Strong name validation failed. (Exception from HRESULT: 0x8013141A)".
let [<Literal>] resPath = __SOURCE_DIRECTORY__ + @"..\packages\MySql.Data.8.0.8-dmr\lib\net452"
After connection with the db I want to add information in it and analyze the data of it using F# still.
I don't know what else should I try. All packages are updated, I installed everything through the NuGet package manager and they are all in the references.. I appreciate any ideas / suggestions.
Thank a lot.
SqlDataProvider
is a type provider, which means that it contains code that runs at compile time so that it can generate types for you to use at compile time. All parameters to type providers have to be constants that are known at compile time. This is why resPath
needs to be a "literal" (effectively the same thing as a compile time constant).
__SOURCE_DIRECTORY__
doesn't have a trailing backslash so you need to add that:
let [<Literal>] resPath = __SOURCE_DIRECTORY__ + @"\..\packages\MySql.Data.8.0.8-dmr\lib\net452"
With this in place I was able to reproduce your Strong name validation failed
error. Switching to v6.9.9 (marked as the current version) of MySql.Data fixed that for me.
User contributions licensed under CC BY-SA 3.0