Bug #46375 MySql.Web.Profile.MySQLProfileProvider does not work properly with Mono
Submitted: 24 Jul 2009 16:34 Modified: 4 Aug 2009 16:20
Reporter: Mark Walmsley Email Updates:
Status: Closed Impact on me:
None 
Category:Connector / NET Severity:S3 (Non-critical)
Version:6.0.4.0 OS:Linux (SuSE 11.1)
Assigned to: Reggie Burnett CPU Architecture:Any
Tags: Connector/Net, Mono, MySQLProfileProvider

[24 Jul 2009 16:34] Mark Walmsley
Description:
I am trying to get MySql.Web.Profile.MySQLProfileProvider to work with Mono. When I try to save a string in Profile.Name it does not work. There is nothing in the my_aspnet_Profiles table. I know the documentation says that the MySQL Profile Provider is not implemented yet, but it does seem to be in practice. When I try to force the save with Profile.Save() I get the following error:

Server Error in '/mono' Application

--------------------------------------------------------------------------------

The requested feature is not implemented.
Description: HTTP 500. Error processing request.

Stack Trace: 

System.NotImplementedException: The requested feature is not implemented.
  at MySql.Data.MySqlClient.MySqlConnection.EnlistTransaction (System.Transactions.Transaction transaction) [0x00000] 
  at MySql.Data.MySqlClient.MySqlConnection.Open () [0x00000] 
  at MySql.Web.Profile.MySQLProfileProvider.SetPropertyValues (System.Configuration.SettingsContext context, System.Configuration.SettingsPropertyValueCollection collection) [0x00000] 
 

--------------------------------------------------------------------------------
Version information: Mono Version: 2.0.50727.1433; ASP.NET Version: 2.0.50727.1433 

Here is my Web.Config file:

<?xml version="1.0"?>
<configuration>
  <system.web>
    <compilation>
      <assemblies>
        <add assembly="MySql.Data, Version=6.0.4.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d"/>
        <add assembly="MySql.Web, Version=6.0.4.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d"/>
        <add assembly="System.Transactions, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"/>
      </assemblies>
    </compilation>
    <authentication mode="Forms">
      <forms name=".ASPXAUTH" loginUrl="login.aspx" protection="All" timeout="30" path="/" requireSSL="false" slidingExpiration="true" defaultUrl="login.aspx" cookieless="UseCookies" enableCrossAppRedirects="false"/>
    </authentication>
    <membership defaultProvider="MySqlMembershipProvider" userIsOnlineTimeWindow="15">
      <providers>
        <add name="MySqlMembershipProvider" type="MySql.Web.Security.MySQLMembershipProvider, MySql.Web, Version=6.0.4.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d" connectionStringName="Test" applicationName="SecurityTest" autoGenerateSchema="true" enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="true" requiresUniqueEmail="true" passwordFormat="Encrypted"/>
      </providers>
    </membership>
    <roleManager enabled="true" cacheRolesInCookie="true" defaultProvider="MySqlRoleManagerProvider" cookieName=".ASPXROLES" cookiePath="/" cookieTimeout="30" cookieRequireSSL="false" cookieSlidingExpiration="true" createPersistentCookie="false" cookieProtection="All">
      <providers>
        <add name="MySqlRoleManagerProvider" type="MySql.Web.Profile.MySQLProfileProvider, MySql.Web, Version=6.0.4.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d" connectionStringName="ASPNETDB" applicationName="SecurityTest" autoGenerateSchema="true"/>
      </providers>
    </roleManager>
    <profile enabled="true" defaultProvider="MySqlProfileProvider">
      <providers>
        <add name="MySqlProfileProvider" type="MySql.Web.Profile.MySQLProfileProvider, MySql.Web, Version=6.0.4.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d" connectionStringName="Test" applicationName="SecurityTest" autoGenerateSchema="true"/>
      </providers>
      <properties>
        <add name="Name" allowAnonymous="true"/>
      </properties>
    </profile>
    <anonymousIdentification enabled="true" domain="" cookieName=".ASPXANONYMOUS" cookieTimeout="100000" cookiePath="/" cookieRequireSSL="false" cookieSlidingExpiration="true" cookieProtection="All" cookieless="UseCookies"/>
    <authorization>
      <deny users="?"/>
    </authorization>
    <machineKey validation="SHA1" validationKey="889162C5F8CE4027205D671227FE292CA958D8B42D981FA723F87D9A55FAB39B6B5BA1A297336FF99712D8C237400E94B41571C92509AA80D378D2DD920ADFB6" decryption="AES" decryptionKey="6FC649E37B2DCF3853FDE638BC78190090F08B5B5B3632F86F120FF11C6B084C"/>
    <customErrors mode="Off"/>
  </system.web>
  <system.data>
    <DbProviderFactories>
      <add name="MySqlClient Data Provider" description="MySqlClient Data Provider" invariant="MySql.Data.MySqlClient" type="MySql.Data.MySqlClient.MySqlClientFactory, MySql.Data, Version=6.0.4.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d"/>
    </DbProviderFactories>
  </system.data>
  <connectionStrings>
    <add name="Test" connectionString="Server=localhost;Database=test;Username=user;Password=password;" providerName="MySql.Data.MySqlClient"/>
  </connectionStrings>
</configuration>

How to repeat:
call Profile.Save() in Page_Load() event handler
[25 Jul 2009 16:06] Mark Walmsley
As far as I can tell there are 2 bugs ...

1. Mono's Profile Auto-Saving does not seem to call MySQLProfileProvider.SetPropertyValues() when Profile.Name is set. I need to call Profile.Save() explicitly to get this function called.

2. In MySQLProfileProvider.SetPropertyValues() the line :

using (TransactionScope ts = new TransactionScope())

throws an exception ... things work okay after commenting out this line and the following line:

ts.Complete();

This exception may be my problem for running an older version (5.1.34) of MySql ???
[26 Jul 2009 11:28] Mark Walmsley
Not so serious ...
[27 Jul 2009 6:58] Tonci Grgin
Hi Mark and thanks for your report.

I do not know what to do with it. Have you checked mono does support "EnlistTransactions"? Because of:
System.NotImplementedException: The requested feature is not implemented.
  at MySql.Data.MySqlClient.MySqlConnection.EnlistTransaction
(System.Transactions.Transaction transaction) [0x00000] 
I'd start from there...

Really doesn't appear to be our bug as it should be supported:
http://msdn.microsoft.com/en-us/library/system.data.common.dbconnection.enlisttransaction....
[27 Jul 2009 9:23] Mark Walmsley
I suspect the bugs are just due to my particular setup ... I'm using MyISAM tables which do not support transactions.

However, the MySQLMembershipProvider uses transaction = connection.BeginTransaction() plus transaction.Commit() or transaction.Rollback() instead of ts = new TransactionScope() plus ts.Complete() in MySQLRoleProvider and MySQLProfileProvider ... and MySQLMembershipProvider runs fine without exceptions.
[27 Jul 2009 12:16] Mark Walmsley
What I mean to say is that (since I can live without transactions) I'm able to work around the problem by just commenting out the transaction support and re-building the providers ... .

... but BeginTransaction() seems to silently ignore the lack of transaction support in the database (whereas TransactionScope does not), and if BeginTransaction() was used in the official MySql providers (instead of TransactionScope) then anyone could use your providers directly, whether they wanted to work with a database engine that supports transactions or not.
[3 Aug 2009 7:33] Tonci Grgin
Mark, you are probably right, must consult others on this change.
[3 Aug 2009 9:48] Tonci Grgin
Mark, TransactionScope and Transaction are not the same thing. Transaction scope is more like XA, i.e you can set the scope and do transaction against multiple/heterogenous databases. When something is aborted during this time, every participating transaction is aborted, or similar.
Mono support for this is limited (as described in http://www.mono-project.com/Transactions) thus we do not support everything on Mono (for example, EnlistTransaction is surrounded by #if !MONO && !CF) hence you seem to have problems instantiating TransactionScope.

So I'm not exactly sure what how to rule this report... Maybe we could enable remarked code in driver and just let Mono throw "NotImplemeted". But that's for Reggie to decide.
[3 Aug 2009 14:58] Mark Walmsley
How about a configuration option (like autoGenerateSchema or writeExceptionsToEventLog) to turn transaction support in the providers on or off?
[4 Aug 2009 13:49] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/80027

703 Reggie Burnett	2009-08-04
      removed usage of TransactionScope from web providers so that they work properly on Mono 2.0 (bug #46375)
[4 Aug 2009 13:58] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/80039

703 Reggie Burnett	2009-08-04
      removed usage of TransactionScope from web providers so that they work properly on Mono 2.0 (bug #46375)
[4 Aug 2009 14:04] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/80041

703 Reggie Burnett	2009-08-04
      removed usage of TransactionScope from web providers so that they work properly on Mono 2.0 (bug #46375)
[4 Aug 2009 14:13] Reggie Burnett
fixed in 5.2.8, 6.0.5, and 6.1.1+
[4 Aug 2009 16:20] Tony Bedford
Entries were added to the 5.2.8, 6.0.5 and 6.1.1 changelogs:

The MySQL Connector/NET Profile Provider, MySql.Web.Profile.MySQLProfileProvider, generated an error when running on Mono. When an attempt was made to save a string in Profile.Name the string was not saved to the my_aspnet_Profiles table. If an attempt was made to force the save with Profile.Save() the following error was generated:

Server Error in '/mono' Application

--------------------------------------------------------------------------------

The requested feature is not implemented.
Description: HTTP 500. Error processing request.

Stack Trace: 

System.NotImplementedException: The requested feature is not implemented.
  at MySql.Data.MySqlClient.MySqlConnection.EnlistTransaction
(System.Transactions.Transaction transaction) [0x00000] 
  at MySql.Data.MySqlClient.MySqlConnection.Open () [0x00000] 
  at MySql.Web.Profile.MySQLProfileProvider.SetPropertyValues
(System.Configuration.SettingsContext context,
System.Configuration.SettingsPropertyValueCollection collection) [0x00000] 
 

--------------------------------------------------------------------------------

Version information: Mono Version: 2.0.50727.1433; ASP.NET Version: 2.0.50727.1433