17

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:\Windows\Microsoft.NET\Framework\v4.0.30319\Config\machine.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.
Ognyan Dimitrov
  • 6,026
  • 1
  • 48
  • 70
CodeCanyon
  • 929
  • 2
  • 11
  • 36
  • It looks like someone changed machine.config instead of site's web.config - find out who and ask why it was done... Otherwise make sure to carefully read information in "The following information can be helpful to determine why..." section of error message. – Alexei Levenkov Oct 04 '14 at 04:49
  • No no one changed it.Because i just created the project and tried to run it. – CodeCanyon Oct 04 '14 at 05:00
  • I'm pretty sure that it is not how one installed/created by .Net install (or Windows install, depending on version) looks like. So someone or something changed the machine.config file. If you don't care - just remove that line and it should fix *your* problem (possibly breaking something else that made the change...). – Alexei Levenkov Oct 04 '14 at 05:06
  • You mean to remove the line from web.config file? – CodeCanyon Oct 04 '14 at 05:13
  • I'm confusing why it works fine for empty project and not for internet application project. – CodeCanyon Oct 04 '14 at 05:59
  • Because one reads the element and tries to instantiate objects while other does not. – Alexei Levenkov Oct 04 '14 at 06:06
  • OK.I understood.Can you please tell me what should i do to avoid from this issue?I checked this issue on internet, but didn't found a solution. – CodeCanyon Oct 04 '14 at 06:32
  • Remove that line - you can always put it back if needed (also I don't think it should be in machine level config to start with). If not enough update your question/or ask new one with new error. – Alexei Levenkov Oct 04 '14 at 06:35
  • OK.Can you please tell me from which file i should remove this?I'm bit confused because i couldn't find this in web.config file. – CodeCanyon Oct 04 '14 at 06:37

7 Answers7

44

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.

Community
  • 1
  • 1
Ognyan Dimitrov
  • 6,026
  • 1
  • 48
  • 70
5

This solution worked for me:

<siteMap>
      <providers>
        <remove name="MySqlSiteMapProvider"/>
      </providers>
    </siteMap>

I think they forgot to put the file MySql.Web in de GAC (Global Assembly Cache)

  • If you do not correct the root of the problem, which is the snippet inserted by the installer in your machine.config you will have to copy-paste this on every solution you make on your developer machine. – Ognyan Dimitrov Nov 21 '14 at 11:05
  • For some reason, the issue only happens in some of my solutions, so this works for me in the few solutions where it is happening. Also, the section goes in the section – Eric Barr Feb 15 '19 at 22:21
4

-Open the MySQL installer
-Click the remove tab to your right.
-Check all the things that are related to .Net (like connectors)
-Click remove button
-Close and reopen visual studio
-Upvote Ognyan Dimitrov's answer

Tosh
  • 531
  • 7
  • 3
  • 1
    Unistalling .net connectors isn't really a solution when you need to use MySQL in your other projects... – walther Jan 15 '15 at 17:42
4

There is another solution: I manually opened machine.config and commented out section <Sitemap> (it's almost on the bottom of the file). Save it as the administrator and violá. It works.

Solutions using sitemaps are intact without having to touch them and my solutions where I need to use the MySQL connector work as expected as well.

walther
  • 13,466
  • 5
  • 41
  • 67
1

finally I have solved it my own and it was a small solution. Just have to add a reference to Web.Mysql dll file and now it works properly.

Harry
  • 3,031
  • 7
  • 42
  • 67
CodeCanyon
  • 929
  • 2
  • 11
  • 36
  • No an option if your project is not MySQL dependent. Every project of yours will be dependent on this assembly and whenever you use ASP.NET roles you will have to include this assembly! – Ognyan Dimitrov Oct 07 '14 at 14:33
0

I know this was asked a while ago, but what worked for me was adding the MySql.Data and MySql.Web references to my project.

Harry
  • 3,031
  • 7
  • 42
  • 67
-1

just install latest MySql .Net Connector and select 'Complete' install, it will fix your problems.

Kayhan
  • 1
  • 1