.net core2.2 mysql [DataConnection.DefaultSettings] throw an Exception
See original GitHub issueUse .net core2.2, reference demo, use [DataConnection.DefaultSettings = new Settings();] throw an exception
Exception message:Could not load file or assembly 'System.Data.SqlClient, Version=4.5.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'
Stack trace:
{System.TypeInitializationException: The type initializer for 'LinqToDB.Data.DataConnection' threw an exception. --->
System.TypeInitializationException: The type initializer for 'LinqToDB.DataProvider.SqlServer.SqlServerTools' threw an exception. --->
System.IO.FileLoadException: Could not load file or assembly 'System.Data.SqlClient, Version=4.5.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'.
The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
Settings.cs
public class ConnectionStringSettings : IConnectionStringSettings
{
public string ConnectionString { get; set; }
public string Name { get; set; }
public string ProviderName { get; set; }
public bool IsGlobal => false;
}
public class Settings : ILinqToDBSettings
{
public IEnumerable<IDataProviderSettings> DataProviders => Enumerable.Empty<IDataProviderSettings>();
public string DefaultConfiguration => "MySql";
public string DefaultDataProvider => "MySql";
public IEnumerable<IConnectionStringSettings> ConnectionStrings
{
get
{
yield return new ConnectionStringSettings
{
Name = "MySql",
ProviderName = "MySql",
ConnectionString = "Server=xxx;Port=3306;Database=xxx;Uid=root;Pwd=xxx;charset=utf8;"
};
}
}
}
Startup.cs
DataConnection.DefaultSettings = new Settings();
Environment details
linq2db version: 2.7.0 Database Server: E.g. Windows Server 2008R2 Database Provider: E.g. MySql Operating system: E.g. Windows 10 Framework version: .NET Core 2.2
Issue Analytics
- State:
- Created 4 years ago
- Reactions:4
- Comments:5 (5 by maintainers)
Top Results From Across the Web
Opening mysql connection threw an exception in net core
Im trying to open a connection just closed to mysql, this threw a exception totally misleading: "The given key was not present in...
Read more >MySQL Connector/NET Developer Guide
This manual describes how to install and configure MySQL Connector/NET, the connector that enables .NET applications to communicate with MySQL servers, and how ......
Read more >Configuration in ASP.NET Core
Learn how to use the Configuration API to configure AppSettings in an ASP.NET Core app.
Read more >MySQL connection throwing exception : r/csharp
I had a MySQL Connection working on a different project and when i tried copying the code to a different project it would...
Read more >MySQL .NET Connection String Options
If false (the default) date columns are returned as DateTime values, and an exception is thrown for unrepresentable dates. Application Name, ApplicationName ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
We will fix dependency version by #1744 in next bugfix release. For explicit dependency removal task tracking use #1715