Bug #66625 ProfileManager.DeleteProfiles call fails with System.InvalidCastException
Submitted: 30 Aug 2012 18:52 Modified: 10 Sep 2012 14:45
Reporter: John Hetzler Email Updates:
Status: Duplicate Impact on me:
None 
Category:Connector / NET Severity:S2 (Serious)
Version:6.5.4 OS:Windows (Win7)
Assigned to: Assigned Account CPU Architecture:Any
Tags: cast, DeleteProfiles, invalid, ProfileManager

[30 Aug 2012 18:52] John Hetzler
Description:
I was following a tutorial on using Profiles with MySQL and Asp.Net. I added the section in Global.asax for the Profile_OnMigrateAnonymous event handler.

The call to ProfileManager.DeleteProfile(args.AnonymousID) fails with a System.InvalidCastException: specified cast is not valid. This should have deleted the profile for this anonymous user. None of the data in the my_aspnet_* tables changed where the row in My_aspnet_profiles for this userid should have been removed.

The top-most traces are:
MySql.Web.Profile.MySQLProfileProvider.DeleteProfiles(String[] usernames) +350
System.Web.Profile.ProfileManager.DeleteProfile(String username) +84

I'll attach a screen-shot of the stack trace as reported in the Browser.

Windows 7, Visual Studio 2010, .Net 4.0, MySQL 5.5.27, Connector.Net 6.5.4, IE 8

How to repeat:
Simple asp.net tutorial app on profiles with a login page and MySQL as provider.
Run from within Visual Studio with Ctrl-F5.
Access profile page as anonymous user and save profile data. Exit browser.
Run from within Visual Studio with Ctrl-F5.
Login as authorized user. As soon as login button is pressed, the invalid cast exception is thrown.

Suggested fix:
Find and fix the invalid cast.
[30 Aug 2012 18:54] John Hetzler
Stack trace at failure

Attachment: DeleteProfileError.jpg (image/pjpeg, text), 92.32 KiB.

[10 Sep 2012 14:45] Roberto Ezequiel Garcia Ballesteros
Bug duplicated:
http://bugs.mysql.com/bug.php?id=64470
[12 Sep 2012 17:19] Fernando Gonzalez.Sanchez
The fix for this bug's duplicate (64470) has been already released in 6.6.1 and later.