U4-4250 - System.InvalidOperationException - open DataReader exception when iterating Member properties

Created by Robert Foster 18 Feb 2014, 02:57:11 Updated by Sebastiaan Janssen 18 Feb 2014, 07:41:15

I'm trying to retrieve a list of properties and their values from a Member profile using the following code:

foreach (var p in subscriber.Member.GenericProperties) { mergeFields.Add(p.PropertyType.Alias, p.Value.ToString()); }

When accessing any Property Value the program execution aborts and the following log entry is present in the Log:

2014-02-18 13:12:05,232 [68] ERROR Umbraco.Core.UmbracoApplicationBase - [Thread 68] An unhandled exception occurred System.Web.HttpUnhandledException (0x80004005): Exception of type 'System.Web.HttpUnhandledException' was thrown. ---> System.InvalidOperationException: There is already an open DataReader associated with this Command which must be closed first. at System.Data.SqlClient.SqlInternalConnectionTds.ValidateConnectionForExecute(SqlCommand command) at System.Data.SqlClient.SqlConnection.ValidateConnectionForExecute(String method, SqlCommand command) at System.Data.SqlClient.SqlCommand.ValidateCommand(String method, Boolean async) at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, TaskCompletionSource1 completion, Int32 timeout, Task& task, Boolean asyncWrite) at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method) at System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior behavior, String method) at System.Data.SqlClient.SqlCommand.ExecuteDbDataReader(CommandBehavior behavior) at System.Data.Common.DbCommand.ExecuteReader(CommandBehavior behavior) at StackExchange.Profiling.Data.ProfiledDbCommand.ExecuteDbDataReader(CommandBehavior behavior) at System.Data.Common.DbCommand.System.Data.IDbCommand.ExecuteReader() at Umbraco.Core.Persistence.PetaPocoCommandExtensions.<>c__DisplayClass4.<ExecuteReaderWithRetry>b__3() at Umbraco.Core.Persistence.FaultHandling.RetryPolicy.ExecuteAction[TResult](Func1 func) at Umbraco.Core.Persistence.PetaPocoCommandExtensions.ExecuteReaderWithRetry(IDbCommand command, RetryPolicy cmdRetryPolicy, RetryPolicy conRetryPolicy) at Umbraco.Core.Persistence.PetaPocoCommandExtensions.ExecuteReaderWithRetry(IDbCommand command, RetryPolicy retryPolicy) at Umbraco.Core.Persistence.PetaPocoCommandExtensions.ExecuteReaderWithRetry(IDbCommand command) at Umbraco.Core.Persistence.Database.d__1c1.MoveNext() at System.Collections.Generic.List1..ctor(IEnumerable1 collection) at System.Linq.Enumerable.ToList[TSource](IEnumerable1 source) at Umbraco.Core.Persistence.Database.Fetch[T1,T2,T3](Sql sql) at umbraco.cms.businesslogic.datatype.DefaultData.LoadValueFromDatabase() at umbraco.cms.businesslogic.datatype.DefaultData.get_Value() at umbraco.cms.businesslogic.property.Property.get_Value() at

I'm running the code block in a function that is called in a foreach loop, but testing with one entry in the (IEnumerable) list only. This code is being called from the backoffice via a dialog form submit sitting in an UpdatePanel.

I have two properties on this member type:

  • The first property is a custom control which has it's data cached but looks up prevalues using the old SqlHelper.ExectuteReader method.
  • The second property (also reporting an error) is the standard RichText Editor.

It looks to me like it's fetching the default values for each property and failing there.

This is a bit of a show stopper for me going forward, however in the interim I've placed a try-catch block around the offending code and ignoring it for now.

Comments

Sebastiaan Janssen 18 Feb 2014, 07:41:12

Not an umbraco problem but something you're doing wrong in your own code, see: http://stackoverflow.com/questions/6062192/there-is-already-an-open-datareader-associated-with-this-command-which-must-be-c


Priority: Normal

Type: Bug

State: Closed

Assignee:

Difficulty: Normal

Category:

Backwards Compatible: True

Fix Submitted:

Affected versions: 6.1.6

Due in version:

Sprint:

Story Points:

Cycle: