Quantcast
Channel: Microsoft Dynamics CRM Forum - Recent Threads
Viewing all articles
Browse latest Browse all 55831

Console app for MS Dynamics CRM

$
0
0

I am using late binding to  connect to MS CRM using console application. My program.cs file looks like this

class Program
{
private static OrganizationServiceProxy _serviceProxy;
private static ClientCredentials _clientCreds;


static void Main(string[] args)
{
// Setup credential
_clientCreds = new ClientCredentials();
_clientCreds.Windows.ClientCredential.UserName = "userName";
_clientCreds.Windows.ClientCredential.Password = "Password";
_clientCreds.Windows.ClientCredential.Domain = "Domain";

Uri URL = new Uri("servername/.../Organization.svc");
// Connect to Crm WCF endpoint
using (_serviceProxy = new OrganizationServiceProxy(URL, null, _clientCreds, null))
{
OrganizationServiceContext orgContext = new OrganizationServiceContext(_serviceProxy);

WhoAmIRequest request = new WhoAmIRequest();
WhoAmIResponse response = (WhoAmIResponse)orgContext.Execute(request);
Console.WriteLine("Your Crm user Guid is {0}", , response.UserId);
Console.Read();

Can someone help me on what should I put in my app.config file. Everytime I run the program it gives me below error:

The type initializer for 'System.ServiceModel.Diagnostics.TraceUtility' threw an exception.


Viewing all articles
Browse latest Browse all 55831

Trending Articles