F# SqlDataProvider, "The type initializer for 'Main' threw an exception.'

1

I have been attempting to use the SqlProvider type provider on several different databases where I work. In Visual Studio, intellisense for these different DBs (of types MS Access, SQL Server, and an ODBC connection) all work as shown below:

Intellisense working

I've even tried it on the Northwind example database:

Northwind

It does not matter the connection I actually choose, they seem to all result in 2 exceptions when the code is actually run:

System.TypeInitializationException
  HResult=0x80131534
  Message=The type initializer for 'Main' threw an exception.
  Source=SqlProviderTest2
  StackTrace:
   at Main.main(String[] _arg1) in C:\Users\***\source\repos\SqlProviderTest2\Program.fs:line 29

Inner Exception 1:
TypeInitializationException: The type initializer for '<StartupCode$SqlProviderTest2>.$Main' threw an exception.

Inner Exception 2:
FileLoadException: Could not load file or assembly 'System.Data.OleDb, Version=4.0.1.1, Culture=neutral, PublicKeyToken=31bf3856ad364e35'. The located assembly's manifest definition does not match the assembly reference. (0x80131040)

How is it possible that the intellisense can detect the DB but not work when the program is actually run? Is there a common fix for this?

(Using Visual Studio 2019 Professional, if that makes a difference.)

sql
f#
sqlconnection
type-providers
asked on Stack Overflow Aug 3, 2020 by LSM07

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0