Having more than one storage filter for a given part

Topics: General, Troubleshooting, Writing modules
Sep 1, 2011 at 7:06 AM

I'm getting the following error in my stackstace but i don't have more then 1 storage filter for the record:

Having more than one storage filter for a given part (Orchard.ContentManagement.ContentPart`1[[CommunityPages.Records.CommunityEstablishmentPartRecord, CommunityPages, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null]]) is invalid.

Somebody has a clue?

Coordinator
Sep 1, 2011 at 6:22 PM

Can you provide the full stack trace, and the code for your handler?

Sep 9, 2011 at 8:38 AM

Still not fixed and very problematic at the moment!

this is what is get from my output:

A first chance exception of type 'System.InvalidOperationException' occurred in Orchard.Framework.dll
Orchard.ContentManagement.DefaultContentManager: ERROR - InvalidOperationException thrown from IContentHandler by CommunityPages.Handlers.CommunityEstablishmentPartHandler
System.InvalidOperationException: Having more than one storage filter for a given part (Orchard.ContentManagement.ContentPart`1[[CommunityPages.Records.CommunityEstablishmentPartRecord, CommunityPages, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null]]) is invalid.
   at Orchard.ContentManagement.Handlers.StorageFilter`1.Activated(ActivatedContentContext context, ContentPart`1 instance) in C:\folderstructureOrchard\ContentManagement\Handlers\StorageFilter.cs:line 45
   at Orchard.ContentManagement.Handlers.StorageFilterBase`1.Orchard.ContentManagement.Handlers.IContentStorageFilter.Activated(ActivatedContentContext context) in C:\folderstructureOrchard\ContentManagement\Handlers\StorageFilterBase.cs:line 24
   at Orchard.ContentManagement.Handlers.ContentHandler.Orchard.ContentManagement.Handlers.IContentHandler.Activated(ActivatedContentContext context) in C:\folderstructureOrchard\ContentManagement\Handlers\ContentHandler.cs:line 192
   at Orchard.ContentManagement.DefaultContentManager.<>c__DisplayClass6.<New>b__4(IContentHandler handler) in C:\folderstructureOrchard\ContentManagement\DefaultContentManager.cs:line 87
   at Orchard.InvokeExtensions.Invoke[TEvents](IEnumerable`1 events, Action`1 dispatch, ILogger logger) in C:\folderstructureOrchard\InvokeExtensions.cs:line 19

My handler (very basic):

[UsedImplicitly]
    public class CommunityEstablishmentPartHandler : ContentHandler
    {
        public CommunityEstablishmentPartHandler(IRepository<CommunityEstablishmentPartRecord> repository)
        {
            Filters.Add(StorageFilter.For(repository));
        }
    }

Sep 12, 2011 at 6:28 AM

Does someone has a clue? Because this problem getting serious at the moment :(

Sep 12, 2011 at 8:13 AM

Have you checked all your other handlers? It's easy enough to have a typo and specify the wrong type in your constructor which might cause this.

Sep 12, 2011 at 8:15 AM

Ok after some research i found out the following code had to be removed from my part:

public CommunityEstablishmentPart()
{
      Record = new CommunityEstablishmentPartRecord();
}

So FIXED