2
votes

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
try systemuser with lowercaseAdi Katz
That won't work either. Remember, this is CRM SDK code that I obtained from Microsoft's own code libraries. "SystemUser" is an object that is used frequently throughout the sample code, and is even mentioned here in stackexchange. Surely somebody knows why this code will not compile.mike

1 Answers

6
votes

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.