SystemUser class in CRM2011 SDK Sample Code

好久不见. 提交于 2019-12-10 11:27:47

问题


I am using the Microsoft CRM2011 Sample Code, when I try to compile it with Visual Studio 2010, (i use the C-Sharp code only, No VB for me please), i get this error:

Error 13 The type or namespace name 'SystemUser' could not be found (are you missing a using directive or an assembly reference?) systemuserprovider.cs

I am compiling a file straight from the SDK

...
SystemUser currentUser = serviceProxy.Retrieve(SystemUser.EntityLogicalName, currentUserId, new ColumnSet("domainname")).ToEntity<SystemUser>();
...

Similar issue with ...

// Query to retrieve other users. QueryExpression querySystemUser = new QueryExpression { EntityName = SystemUser.EntityLogicalName, ColumnSet = new ColumnSet(new String[] { "systemuserid", "fullname" }), Criteria = new FilterExpression() };

...

My includes are:

using System;
using System.IO;
using System.Text;
using System.Collections.Generic;
using System.DirectoryServices;      /* you need System.DirectoryServices.dll */
using System.Linq;
using System.Xml.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.ServiceModel;
using System.ServiceModel.Description;

using Microsoft.Xrm.Sdk;
using Microsoft.Xrm.Sdk.Query;
using Microsoft.Xrm.Sdk.Client;
using Microsoft.Xrm.Sdk.Messages;

using Microsoft.Crm.Sdk;
using Microsoft.Crm.Sdk.Messages;
...

Does anyone know where I can find a definition of SystemUser ?

Mike


回答1:


The early bound classes must be generated from CRM and included in the project.

There is a utility in the SDK to do this: sdk\bin\CrmSvcUtil.exe

Open a command prompt and move to the bin folder.
Run the program with these parameters:

CrmSvcUtil.exe /username:kingjulian /password:julianisking /url:https://julian.madagascar.com/XRMServices/2011/Organization.svc /out:jCRM.cs /serviceContextName:Context
  • Username and password are self explanatory
  • url is the organization service url
  • out is the cs file to be generated
  • serviceContextName is the name of the class that you can instantiate and write Linq queries against.

Once jCRM.cs has been added to the project you will have access to the SystemUser class.
The file jCRM.cs is located in sdk\bin.



来源:https://stackoverflow.com/questions/21689217/systemuser-class-in-crm2011-sdk-sample-code

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!