Description:
I want to use the MySQL .NET Connector so that I can use the database with Membership and Role providers. The connector supports this technology and I have most of it working. I can make new users using the ASP.NET Web Site Administration Tool in Visual Studio. However, when I create a role and then click on the "Manage" link. I get this error:
Object reference not set to an instance of an object. at System.Web.Administration.WebAdminPage.CallWebAdminHelperMethod(Boolean isMembership, String methodName, Object[] parameters, Type[] paramTypes) at ASP.security_roles_managesinglerole_aspx.Page_Load() at System.Web.Util.CalliHelper.ArglessFunctionCaller(IntPtr fp, Object o) at System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) at System.Web.UI.Control.OnLoad(EventArgs e) at System.Web.UI.Control.LoadRecursive() at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
What's strange is that, when I look at the contents of the `my_aspnet_role` table in the provider database schema, it contains the role I created. Unfortunately though, the ASP.NET admin tool doesn't think the roles are there so I can't assign users to roles.
My enviornment Information:
Windows XP Proffessional
Visual Studio 2005 Proffessional Edition
ASP.NET 2.0.50727
MySQL Server 5.0.67
MySQL Connector Net 6.0.3
My web.config Information:
(The user name and password in the connection string are not shown for security reasons. Also, I am running the MySQL Server on port 3307 and not the default port of 3306.)
<connectionStrings>
<remove name="LocalMySqlServer"/>
<add name="LocalMySqlServer" connectionString="DataSource=localhost;Port=3307;Database=DB;uid=;pwd=;" providerName="MySql.Data.MySqlClient"/>
</connectionStrings>
<system.web>
<roleManager enabled="true" defaultProvider="MySQLRoleProvider">
<providers>
<clear />
<add name="MySQLRoleProvider" type="MySql.Web.Security.MySQLRoleProvider, MySql.Web, Version=6.0.3.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d" connectionStringName="LocalMySqlServer" applicationName="/" />
</providers>
</roleManager>
<membership defaultProvider="MySQLMembershipProvider">
<providers>
<clear/>
<add autogenerateschema="true" name="MySQLMembershipProvider" type="MySql.Web.Security.MySQLMembershipProvider, MySql.Web, Version=6.0.3.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d" connectionStringName="LocalMySqlServer" />
</providers>
</membership>
</system.web>
How to repeat:
1. Install MySQL Connector/NET Version 6.0.3.
2. Create a new ASP.NET Website in Visual Studio 2005.
3. In Visual Studio 2005, go to the menu "Website" and select "ASP.Net Configuration". (I am assuming that you already have the Provider schema database created).
4. Click on the "Provider" tab and then select the MySQLMembershipProvider and the MySQLRoleProvider.
5. Click on the "Security" tab.
6. Click on the "Create or Manager roles" link.
7. Create the role and then click on the "Manage" link. You should get the error.
Suggested fix:
Fix the error that occurs when creating a role.