CRM 검색 엔티티 - 오류 : 'microsoft.xrm.sdk.entity'유형의 객체를 던지면 'crmentities.list'를 입력 할 수 없습니다.

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

문제

이처럼 CRM에서 엔티티를 생성했습니다.

CrmSvcUtil.exe /url:http://<servername>/<organizationname>/XRMServices/2011/Organization.svc
    /out:<outputfilename>.cs /username:<username> /password:<password> /domain:<domainname>
    /namespace:CRMEntities /serviceContextName:XrmServiceContext
.

serviceContextName 의 경우 xrmserviceContext 을 설정합니다. 다음 코드를 사용하여 CRM에서 일부 엔티티를 검색하고 싶습니다.

var context = new XrmServiceContext(myorgserv);
var marketingList = context.ListSet.Where(item => item.Id == new Guid("SOME GUID"));
.

에 오류가 발생합니다.

Message "Unable to cast object of type 'Microsoft.Xrm.Sdk.Entity' to type 'CRMEntities.List'."
.

시계에 추가하십시오. 내가 누락 된 것은 무엇입니까?

도움이 되었습니까?

해결책

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