Error Sequence contains more than one element

Sep 25, 2011 at 1:18 PM

Hello,

I´m getting the following error:

Server Error in '/' Application.

Sequence contains more than one element

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 

Exception Details: System.InvalidOperationException: Sequence contains more than one element

Source Error: 

Line 187:            if (imageGalleryName.Contains("\\") || imageGalleryName.Contains("/"))
Line 188:                imageGalleryName = GetName(imageGalleryName);
Line 189:            return _repository.Get(o => o.ImageGalleryName == imageGalleryName);
Line 190:        }
Line 191:


Source File: c:\inetpub\vhosts\nduarte.com\subdomains\caladorf\httpdocs\Modules\Mello.ImageGallery\Services\ImageGalleryService.cs    Line: 189 

Stack Trace: 

[InvalidOperationException: Sequence contains more than one element]
   System.Linq.Enumerable.SingleOrDefault(IEnumerable`1 source) +4178510
   NHibernate.Linq.Visitors.ImmediateResultsVisitor`1.HandleSingleOrDefaultCall(MethodCallExpression call) +51
   NHibernate.Linq.Visitors.ImmediateResultsVisitor`1.VisitMethodCall(MethodCallExpression call) +411
   NHibernate.Linq.Visitors.ExpressionVisitor.Visit(Expression exp) +371
   NHibernate.Linq.Visitors.NHibernateExpressionVisitor.Visit(Expression exp) +211
   NHibernate.Linq.Visitors.ImmediateResultsVisitor`1.GetResults(MethodCallExpression expr) +15
   NHibernate.Linq.Visitors.RootVisitor.HandleImmediateResultsCall(MethodCallExpression call) +174
   NHibernate.Linq.Visitors.RootVisitor.VisitMethodCall(MethodCallExpression expr) +716
   NHibernate.Linq.Visitors.ExpressionVisitor.Visit(Expression exp) +371
   NHibernate.Linq.Visitors.NHibernateExpressionVisitor.Visit(Expression exp) +211
   NHibernate.Linq.Visitors.NHibernateQueryTranslator.TranslateInternal(Expression expression) +75
   NHibernate.Linq.Visitors.NHibernateQueryTranslator.Translate(Expression expression, QueryOptions queryOptions) +27
   NHibernate.Linq.NHibernateQueryProvider.TranslateExpression(Expression expression) +289
   NHibernate.Linq.NHibernateQueryProvider.Execute(Expression expression) +14
   NHibernate.Linq.QueryProvider.System.Linq.IQueryProvider.Execute(Expression expression) +38
   System.Linq.Queryable.SingleOrDefault(IQueryable`1 source) +265
   Orchard.Data.Repository`1.Get(Expression`1 predicate) +104
   Orchard.Data.Repository`1.Orchard.Data.IRepository<T>.Get(Expression`1 predicate) +45
   Mello.ImageGallery.Services.ImageGalleryService.GetImageGallerySettings(String imageGalleryName) in c:\inetpub\vhosts\nduarte.com\subdomains\caladorf\httpdocs\Modules\Mello.ImageGallery\Services\ImageGalleryService.cs:189
   Mello.ImageGallery.Services.ImageGalleryService.CreateImageGalleryFromMediaFolder(MediaFolder mediaFolder) in c:\inetpub\vhosts\nduarte.com\subdomains\caladorf\httpdocs\Modules\Mello.ImageGallery\Services\ImageGalleryService.cs:206
   System.Linq.WhereSelectListIterator`2.MoveNext() +110
   ASP._Page_Modules_Mello_ImageGallery_Views_admin_Index_cshtml.Execute() in c:\inetpub\vhosts\nduarte.com\subdomains\caladorf\httpdocs\Modules\Mello.ImageGallery\Views\Admin\Index.cshtml:20
   System.Web.WebPages.WebPageBase.ExecutePageHierarchy() +209
   System.Web.Mvc.WebViewPage.ExecutePageHierarchy() +89
   System.Web.WebPages.WebPageBase.ExecutePageHierarchy(WebPageContext pageContext, TextWriter writer, WebPageRenderingBase startPage) +90
   System.Web.Mvc.RazorView.RenderView(ViewContext viewContext, TextWriter writer, Object instance) +199
   System.Web.Mvc.BuildManagerCompiledView.Render(ViewContext viewContext, TextWriter writer) +107
   Orchard.Mvc.ViewEngines.ThemeAwareness.<>c__DisplayClass7.<FindView>b__5(ViewContext viewContext, TextWriter writer, IViewDataContainer viewDataContainer) +235
   Orchard.Mvc.ViewEngines.ThemeAwareness.LayoutView.Render(ViewContext viewContext, TextWriter writer) +88
   System.Web.Mvc.ViewResultBase.ExecuteResult(ControllerContext context) +291
   System.Web.Mvc.ControllerActionInvoker.InvokeActionResult(ControllerContext controllerContext, ActionResult actionResult) +13
   System.Web.Mvc.<>c__DisplayClass1c.<InvokeActionResultWithFilters>b__19() +23
   System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilter(IResultFilter filter, ResultExecutingContext preContext, Func`1 continuation) +264
   System.Web.Mvc.<>c__DisplayClass1e.<InvokeActionResultWithFilters>b__1b() +20
   System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilter(IResultFilter filter, ResultExecutingContext preContext, Func`1 continuation) +264
   System.Web.Mvc.<>c__DisplayClass1e.<InvokeActionResultWithFilters>b__1b() +20
   System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilter(IResultFilter filter, ResultExecutingContext preContext, Func`1 continuation) +264
   System.Web.Mvc.<>c__DisplayClass1e.<InvokeActionResultWithFilters>b__1b() +20
   System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilter(IResultFilter filter, ResultExecutingContext preContext, Func`1 continuation) +264
   System.Web.Mvc.<>c__DisplayClass1e.<InvokeActionResultWithFilters>b__1b() +20
   System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilter(IResultFilter filter, ResultExecutingContext preContext, Func`1 continuation) +264
   System.Web.Mvc.<>c__DisplayClass1e.<InvokeActionResultWithFilters>b__1b() +20
   System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilter(IResultFilter filter, ResultExecutingContext preContext, Func`1 continuation) +264
   System.Web.Mvc.<>c__DisplayClass1e.<InvokeActionResultWithFilters>b__1b() +20
   System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilter(IResultFilter filter, ResultExecutingContext preContext, Func`1 continuation) +264
   System.Web.Mvc.<>c__DisplayClass1e.<InvokeActionResultWithFilters>b__1b() +20
   System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilter(IResultFilter filter, ResultExecutingContext preContext, Func`1 continuation) +264
   System.Web.Mvc.<>c__DisplayClass1e.<InvokeActionResultWithFilters>b__1b() +20
   System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilter(IResultFilter filter, ResultExecutingContext preContext, Func`1 continuation) +264
   System.Web.Mvc.<>c__DisplayClass1e.<InvokeActionResultWithFilters>b__1b() +20
   System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilter(IResultFilter filter, ResultExecutingContext preContext, Func`1 continuation) +264
   System.Web.Mvc.<>c__DisplayClass1e.<InvokeActionResultWithFilters>b__1b() +20
   System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilter(IResultFilter filter, ResultExecutingContext preContext, Func`1 continuation) +264
   System.Web.Mvc.<>c__DisplayClass1e.<InvokeActionResultWithFilters>b__1b() +20
   System.Web.Mvc.ControllerActionInvoker.InvokeActionResultWithFilters(ControllerContext controllerContext, IList`1 filters, ActionResult actionResult) +176
   System.Web.Mvc.ControllerActionInvoker.InvokeAction(ControllerContext controllerContext, String actionName) +329
   System.Web.Mvc.Controller.ExecuteCore() +115
   System.Web.Mvc.ControllerBase.Execute(RequestContext requestContext) +94
   System.Web.Mvc.ControllerBase.System.Web.Mvc.IController.Execute(RequestContext requestContext) +10
   System.Web.Mvc.<>c__DisplayClassb.<BeginProcessRequest>b__5() +37
   System.Web.Mvc.Async.<>c__DisplayClass1.<MakeVoidDelegate>b__0() +21
   System.Web.Mvc.Async.<>c__DisplayClass8`1.<BeginSynchronous>b__7(IAsyncResult _) +12
   System.Web.Mvc.Async.WrappedAsyncResult`1.End() +55
   System.Web.Mvc.<>c__DisplayClasse.<EndProcessRequest>b__d() +31
   System.Web.Mvc.SecurityUtil.<GetCallInAppTrustThunk>b__0(Action f) +7
   System.Web.Mvc.SecurityUtil.ProcessInApplicationTrust(Action action) +23
   System.Web.Mvc.MvcHandler.EndProcessRequest(IAsyncResult asyncResult) +59
   System.Web.Mvc.MvcHandler.System.Web.IHttpAsyncHandler.EndProcessRequest(IAsyncResult result) +9
   Orchard.Mvc.Routes.HttpAsyncHandler.EndProcessRequest(IAsyncResult result) +50
   System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +8841105
   System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +184

Anyone could give a hint how to resolve this?

Thank's

Nuno.

Coordinator
Sep 25, 2011 at 7:17 PM

Hi Nuno,

Could you please give some details about the names of your image galleries created and what is the full path of your Orchard installation?

Thanks for your feedback.

Gabriel

Sep 25, 2011 at 7:36 PM

Hi Gabriel, 

I Believe i found the problem, for some reason my client managed to create two galleries with the same name. After deleting one on the database, the error disapeared.
Below you can see the table Mello_ImageGallery_ImageGallerySettingsRecord (when the error was there). 
This error came up while trying to manage the ImageGalleries from the dashboard.  

1 Product1 120 103 False
2 Product2 120 103 False
3 Product3 120 103 False
4 Product4 120 103 False
5 Inspiration 180 100 True
6 product 5   the squire 120 103 False
7 Teste 2 120 103 False
9 Test Duarte 120 103 False
10 Liquidglass 100 100 True
11 Theuniversal 100 100 True
12 The Stander 120 103 False
13 TheSquire 100 100 True
14 The Travel 120 103 False
15 Liquid Glass 120 103 False
16 The Universal 120 103 False
17 The Squire 120 103 False
18 The Stander 120 103 False





Thank´s

Nuno.

Coordinator
Sep 26, 2011 at 12:34 PM

Thanks for you feedback Nuno. This guess this occurred if the user deleted the image gallery folder manually instead of using the module UI.

I added an issue on the issue tracker so I can remember to take a look a this problem for the future releases.

Thanks!