我正在尝试创建我的第一个.NET应用程序以连接到mysql数据并收到此错误:
The primary reference "MySql.Data, Version=6.10.8.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d, processorArchitecture=MSIL" could not be resolved because it was built against the ".NETFramework,Version=v4.5.2" framework. This is a higher version than the currently targeted framework ".NETFramework,Version=v4.5".
我不确定哪个版本适用于.NET 4.5
答案 0 :(得分:1)
原因是.NET 4.5.2取代了4.5。 4.5不知道4.5.2。 一旦安装了引用4.5.2的dll,您的4.5项目就会使用4.5.2 Framework进行编译,现在它知道4.5.2并会抱怨。请参阅此链接:
https://dev.mysql.com/doc/connectors/en/connector-net-versions.html
按此:
6.10 .Net Version required is 4.5.2 for VS 2013 / 2015 / 2017, .NET Core 1.1 for VS 2015 / 2017
6.10.5 (and later): .NET Core 2.0 for VS 2017 15.0.3 (or later)
但是7.0或8.0要求是:
7.0 is 4.5.x for VS 2013 / 2015 / 2017, .NET Core 1.1 for VS 2015 / 2017
因此,需要安装7.0或8.0 mysql版本连接器或将目标框架更改为4.5.2.。