CRM استرداد الكيان - خطأ: غير قادر على إلقاء كائن من النوع "Microsoft.xrm.sdk.entity" لنوع "الحكم"
-
14-11-2019 - |
سؤال
قمت بإنشاء كيانات من 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();
لا تنتمي إلى StackOverflow