“无法找到或加载已注册的 .Net Framework 数据提供程序”与 MySQL +网络平台
我们该如何修复这个问题?这个问题在互联网上已经被多次讨论过,但这始终是一种解决方法。始终将 MySql.data.dll 复制到您的 bin 目录中,或明确说明您想要的版本。将 DbProvderFactory for MySQL 与 ASP.NET 结合使用的“正确”方法是什么?
我希望能够在本地进行开发,而不用担心他们在服务器上安装了什么版本。就目前情况而言,如果我确实复制了自己的版本,我必须确保它是他们使用的版本。看起来很容易坏。
How do we repair this? This question has been sort of addressed many times around the internet, but it's always a workaround. Always copying the MySql.data.dll into your bin directory, or explicitly stating what version you want. What is the "proper" approach to using DbProvderFactory for MySQL with ASP.NET?
I'd like to be able to develop locally and not worry what version they have installed on the server. As it stands, if I do copy up my own version I have to make sure it's the one they use. Seems easy to break.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
类似线程上的用户注意到了此错误的另一个原因 此处 我已复制粘贴下面的用户答案,以防链接发生更改
我刚刚看到在我的情况下出现此异常的原因是 dll 和配置条目之间的版本不同。
因此,有时您实际拥有的 dll(通过 nuget 或其他方式安装)与 app.config 节点中的条目不同。如果 app.config 中没有此部分,也可以在下面找到
Windows\Microsoft.NET\Framework64\v4.0.30319\Config\machine.config 和附近的文件夹。
更改 dll 版本条目中的版本解决了该问题。
Another reason for this error was noted by a user on a similar thread here I have copy pasted the users answer below in case the link changes
I just saw that the reason of this exception in my case were the differt versions between dll and the configuration entry.
So, sometimes the dll you actually have (either installed by nuget or other way) differs from the entry in the node of the app.config. This section, if not in app.config, can be also found under
Windows\Microsoft.NET\Framework64\v4.0.30319\Config\machine.config and nearby folders.
Changing version in the entry to version of the dll solved the issue.
以下是我如何让 MySQL 连接器工作:
在 DbProviderFactories 下的 machine.config 中添加以下内容:
*请注意,版本号和 PublicKeyToken 将根据您安装的 MySQL 连接器的版本而有所不同。此示例适用于 v6.7.4.0 和 v2.0 dot net
下一个副本 %Program Files%\MySQL\MySQL Connector Net 6.7.4\Assemblies\v2.0\MySql.Data.dll
到
%Windows\程序集。
希望这对某人有帮助:)
Here how I got the MySQL connector to work:
In the machine.config under DbProviderFactories add the folliwng:
*Note the version number and PublicKeyToken will be different depending on the version of the MySQL connector you have installed. This example is for v6.7.4.0 and v2.0 dot net
Next copy %Program Files%\MySQL\MySQL Connector Net 6.7.4\Assemblies\v2.0\MySql.Data.dll
to
%Windows\assembly.
Hope this helps someone :)
另一种无需 app.config 的代码方式:(不要忘记在此代码中设置正确的 MySql.Data 版本)
Another way through code without app.config: (don't forget to set the right MySql.Data version in this code)
如果相关程序集不在 GAC 中,则它必须存在于路径(即 bin 文件夹)中。必须在 GAC 大会上签字。我猜测 MySql.data.dll 的构建者没有签署该 dll,因此您可能无法将其放入服务器上的 GAC 中。因此,复制 dll 是您的解决方案。
If the assembly in question is not in the GAC, then it does have to exist in the path, i.e. the bin folder. The be in the GAC, the assembly has to be signed. I'm guessing the the builders of MySql.data.dll did not sign the dll so you may not be able to put it into the GAC on the server. So copying the dll is your solution.