Copied to clipboard

Flag this post as spam?

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


  • Andrew Stannard 14 posts 32 karma points
    Mar 26, 2010 @ 14:18
    Andrew Stannard
    0

    Error using api, accessing a documents properties failing

    '((umbraco.cms.businesslogic.Content)(temp)).GenericProperties' threw an exception of type 'System.Collections.Generic.KeyNotFoundException'

     

    I am using the following code:

     

    Document doc = new Document(1055);

    foreach (Document childDoc in doc.Children)
    {
          Document temp = new Document(childDoc.UniqueId);
          temp.getProperty("NoOfBizLessThan12").Value = 13;
    }

    The exception is thrown when using the getproperty method. I have also tried using getproperties but this also throws the same exception.

     

    Any ideas?

  • Nik Wahlberg 639 posts 1237 karma points MVP
    Mar 26, 2010 @ 14:38
    Nik Wahlberg
    0

    The only thing I can think of is that you have a typo in the property name or referenceing a proprty that does not exist on that doc type. 

    Obvious maybe, but I know I glance over typos all the time :) 

    Thanks,
    Nik

  • Andrew Stannard 14 posts 32 karma points
    Mar 26, 2010 @ 14:57
    Andrew Stannard
    0

    Thanks Nik, its not a spelling error though its always wise to check th obvious. I dug deeper into my visual studio value watch properties and found the following error:

       at System.ThrowHelper.ThrowKeyNotFoundException()
       at System.Collections.Generic.Dictionary`2.get_Item(TKey key)
       at umbraco.cms.businesslogic.datatype.controls.Factory.GetNewObject(Guid DataEditorId)
       at umbraco.cms.businesslogic.datatype.controls.Factory.DataType(Guid DataTypeId)
       at umbraco.cms.businesslogic.datatype.DataTypeDefinition.get_DataType()
       at umbraco.cms.businesslogic.property.Property..ctor(Int32 Id)
       at umbraco.cms.businesslogic.Content.InitializeProperties()
       at umbraco.cms.businesslogic.Content.get_GenericProperties()

    I am not familier with this conde but it seems that the get_GenericProperties() method is failing for the Document object???

     

  • Andrew Stannard 14 posts 32 karma points
    Mar 26, 2010 @ 16:43
    Andrew Stannard
    0

    I found this thread: http://our.umbraco.org/forum/developers/extending-umbraco/3499-Custom-data-type-issue?sort=newest

    I copied all of the dll files from my server running umbraco to the bin of the project using the api and it started working

Please Sign in or register to post replies

Write your reply to:

Draft