In the project’s properties, set the target framework to .NET Framework 4.
Add the following .NET references to your project:
System.Data.Linq
System.Runtime.Serialization
System.Security
System.ServiceModel
System.DirectoryServices.AccountManagement
Add the required Microsoft Dynamics CRM SDK assembly references. At a minimum, add Microsoft.Crm.Sdk.Proxy and Microsoft.Xrm.Sdk. For a complete list of the assemblies included in the Microsoft Dynamics CRM SDK, see Assemblies Included in the Microsoft Dynamics CRM SDK.
In most cases, you need to install Windows Identity Foundation and add a reference to Microsoft.IdentityModel to your project.
Including the following namespaces
using System;
//using System.ServiceModel; // Maybe needed for more complex crm programs
using System.ServiceModel.Description;
using Microsoft.Xrm.Sdk.Client;
//using Microsoft.Crm.Sdk; // Maybe needed for more complex crm programs
using Microsoft.Crm.Sdk.Messages;
using System; //using System.Collections.Generic; //using System.Text; //using System.ServiceModel; using System.ServiceModel.Description; using Microsoft.Xrm.Sdk.Client; //using Microsoft.Crm.Sdk; using Microsoft.Crm.Sdk.Messages; namespace CrmConsoleApplication2 { public class Program { private static ClientCredentials _clientCreds; private static OrganizationServiceProxy _serviceProxy; public static void Main(string[] args) { _clientCreds = new ClientCredentials(); _clientCreds.Windows.ClientCredential.UserName = "Administrator"; _clientCreds.Windows.ClientCredential.Password = "NotTheRealPassword"; _clientCreds.Windows.ClientCredential.Domain = "PLAYGROUND"; using (_serviceProxy = new OrganizationServiceProxy(new Uri("http://localhost:5555/CRM2011RTM/XRMServices/2011/Organization.svc") , null , _clientCreds , null)) { WhoAmIRequest request = new WhoAmIRequest(); WhoAmIResponse response = (WhoAmIResponse)_serviceProxy.Execute(request); Console.WriteLine("User {0} has just connected", response.UserId); } Console.ReadLine(); } } }
#Use the Sample and Helper Code
No comments:
Post a Comment