locked
Unable to cast object of type 'Microsoft.Crm.Sdk.Query.AllColumns' to type 'Microsoft.Crm.Sdk.Query.ColumnSet. RRS feed

  • Question

  • Hi,

    In my plugin code i am using this line of code.

    ColumnSet columns = (ColumnSet)context.InputParameters["ColumnSet"];


    But it is giving me the error

    Unable to cast object of type 'Microsoft.Crm.Sdk.Query.AllColumns' to type 'Microsoft.Crm.Sdk.Query.ColumnSet.

    Please tell me how to type cast it?


    Thanks,
    Kishen

    Tuesday, November 30, 2010 10:03 AM

Answers

  • I think you're actaully better off casting to ColumnSetBase, as the ColumnSet InoutParameter could be of type AllColumns or ColumnSet, which both derive from ColumnSetBase. You can then use the 'is' operator to check which type it is:

    ColumnSetBase columns = (AllColumns)context.InputParameters["ColumnSet"];
    if (columns Is AllColumns)

    ......


    Microsoft CRM MVP - http://mscrmuk.blogspot.com  http://www.excitation.co.uk
    Tuesday, November 30, 2010 1:30 PM
    Moderator

All replies