0
votes

Added references:

  • microsoft.crm.sdk.dll
  • microsoft.crm.sdk.proxy.dll
  • microsoft.xrm.sdk.dll

Errors i get:

Error 2 'CrmService' does not contain a definition for 'Url' and no extension method 'Url' accepting a first argument of type 'CrmService' could be found (are you missing a using directive or an assembly reference?)

Error 3 'CrmService' does not contain a definition for 'CrmAuthenticationTokenValue' and no extension method 'CrmAuthenticationTokenValue' accepting a first argument of type 'CrmService' could be found (are you missing a using directive or an assembly reference?)

Error 4 'CrmService' does not contain a definition for 'Credentials' and no extension method 'Credentials' accepting a first argument of type 'CrmService' could be found (are you missing a using directive or an assembly reference?)

Code:

using System;
using System.Collections.Generic;
using System.Text;
using System.Net;
using System.Security;
using System.Runtime.InteropServices;
using Microsoft.Crm.Sdk;
using System.Xml;

public partial class _Default : System.Web.UI.Page
{
    public CrmService service;

    protected void Page_Load(object sender, EventArgs e)
    {

    }

    protected void id_Click(object sender, EventArgs e)
    {
         string server = "192.168.1.50";
         string domain = "domain";
         string org = "organization";
         string username = "user1\\crm.bdm";
         string password = "user1secret";

         NetworkCredential cred = new NetworkCredential();
         cred.Domain = domain;
         cred.UserName = username;
         cred.Password = password;

         CrmAuthenticationToken token = new CrmAuthenticationToken();
         token.AuthenticationType = 0;
         token.OrganizationName = org;

         service = new CrmService();
         service.Url = "http://192.168.1.50/airflights/XRMServices/2011/Organization.svc";
         service.CrmAuthenticationTokenValue = token;
         service.Credentials = cred;

         cred = null;
    }

    public CrmService Service
    {
        get
        {
            return service;
        }
    }
}

What am I forgetting here ? Thanks.

2

2 Answers

1
votes

I'm not certain why are getting compile errors, but it might because you appear to be mixing the Crm 4 and Crm 2011 dlls.

It's unclear what you are trying to achieve here, you are using CrmService (a Crm 4 class) to try and connect to a 2011 endpoint, I've never tried this but I wouldnt expect that to work.

I'm going to guess you are trying to write web service calls for Crm 2011, in which case I would suggest having a look at this: http://msdn.microsoft.com/en-us/library/gg309557

0
votes

I think you needs to add a reference to "System.Web.Services" to make it work.