unable to cast object of type microsoft.crm.sdk.propertycollection RRS feed

  • Question

  • I am having trouble setting the properties on a dynamic entity in a crm 4 workflow

    keep  getting unable to cast object of type microsoft.crm.sdk.propertycollection to type system.collection.icollection

    Im bascially doing a retrievemultiple and then trying to update the dynamic entity

    I do not have a reference to the crm webservice.  I only have the reference to the sdk dlls 

    can anyone see errors in the code is below


    Dim requestMarketingList As RetrieveMultipleRequest = New RetrieveMultipleRequest requestMarketingList.Query = queryMarketingList requestMarketingList.ReturnDynamicEntities = True Dim responseMarketingList As RetrieveMultipleResponse = crmService.Execute(requestMarketingList) If responseMarketingList.BusinessEntityCollection.BusinessEntities.Count > 0 Then Dim BusinessEntity As BusinessEntity 'loop through the list For Each BusinessEntity In responseMarketingList.BusinessEntityCollection.BusinessEntities Dim MarketingList As DynamicEntity = CType(BusinessEntity, DynamicEntity) Dim tempString As StringProperty = New StringProperty tempString.Name = "listname"
    tempString.Value = "test" MarketingList.Properties.Add(tempString) 'crmService.Update(MarketingList) 'Create the update target. Dim updateDynamic As TargetUpdateDynamic = New TargetUpdateDynamic 'Set the properties of the target.
    updateDynamic.Entity = MarketingList 'Create the update request object. Dim update As UpdateRequest = New UpdateRequest 'Set request properties. update.Target = updateDynamic ' Execute the request. Dim updated As UpdateResponse = CType(crmService.Execute(update), UpdateResponse) Next End If 'end retrieve marketinglist
    • Edited by T Bonz Thursday, June 11, 2009 12:41 PM
    Thursday, June 11, 2009 12:20 PM


  • well after all the headaches it turned out I had reference to to systems.collections and it was conflicting

    • Marked as answer by T Bonz Thursday, June 11, 2009 1:07 PM
    Thursday, June 11, 2009 1:06 PM