Inaccessible due to its protection level.. ??? RRS feed

  • Question

  • How resolve following error message which is showing when I am trying to use Count().


    Wednesday, October 7, 2015 5:51 AM

All replies

  • Hi Setu,

    By looking your code snippet - I can say that you are using two different API:
    1. CRM Api (CRM web services)
    2. Telerik Api

    Now come to EntityCollection Class & its object - 

    EntityCollection class present in both the API:
    1. CRM EntityCollection
    2. Telerik EntityCollection

    And this might be an issue - You code might setting EntityCollection of Telerik insteed of CRM in your code first line.

    EntityCollection entityCollection = serviceProxy.Re....
    //update this to:
    Microsoft.Xrm.Sdk.EntityCollection entityCollection = serviceProxy.Re....

    It will force it to use the EntityCollection from Microsoft CRM sdk, which having Count method.

    • Edited by Piyush Parate Wednesday, October 7, 2015 7:35 AM
    • Proposed as answer by Piyush Parate Wednesday, October 7, 2015 7:35 AM
    • Unproposed as answer by Piyush Parate Wednesday, October 7, 2015 9:24 AM
    Wednesday, October 7, 2015 7:33 AM
  • Thanks for quick reply but.. I tried as u suggested but not working... Although if I remove () from count .. then It worked..

    But I wondered how the same code is working fine in a class..can you explain this behavior..?


    Wednesday, October 7, 2015 7:43 AM
  • Hi,

    As suggested above when you use Count().

    its taking  'Count' method from below API.


    Whereas in CRM EntityCollection 'Count' is a property not a method.

    Hope it helps


    If you find this post helpful then please "Vote as Helpful" and "Mark As Answer". Thanks and Regards, Mohammad Yusuf Ansari http://microxrm.blogspot.in

    Wednesday, October 7, 2015 10:32 AM