locked
"Value cannot be null.Parameter name: DeviceCredentials" Error while connection to crm from ASP.Net Application RRS feed

  • Question

  • Hi,

    I am getting the following error while connecting to crm online 2011 from ASP.Net Application

    "Value cannot be null.\r\nParameter name: DeviceCredentials".

    I am using the following code to bind the dropdown list with data from crm.

               

    private void BindDropDownList(IOrganizationService prmCrmService, string prmEntityName, string prmAttributeName, List<OptionCodes> ListOfOptions, DropDownList ddl)
            {
                RetrieveAttributeRequest retrieveAttributeRequest = new RetrieveAttributeRequest
                {
                    EntityLogicalName = prmEntityName,
                    LogicalName = prmAttributeName,
                    RetrieveAsIfPublished = true
                };

    RetrieveAttributeResponse retrieveAttributeResponse = (RetrieveAttributeResponse)prmCrmService.Execute(retrieveAttributeRequest);//This line gives error

                Microsoft.Xrm.Sdk.Metadata.PicklistAttributeMetadata retrievedPicklistAttributeMetadata = (Microsoft.Xrm.Sdk.Metadata.PicklistAttributeMetadata)

                retrieveAttributeResponse.AttributeMetadata;

                OptionMetadata[] jj_OptionList = retrievedPicklistAttributeMetadata.OptionSet.Options.ToArray();
                ListOfOptions = new List<OptionCodes>();
                foreach (OptionMetadata jj_OptionMetaData in jj_OptionList)
                {
                    OptionCodes objCRM_OptionCodes = new OptionCodes();
                    objCRM_OptionCodes.CRM_OptionCode = jj_OptionMetaData.Value.Value;
                    objCRM_OptionCodes.CRM_OptionCode_Text = jj_OptionMetaData.Label.UserLocalizedLabel.Label;
                    ListOfOptions.Add(objCRM_OptionCodes);
                }
                ddl.DataTextField = "CRM_OptionCode_Text";
                ddl.DataValueField = "CRM_OptionCode";
                ddl.DataSource = ListOfOptions;
                ddl.DataBind();
                ddl.Items.Insert(0, new ListItem("Select", "0"));
            }


    Any help would be appreciated.

    Wednesday, September 25, 2013 6:10 AM

Answers

  • Hi,

    The issue is resolved when i updated the latest SDK dlls in my application.

    Wednesday, September 25, 2013 12:41 PM

All replies

  • DeviceCredentials is a property of the OrganizationServiceProxy (which in you code is probably the prmCrmService variable). So, the issue is with the code that instantiates prmCrmService, rather than the code that you've posted 

    Microsoft CRM MVP - http://mscrmuk.blogspot.com/ http://www.excitation.co.uk

    Wednesday, September 25, 2013 10:39 AM
    Moderator
  • Hi,

    The issue is resolved when i updated the latest SDK dlls in my application.

    Wednesday, September 25, 2013 12:41 PM