Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Jeavon Leopold 3000 posts 13139 karma points MVP 6x admin c-trib
    May 14, 2015 @ 00:11
    Jeavon Leopold
    0

    Trouble with Media Types that have inheritance

    Hi Kevin,

    uSync has been throwing a YSOD when it's trying to sync media types that have inheritance.

    Here is the error

    Read MediaType failed System.SystemException: Read MediaType failed System.SystemException: Read MediaType failed System.ArgumentException: An item with the same key has already been added.
      at System.Collections.Generic.Dictionary`2.Insert(TKey key, TValue value, Boolean add)
      at System.Collections.ObjectModel.KeyedCollection`2.AddKey(TKey key, TItem item)
      at Umbraco.Core.Models.PropertyGroupCollection.InsertItem(Int32 index, PropertyGroup item)
      at Umbraco.Core.Models.PropertyGroupCollection.Add(PropertyGroup item)
      at Umbraco.Core.EnumerableExtensions.ForEach[TItem](IEnumerable`1 items, Action`1 action)
      at Umbraco.Core.Models.PropertyGroupCollection.Reset(IEnumerable`1 groups)
      at Umbraco.Core.Persistence.Repositories.ContentTypeBaseRepository`1.ContentTypeQueryMapper.MapGroupsAndProperties(Int32[] contentTypeIds, Database db, IDictionary`2& allPropertyTypeCollection, IDictionary`2& allPropertyGroupCollection)
      at Umbraco.Core.Persistence.Repositories.ContentTypeBaseRepository`1.ContentTypeQueryMapper.MapContentTypeChildren[TRepo](IContentTypeComposition[] contentTypes, Database db, TRepo contentTypeRepository, IDictionary`2 allParentContentTypeIds)
      at Umbraco.Core.Persistence.Repositories.ContentTypeBaseRepository`1.ContentTypeQueryMapper.GetMediaTypes[TRepo](Int32[] mediaTypeIds, Database db, TRepo contentTypeRepository)
      at Umbraco.Core.Persistence.Repositories.RepositoryBase`2.GetAll(TId[] ids)
      at Umbraco.Core.Services.ContentTypeService.GetAllMediaTypes(Int32[] ids)
      at Umbraco.Core.Services.ContentTypeService.ValidateLocked(IContentTypeComposition compositionContentType)
      at Umbraco.Core.Services.ContentTypeService.Save(IMediaType mediaType, Int32 userId)
      at umbraco.cms.businesslogic.media.MediaType.Save()
      at jumps.umbraco.usync.MediaTypeHelper.Import(XmlNode n, Boolean ImportStructure)
      at jumps.umbraco.usync.SyncMediaTypes.ReadFromDisk(String path, Boolean structure)
      at jumps.umbraco.usync.SyncMediaTypes.ReadFromDisk(String path, Boolean structure)
      at jumps.umbraco.usync.SyncMediaTypes.ReadFromDisk(String path, Boolean structure)
      at jumps.umbraco.usync.SyncMediaTypes.ReadFromDisk(String path, Boolean structure)
      at jumps.umbraco.usync.SyncMediaTypes.ReadFromDisk(String path, Boolean structure)
    
    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.SystemException: Read MediaType failed System.SystemException: Read MediaType failed System.SystemException: Read MediaType failed System.ArgumentException: An item with the same key has already been added.
      at System.Collections.Generic.Dictionary`2.Insert(TKey key, TValue value, Boolean add)
      at System.Collections.ObjectModel.KeyedCollection`2.AddKey(TKey key, TItem item)
      at Umbraco.Core.Models.PropertyGroupCollection.InsertItem(Int32 index, PropertyGroup item)
      at Umbraco.Core.Models.PropertyGroupCollection.Add(PropertyGroup item)
      at Umbraco.Core.EnumerableExtensions.ForEach[TItem](IEnumerable`1 items, Action`1 action)
      at Umbraco.Core.Models.PropertyGroupCollection.Reset(IEnumerable`1 groups)
      at Umbraco.Core.Persistence.Repositories.ContentTypeBaseRepository`1.ContentTypeQueryMapper.MapGroupsAndProperties(Int32[] contentTypeIds, Database db, IDictionary`2& allPropertyTypeCollection, IDictionary`2& allPropertyGroupCollection)
      at Umbraco.Core.Persistence.Repositories.ContentTypeBaseRepository`1.ContentTypeQueryMapper.MapContentTypeChildren[TRepo](IContentTypeComposition[] contentTypes, Database db, TRepo contentTypeRepository, IDictionary`2 allParentContentTypeIds)
      at Umbraco.Core.Persistence.Repositories.ContentTypeBaseRepository`1.ContentTypeQueryMapper.GetMediaTypes[TRepo](Int32[] mediaTypeIds, Database db, TRepo contentTypeRepository)
      at Umbraco.Core.Persistence.Repositories.RepositoryBase`2.GetAll(TId[] ids)
      at Umbraco.Core.Services.ContentTypeService.GetAllMediaTypes(Int32[] ids)
      at Umbraco.Core.Services.ContentTypeService.ValidateLocked(IContentTypeComposition compositionContentType)
      at Umbraco.Core.Services.ContentTypeService.Save(IMediaType mediaType, Int32 userId)
      at umbraco.cms.businesslogic.media.MediaType.Save()
      at jumps.umbraco.usync.MediaTypeHelper.Import(XmlNode n, Boolean ImportStructure)
      at jumps.umbraco.usync.SyncMediaTypes.ReadFromDisk(String path, Boolean structure)
      at jumps.umbraco.usync.SyncMediaTypes.ReadFromDisk(String path, Boolean structure)
      at jumps.umbraco.usync.SyncMediaTypes.ReadFromDisk(String path, Boolean structure)
      at jumps.umbraco.usync.SyncMediaTypes.ReadFromDisk(String path, Boolean structure)
      at jumps.umbraco.usync.SyncMediaTypes.ReadFromDisk(String path, Boolean structure)
    
    Source Error: 
    
    An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
    
    Stack Trace: 
    
    
    [SystemException: Read MediaType failed System.SystemException: Read MediaType failed System.SystemException: Read MediaType failed System.ArgumentException: An item with the same key has already been added.
       at System.Collections.Generic.Dictionary`2.Insert(TKey key, TValue value, Boolean add)
       at System.Collections.ObjectModel.KeyedCollection`2.AddKey(TKey key, TItem item)
       at Umbraco.Core.Models.PropertyGroupCollection.InsertItem(Int32 index, PropertyGroup item)
       at Umbraco.Core.Models.PropertyGroupCollection.Add(PropertyGroup item)
       at Umbraco.Core.EnumerableExtensions.ForEach[TItem](IEnumerable`1 items, Action`1 action)
       at Umbraco.Core.Models.PropertyGroupCollection.Reset(IEnumerable`1 groups)
       at Umbraco.Core.Persistence.Repositories.ContentTypeBaseRepository`1.ContentTypeQueryMapper.MapGroupsAndProperties(Int32[] contentTypeIds, Database db, IDictionary`2& allPropertyTypeCollection, IDictionary`2& allPropertyGroupCollection)
       at Umbraco.Core.Persistence.Repositories.ContentTypeBaseRepository`1.ContentTypeQueryMapper.MapContentTypeChildren[TRepo](IContentTypeComposition[] contentTypes, Database db, TRepo contentTypeRepository, IDictionary`2 allParentContentTypeIds)
       at Umbraco.Core.Persistence.Repositories.ContentTypeBaseRepository`1.ContentTypeQueryMapper.GetMediaTypes[TRepo](Int32[] mediaTypeIds, Database db, TRepo contentTypeRepository)
       at Umbraco.Core.Persistence.Repositories.RepositoryBase`2.GetAll(TId[] ids)
       at Umbraco.Core.Services.ContentTypeService.GetAllMediaTypes(Int32[] ids)
       at Umbraco.Core.Services.ContentTypeService.ValidateLocked(IContentTypeComposition compositionContentType)
       at Umbraco.Core.Services.ContentTypeService.Save(IMediaType mediaType, Int32 userId)
       at umbraco.cms.businesslogic.media.MediaType.Save()
       at jumps.umbraco.usync.MediaTypeHelper.Import(XmlNode n, Boolean ImportStructure)
       at jumps.umbraco.usync.SyncMediaTypes.ReadFromDisk(String path, Boolean structure)
       at jumps.umbraco.usync.SyncMediaTypes.ReadFromDisk(String path, Boolean structure)
       at jumps.umbraco.usync.SyncMediaTypes.ReadFromDisk(String path, Boolean structure)
       at jumps.umbraco.usync.SyncMediaTypes.ReadFromDisk(String path, Boolean structure)
       at jumps.umbraco.usync.SyncMediaTypes.ReadFromDisk(String path, Boolean structure)]
       jumps.umbraco.usync.SyncMediaTypes.ReadFromDisk(String path, Boolean structure) +675
       jumps.umbraco.usync.SyncMediaTypes.ReadAllFromDisk() +177
       jumps.umbraco.usync.uSync.ReadAllFromDisk() +520
       jumoo.usync.ui.uSyncUi.btnImport_Click(Object sender, EventArgs e) +30
       System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +155
       System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +3804
    

    I could send you the "MediaTypes" folder if that would be useful?

    Cheers,

    Jeavon

  • marcelh 171 posts 471 karma points
    Jun 23, 2015 @ 12:26
    marcelh
    0

    Ouch. Just ran into the same message. I used to be working OK on this site, but after upgrading to Umbraco vLatest in combination with uSync vLatest I'm receiving the same message.

    @Jeavon did you get around this?

  • Jeavon Leopold 3000 posts 13139 karma points MVP 6x admin c-trib
    Jun 24, 2015 @ 08:39
    Jeavon Leopold
    0

    I'm afraid not, we now delete the media types folder before executing a uSync import at the moment and have reverted to migrating media type changes manually

  • marcelh 171 posts 471 karma points
    Jun 24, 2015 @ 08:44
    marcelh
    0

    That's what I planned to do. I noticed there is a configuration switch in the uSyncSettings that excludes media from being synced.

    Also found out that my issue probably not (only) related to uSync. I appears that in the upgrade process from v7.1.9 (I think) to v7.2.6 the doctype inheritance for media types was not handled properly. This may have caused the uSync error, but still investigating that...

  • Kevin Jump 1496 posts 9564 karma points MVP 3x c-trib
    Jun 24, 2015 @ 09:03
    Kevin Jump
    0

    Hi

    The actual error looks to be buried deep in the core somewhere, but I think it relates to Umbraco importing the Tabs for the media type.

    could you have a look at the media def.config files ? is It possible that the import file contains either two entries for a tab in the

    or that the tab section of the child contains the tab name from a parent?

    This shouldn't happen but if it has then it might be something that can be fixed at the export stage.

    Kevin

  • Jeavon Leopold 3000 posts 13139 karma points MVP 6x admin c-trib
    Jun 24, 2015 @ 09:13
    Jeavon Leopold
    0

    Hey Kevin,

    I don't see anything obvious...

    Image - def.config

    <?xml version="1.0" encoding="UTF-8" standalone="no"?>
    <MediaType>
      <Info>
        <Name>Image</Name>
        <Alias>Image</Alias>
        <Icon>icon-picture</Icon>
        <Thumbnail>icon-picture</Thumbnail>
        <Description>
        </Description>
        <AllowAtRoot>False</AllowAtRoot>
      </Info>
      <Structure />
      <GenericProperties>
        <GenericProperty>
          <Name>Alt text</Name>
          <Alias>altText</Alias>
          <Type>ec15c1e5-9d90-422a-aa52-4f7622c63bea</Type>
          <Definition>0cc0eba1-9960-42c9-bf9b-60e150b429ae</Definition>
          <Tab>Image</Tab>
          <Mandatory>False</Mandatory>
          <Validation>
          </Validation>
          <Description><![CDATA[]]></Description>
        </GenericProperty>
        <GenericProperty>
          <Name>Upload image</Name>
          <Alias>umbracoFile</Alias>
          <Type>556d6272-6163-6f2e-496d-61676543726f</Type>
          <Definition>88b800f5-67b0-4240-9c3e-8332acf9901f</Definition>
          <Tab>Image</Tab>
          <Mandatory>False</Mandatory>
          <Validation>
          </Validation>
          <Description><![CDATA[]]></Description>
        </GenericProperty>
        <GenericProperty>
          <Name>Width</Name>
          <Alias>umbracoWidth</Alias>
          <Type>474fcff8-9d2d-11de-abc6-ad7a56d89593</Type>
          <Definition>f0bc4bfb-b499-40d6-ba86-058885a5178c</Definition>
          <Tab>Image</Tab>
          <Mandatory>False</Mandatory>
          <Validation>
          </Validation>
          <Description><![CDATA[]]></Description>
        </GenericProperty>
        <GenericProperty>
          <Name>Height</Name>
          <Alias>umbracoHeight</Alias>
          <Type>474fcff8-9d2d-11de-abc6-ad7a56d89593</Type>
          <Definition>f0bc4bfb-b499-40d6-ba86-058885a5178c</Definition>
          <Tab>Image</Tab>
          <Mandatory>False</Mandatory>
          <Validation>
          </Validation>
          <Description><![CDATA[]]></Description>
        </GenericProperty>
        <GenericProperty>
          <Name>Size</Name>
          <Alias>umbracoBytes</Alias>
          <Type>474fcff8-9d2d-11de-abc6-ad7a56d89593</Type>
          <Definition>f0bc4bfb-b499-40d6-ba86-058885a5178c</Definition>
          <Tab>Image</Tab>
          <Mandatory>False</Mandatory>
          <Validation>
          </Validation>
          <Description><![CDATA[]]></Description>
        </GenericProperty>
        <GenericProperty>
          <Name>Type</Name>
          <Alias>umbracoExtension</Alias>
          <Type>474fcff8-9d2d-11de-abc6-ad7a56d89593</Type>
          <Definition>f0bc4bfb-b499-40d6-ba86-058885a5178c</Definition>
          <Tab>Image</Tab>
          <Mandatory>False</Mandatory>
          <Validation>
          </Validation>
          <Description><![CDATA[]]></Description>
        </GenericProperty>
      </GenericProperties>
      <Tabs>
        <Tab>
          <Id>3</Id>
          <Caption>Image</Caption>
          <Sort>1</Sort>
        </Tab>
      </Tabs>
    </MediaType>
    

    Then a child of Image MicrosoftTileIcon def.config

    <?xml version="1.0" encoding="UTF-8" standalone="no"?>
    <MediaType>
      <Info>
        <Name>MicrosoftTileIcon</Name>
        <Alias>MicrosoftTileIcon</Alias>
        <Icon>icon-folder</Icon>
        <Thumbnail>icon-folder</Thumbnail>
        <Description>
        </Description>
        <AllowAtRoot>False</AllowAtRoot>
        <Master>Image</Master>
      </Info>
      <Structure />
      <GenericProperties>
        <GenericProperty>
          <Name>TileColor</Name>
          <Alias>tilecolor</Alias>
          <Type>ec15c1e5-9d90-422a-aa52-4f7622c63bea</Type>
          <Definition>0cc0eba1-9960-42c9-bf9b-60e150b429ae</Definition>
          <Tab>Image</Tab>
          <Mandatory>False</Mandatory>
          <Validation>
          </Validation>
          <Description><![CDATA[]]></Description>
        </GenericProperty>
      </GenericProperties>
      <Tabs />
    </MediaType>
    

    Thanks for looking into it

    Jeavon

  • marcelh 171 posts 471 karma points
    Jun 25, 2015 @ 10:20
    marcelh
    0

    I'm getting a little closer to the issue. Steps to reproduce:

    1. Install a clean 7.2.6 umbraco install and setup uSync latest
    2. Create child type for media and add some properties and select the File tab for each of the properties (this is where things go wrong!)
    3. Let uSync Export the document types (this goes well)
    4. Let uSync Import the document types. This results in Read MediaType failed System.ArgumentException: An item with the same key has already been added.
    5. Have a look at the media type definition on Settings, expand the File type. This results in ArgumentException: An item with the same key has already been added.

    It appears that having the properties on the same tab as the master media type (probably especially the File tab), causes the issue.

    Note that after this, the mediatypes are in a corrupted state. You cannot delete them, nor can you (re)import them, as the call to GetMediaTypes always results in ArgumentException: An item with the same key has already been added.

    I don't know if this is a specific uSync error (the exported definitions looked ok) or related to the (latest) Umbraco release, but it makes nested mediatypes in combination with uSync useless :(

  • Gijs 38 posts 132 karma points
    Feb 25, 2016 @ 10:01
    Gijs
    0

    I ran into this problem just now. Is there a fix for it?

    Regards Gijs

  • marcelh 171 posts 471 karma points
    Feb 25, 2016 @ 10:03
    marcelh
    1

    I haven't looked into this recently, but I believe that the latest, refactored version of uSync handles it better.

    For me, the solution was to exclude mediaTypes from being synced, as once setup, these weren't changed anymore.

  • Gijs 38 posts 132 karma points
    Feb 25, 2016 @ 10:11
    Gijs
    0

    Thanks for your swift reply. How did you get the media-items out of the corrupted state they were in? Because that's the issue I'm facing now.

  • marcelh 171 posts 471 karma points
    Feb 25, 2016 @ 10:15
    marcelh
    0

    Restored the database ;-)

    Or a deep dive into the database. That's what I did the first time in my development environment, but I can't remember the exact SQL statements.

    Other than that, remove it and recreate it. But you will probably loose any existing media items :(

  • Kevin Jump 1496 posts 9564 karma points MVP 3x c-trib
    Feb 25, 2016 @ 13:02
    Kevin Jump
    0

    Hi

    Sorry I missed the replies to this topic somewhere...

    I've just had a (not to quick in the end) look again at the media service stuff in usync. for versions pre v2.x of uSync it's all a bit arcane the code, because it is using the old api's as the newer ones weren't 100% for media types pre umbraco v7.3.

    After much faffing, I think the fix is to do the tabs in another way using some of the newer api for this bit of the sync. (inherited tabs are actually created both on the parent and child media type, and you have to make sure you add your items to the right tabs, and do it after you've done everything else, or it goes pop.)

    There is an updated dll in github that contains this fix:

    https://github.com/KevinJump/jumps.umbraco.usync/tree/v2.2-Umbraco-7/Package/uSync (you just need jumps.umbraco.usync.dll) once i've done some testing i will push out an updated package.

    I haven't yet found the way to fix existing broken ones :( but removing the tab from parent (so putting existing properties into generic or something) might get you access to the child, but my install was quite messed up with loads of tests when i tried that!.

    • for v7.3+ (uSync 3.x) this works as the code uses the new API.
    • Worth noting in Umbraco 7.4 you can't have nested Media Types,
Please Sign in or register to post replies

Write your reply to:

Draft