"System Configmachine.config with the App.config/web.config configuration node of its own application" workaround

Source: Internet
Author: User

Your app's app. config or Web. config file
C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Configmachine.config files for the system
1. Repeat the following configuration:

    <dbproviderfactories>      <Addname= "MySQL Data Provider2"invariant= "MySql.Data.MySqlClient"Description= ". Net Framework Data Provider for MySQL"type= "MySql.Data.MySqlClient.MySqlClientFactory, Mysql.data, version=6.5.4.0, Culture=neutral, publickeytoken= C5687fc88969c44d " />    </dbproviderfactories>

Will throw an exception as follows:

Exception is:configurationerrorsexception-Error creating configuration section handler for System.Data: Column "InvariantName" is constrained to be unique. Value "MySql.Data.MySqlClient" already exists

2. If both are not configured, the following exception is thrown:

Exception is:argumentexception-can ' t load dbproviderfactory for given value of ProviderType

In practice, you will encounter the following questions:

Some databases are not configured in the system's Configmachine.config file if problems are installed

      <name= "MySQL Data Provider2"  invariant= "MySql.Data.MySqlClient"  description= ". Net Framework Data Provider for MySQL"  type= " MySql.Data.MySqlClient.MySqlClientFactory, Mysql.data, version=6.5.4.0, Culture=neutral, publickeytoken= c5687fc88969c44d "/>

Due to the above uncertainties, we can configure this node in our own application's App/web.config file to cause exceptions due to duplicate configuration.

Workaround:

Add this node to your application's App/web.config file:

<remove invariant= "MySql.Data.MySqlClient"/> Node

That

  <System.Data>    <dbproviderfactories>       <Remove  invariant= "MySql.Data.MySqlClient"/>       <Addname= "MySQL Data Provider2" invariant= "MySql.Data.MySqlClient" Description= ". Net Framework Data Provider for MySQL"type= "MySql.Data.My sqlclient.mysqlclientfactory, Mysql.data, version=6.5.4.0, Culture=neutral, publickeytoken= C5687fc88969c44d " />    </dbproviderfactories>  </System.Data>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.