CRM استرداد الكيان - خطأ: غير قادر على إلقاء كائن من النوع "Microsoft.xrm.sdk.entity" لنوع "الحكم"

StackOverflow https://stackoverflow.com/questions/9518994

سؤال

قمت بإنشاء كيانات من CRM مثل هذا: giveacodicetagpre.

ل servicecontextname قمت بتعيين xrmservicecontext . أريد استرداد بعض الكيان من CRM باستخدام الرمز التالي: giveacodicetagpre.

وألقي الخطأ: giveacodicetagpre.

بعد "إضافة لمشاهدة" رأيت أن كل مجموعة من الكيانات في السياق لها نفس الرسالة. ماذا فاتني؟

هل كانت مفيدة؟

المحلول

Problem solved. After initializing OrganizationServiceProxy, I have to call EnableProxyTypes method.

OrganizationServiceProxy orgserv;
ClientCredentials clientCreds = new ClientCredentials();

    clientCreds.Windows.ClientCredential.UserName = username;
    clientCreds.Windows.ClientCredential.Password = password;
    clientCreds.Windows.ClientCredential.Domain = domain;
    IServiceConfiguration<IOrganizationService> orgConfigInfo = ServiceConfigurationFactory.CreateConfiguration<IOrganizationService>(orgServiceUri);

    orgserv = new OrganizationServiceProxy(orgConfigInfo, clientCreds);
    orgserv.EnableProxyTypes();

Key thing is: orgserv.EnableProxyTypes();

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top