Membership Enable RoleManager Throw exception: Failed to load file or assembly Mysql.web

Source: Internet
Author: User
Tags throw exception

Create a new ASP. NET MVC 4 WEB application in vs2013, using the "basic" template. The forms authentication method is used by default in Web. config and the configuration of membership is added.

   <rolemanager defaultprovider= "Defaultroleprovider" enabled= "true" >      <providers>        <add name= " Defaultroleprovider "Type=" System.Web.Providers.DefaultRoleProvider, System.Web.Providers, version=1.0.0.0, Culture=neutral, publickeytoken=31bf3856ad364e35 "connectionstringname=" defaultconnection "applicationName="/"/ >      </providers>    </roleManager>

The default is no enabled property, it inherits the configuration in C:\Windows\Microsoft.NET\Framework\v4.0.30319\Config\machine.config is false. If you change to enable= "true", you will also find the <roleManager> configuration section in the Machine.config configuration file when you start up.

<roleManager>            <providers>                <add name= "AspNetSqlRoleProvider" Connectionstringname= " LocalSqlServer "Applicationname="/"type=" System.Web.Security.SqlRoleProvider, system.web, version=4.0.0.0, Culture =neutral, publickeytoken=b03f5f7f11d50a3a "/>                <add name=" AspNetWindowsTokenRoleProvider "ApplicationName = "/" type= "System.Web.Security.WindowsTokenRoleProvider, system.web, version=4.0.0.0, Culture=neutral, publickeytoken=b03f5f7f11d50a3a "/>                <add name=" Mysqlroleprovider "type=" MySql.Web.Security.MySQLRoleProvider, Mysql.web, version=6.7.4.0, Culture=neutral, publickeytoken=c5687fc88969c44d "Connectionstringname=" Localmysqlserver "applicationname="/"/>            </providers>        </rolemanager >

If you happen to also have MySQL Connector Net installed, congratulations on winning the lottery, the running site will receive the following exception:

Parser error message: Failed to load file or assembly "Mysql.web, version=6.7.4.0, Culture=neutral, publickeytoken= c5687fc88969c44d "or one of its dependencies. The system cannot find the file specified. SOURCE Error: Line 263: <add name= "AspNetSqlRoleProvider" connectionstringname= "LocalSqlServer" applicationname= "/" t Ype= "System.Web.Security.SqlRoleProvider, system.web, version=4.0.0.0, Culture=neutral, publickeytoken= b03f5f7f11d50a3a "/>  line: <add name=" AspNetWindowsTokenRoleProvider "applicationname="/"type=" System.Web.Security.WindowsTokenRoleProvider, system.web, version=4.0.0.0, Culture=neutral, publickeytoken= b03f5f7f11d50a3a "/>  line 265: <add name=" Mysqlroleprovider "type=" MySql.Web.Security.MySQLRoleProvi Der, Mysql.web, version=6.7.4.0, Culture=neutral, publickeytoken=c5687fc88969c44d "Connectionstringname=" Localmysqlserver "Applicationname="/"/>  row 266: </providers>  Line 267: </ROLEMANAGER&G T  source file: C:\Windows\Microsoft.NET\Framework\v4.0.30319\Config\machine.config line: 265      

According to the official MySQL note is "Currently, MySQL Connector/net provides membership, Role, profile and Session state Providers.", that is, install Mys When QL Connector, the provider was installed by default, and Machine.config files were modified.

There are two ways to handle a program without an error:

1. In the Control Panel, locate MySQL Connector Net in the program, modify the removal web Providers

2. C:\Program Files (x86) \mysql\connector NET 6.7.4\assemblies\v4.0 Several class libraries MySql.Data.dll, MySql.Web.dll, MySql.Data.Entity.dll Copy to the bin directory of the site

Reference:

1. How to Connect to MySQL Using C #

2. rolemanager

Membership Enable RoleManager Throw exception: Failed to load file or assembly Mysql.web

Related Article

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.