Closed tforkmann closed 5 years ago
I don't think this is an issue with SQLProvider.
If you do Sql.GetDataContext connectionString
where the connectionString is a string it should work?
So you are just missing an assembly reference to e.g. System.Web or System.Web.Hosting when using something in there in your project. SQLProvider doesn't use System.Web at all, but maybe the configuration typeprovider does.
Yes, if the connection String is a string. The typeprovider works like a charm!
Ok, I guess this is related to the configuration typeprovider.
Ok, I got rid of the configuration typeprovider and used the standard System.Configuration module instead and it just works.
Description
I'm trying to use an app.config file to get the DataContext on runtime.
But getting following error message:
Can't get DataContext. Message: The type initializer for '<StartupCode$..>.$Config' threw an exception.. InnerMessage: Could not load type 'System.Web.Hosting.HostingEnvironment' from assembly 'System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'
Repro steps
Please provide the steps required to reproduce the problem
Adding CompileTime ConnectionString
let [<Literal>] CompileTimeConnectionString = "Data Source=...."
Get SqlType:
type Sql = SqlDataProvider<Common.DatabaseProviderTypes.MSSQLSERVER, ConnectionString=CompileTimeConnectionString,UseOptionTypes=true, ContextSchemaPath = ContextSchemaPath>
Add RunTime ConnectionString to App.Config file:
Use FSharp.Configuration to receive ConnectionString from the App.Config
Try to get DataContext with RunTimeConnection String
let getDb () = SqlDme.GetDataContext connectionString
Expected behavior
Get GetDataContext without issues
Actual behavior
Assembly File Missing Error
Known workarounds
None
Related information