ASP.NET MVC 4 and MySQL Posted by Mischa S.

Back

Date: September 27, 2012

Installed the relatively new MVC 4 ASP.NET Framework today to try and mess around a bit and see what I could learn.  Lots of nice new tools/toys in the new framework, including asyncronous controller calls!  I first had to upate my client to Service Pack 1...yeah, I know, woefully out of date.  Meh'.  I installed MVC 4 view the web platform installer, created a new project and immediately ran it.  ERROR!!!!!!!!!!!!!!!

WTF.  Seriously?  I didn't even make any customizations.  Just new project -> F5.

Here's my error:

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, Version=6.3.7.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d' or one of its dependencies. The system cannot find the file specified.

Source Error: 


Line 241:      <providers>
Line 242:        <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 243:        <add name="MySQLMembershipProvider" type="MySql.Web.Security.MySQLMembershipProvider, MySql.Web, Version=6.3.7.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 244:      </providers>
Line 245:    </membership>

Source File: C:\Windows\Microsoft.NET\Framework\v4.0.30319\Config\machine.config    Line: 243 

Assembly Load Trace: The following information can be helpful to determine why the assembly 'MySql.Web, Version=6.3.7.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d' could not be loaded.


=== Pre-bind state information ===
LOG: User = PCS\msuemnig
LOG: DisplayName = MySql.Web, Version=6.3.7.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d
 (Fully-specified)
LOG: Appbase = file:///c:/users/msuemnig.pcs/documents/visual studio 2010/Projects/Ebuy.Website/Ebuy.Website/
LOG: Initial PrivatePath = c:\users\msuemnig.pcs\documents\visual studio 2010\Projects\Ebuy.Website\Ebuy.Website\bin
Calling assembly : (Unknown).
===
LOG: This bind starts in default load context.
LOG: Using application configuration file: c:\users\msuemnig.pcs\documents\visual studio 2010\Projects\Ebuy.Website\Ebuy.Website\web.config
LOG: Using host configuration file: 
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework\v4.0.30319\config\machine.config.
LOG: Post-policy reference: MySql.Web, Version=6.3.7.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d
LOG: Attempting download of new URL file:///C:/Windows/Microsoft.NET/Framework/v4.0.30319/Temporary ASP.NET Files/root/c7abd7e0/bc40d4d4/MySql.Web.DLL.
LOG: Attempting download of new URL file:///C:/Windows/Microsoft.NET/Framework/v4.0.30319/Temporary ASP.NET Files/root/c7abd7e0/bc40d4d4/MySql.Web/MySql.Web.DLL.
LOG: Attempting download of new URL file:///c:/users/msuemnig.pcs/documents/visual studio 2010/Projects/Ebuy.Website/Ebuy.Website/bin/MySql.Web.DLL.
LOG: Attempting download of new URL file:///c:/users/msuemnig.pcs/documents/visual studio 2010/Projects/Ebuy.Website/Ebuy.Website/bin/MySql.Web/MySql.Web.DLL.
LOG: Attempting download of new URL file:///C:/Windows/Microsoft.NET/Framework/v4.0.30319/Temporary ASP.NET Files/root/c7abd7e0/bc40d4d4/MySql.Web.EXE.
LOG: Attempting download of new URL file:///C:/Windows/Microsoft.NET/Framework/v4.0.30319/Temporary ASP.NET Files/root/c7abd7e0/bc40d4d4/MySql.Web/MySql.Web.EXE.
LOG: Attempting download of new URL file:///c:/users/msuemnig.pcs/documents/visual studio 2010/Projects/Ebuy.Website/Ebuy.Website/bin/MySql.Web.EXE.
LOG: Attempting download of new URL file:///c:/users/msuemnig.pcs/documents/visual studio 2010/Projects/Ebuy.Website/Ebuy.Website/bin/MySql.Web/MySql.Web.EXE.

Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.272

OK.  So, apparently, because I have MySQL running on my station, MVC assumed I had the dlls and exes in my 4.0 framework, which naturally, I do not.  I did a little Googl(e)ing and found quickly, that this doesn't seem like an issue for anyone else.  Or, at least I couldn't find the right set of keywords to recreate it.

To resolve it, I opened my machine.config (path listed above) and removed the 3 lines (line numbers: 243,249,256) that reference MySQL and it worked fine.

Possibly could've resolved this by updating MySQL...but, I don't want to use MySQL with any .NET apps that I forsee building in the future, so, I'm calling this good enough.