Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
141 views
in Technique[技术] by (71.8m points)

c# - ASP.Net MVC4 configuration error after installing MySQL Connector .NET

I'm creating a MVC4 web application project.When i'm using empty project and simply run it on browser it works fine.But the problem is when i'm trying to create a Internet application project instead of Empty project.Once i created internet application project and when trying to run it on browser it shows following configuration error.As i understood it's something related to MySQL connector assembly reference.Anyhow following is the error.

Server Error in '/' Application.

Configuration Error

Description: An error occurred during the processing of a configuration file required to service    this request. Please review the specific error details below and modify your configuration file appropriately. 

Parser Error Message: Could not load file or assembly 'MySql.Web.v20, Version=6.9.4.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d' or one of its dependencies. The system cannot find the file specified.

Source Error: 


Line 265:      <providers>
Line 266:        <add name="AspNetSqlMembershipProvider" type="System.Web.Security.SqlMembershipProvider, System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" connectionStringName="LocalSqlServer" enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="true" applicationName="/" requiresUniqueEmail="false" passwordFormat="Hashed" maxInvalidPasswordAttempts="5" minRequiredPasswordLength="7" minRequiredNonalphanumericCharacters="1" passwordAttemptWindow="10" passwordStrengthRegularExpression=""/>
Line 267:        <add name="MySQLMembershipProvider" type="MySql.Web.Security.MySQLMembershipProvider, MySql.Web.v20, Version=6.9.4.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d" connectionStringName="LocalMySqlServer" enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="true" applicationName="/" requiresUniqueEmail="false" passwordFormat="Clear" maxInvalidPasswordAttempts="5" minRequiredPasswordLength="7" minRequiredNonalphanumericCharacters="1" passwordAttemptWindow="10" passwordStrengthRegularExpression=""/>
Line 268:      </providers>
Line 269:    </membership>

Source File: C:WindowsMicrosoft.NETFrameworkv4.0.30319Configmachine.config    Line: 267 

Assembly Load Trace: The following information can be helpful to determine why the assembly 'MySql.Web.v20, Version=6.9.4.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d' could not be loaded.
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

This nasty error occurs when you install MySQL .NET Connector 6.9.4 (probably other versions too) because if you do not uncheck "Web Providers" during the installation it writes in your machine.config which brings you to this error. Be sure to read the entire answer before applying any of these steps in order to start from where you have to start.

The real problem with other suggestions is that if you are not using MySQL in every project to just add a reference to MySQL dll to mitigate the problem in every project is not an option. Every project of yours that uses ASP.NET will require it because of the rows added in machine config by the installer!

To solve the problem properly :

  1. Start the installer and click "Change"
  2. then remove the "Web Providers" section entirely.
  3. This will remove the declarations from your machine.config (which I find a horrible thing to do in installer but the installer creates them without any notification anyway).
  4. After that it is a good idea to check you machine config which you can find here. And be sure that it did not spoil both 32 and 64 machine configs.
  5. When your machine config is clear add the MySql.Web assembly to your project and add the MySQLMembershipProvider declaration in your project web.config - the standard procedure.
  6. Enjoy the clean installation of MySQL connector.

But if you do it that way you may try to add Ado NET Entity Data model after, right? If that is the case it is most likely that you do not see the option for MySQL as an available data source in the wizard. This is because from version 6.7 when you install MySQL Connector .NET it will no longer register as DDEX provider automatically.

To correct this issue you have to download a separate installer provided especially for MySQL and .NET from here or the just Visual Studio integration plug-in directly from here.

Be sure to check the Visual Studio integration and connector during the installation wizard on either of the above installers.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...