This article is a mirror article of machine translation, please click here to jump to the original article.

View: 19035|Reply: 0

[Solved] . .NET MySQL Connector Conflicts DbProviderFactories (.NET MySQL Connector Conflicts DbP...

[Copy link]
Posted on 2020-11-11 09:11:52 | | |
This post was last edited by QWERTYU on 2020-11-11 09:14

Scenario:
Open a .NET project using the mysql database and install it in the local development environment.NET MySQL connector, everything is working fine, but when it is released to iis, the program is abnormal and the error message is as follows:
Exception information:
System.Data.Entity.Infrastructure.DependencyResolution.DefaultProviderFactoryResolver. <GetService>b__0---> exception information: The ADO.NET provider with the fixed name "MySql.Data.MySqlClient" is not registered in the computer or application profile or cannot be loaded. For more information, see Internal Exceptions.
InnerException:System.ArgumentException: 找不到请求的 .Net Framework Data Provider。可能没有安装。
Find the problem:
Found that the server is not installed.NET MySQL connector, because mysql uses Alibaba Cloud's cloud database, there are also multiple servers, in order to avoid installation on each server.NET MySQL connector,To do this, I made sure to set the MySQL references to "local copy" so that I could copy them to the bin folder and add the following to my app.config:
After adding the above configuration, it works fine on the server and I can deploy the application without installing the MySQL connector on the server, but now I have a problem on my local dev machine (with the MySQL connector installed) and I get this error when I try EF connection:
Exception information:
System.Data.Entity.Infrastructure.DependencyResolution.DefaultProviderFactoryResolver. <GetService>b__0---> exception information: The ADO.NET provider with the fixed name "MySql.Data.MySqlClient" is not registered in the computer or application profile or cannot be loaded. For more information, see Internal Exceptions.
InnerException:System.ArgumentException: 找不到请求的 .Net Framework Data Provider。可能没有安装。
Try the action:
If I comment out the XML added above in the config, the error goes away. This may be because the same driver is installed on the system and is located in machine.config.
The final solution and why:
Try adding <remove invariant="MySql.Data.MySqlClient" /> in your webconfig. On your machine, you already have the MySql connector installed, and you modify your machine.config by adding one in DbProviderFactories. So if you put another MySql data provider in your web.config, it's as if you tried to register the same thing twice.











Previous:C# puts reference library DLLs into subfolders via probing
Next:ASP.NET Core Link Tracing (3) SkyAPM is based on Consul dynamic configuration
Disclaimer:
All software, programming materials or articles published by Code Farmer Network are only for learning and research purposes; The above content shall not be used for commercial or illegal purposes, otherwise, users shall bear all consequences. The information on this site comes from the Internet, and copyright disputes have nothing to do with this site. You must completely delete the above content from your computer within 24 hours of downloading. If you like the program, please support genuine software, purchase registration, and get better genuine services. If there is any infringement, please contact us by email.

Mail To:help@itsvse.com