0

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.

4

2 に答える 2

1

コンパイルエラーが発生する理由はわかりませんが、Crm4とCrm2011のdllが混在しているように見えることが原因である可能性があります。

ここで何を達成しようとしているのかは不明です。CrmService(Crm 4クラス)を使用して2011エンドポイントに接続しようとしています。これを試したことはありませんが、うまくいくとは思いません。

Crm 2011のWebサービス呼び出しを作成しようとしていると思います。その場合は、http://msdn.microsoft.com/en-us/library/gg309557を参照することをお勧めします

于 2012-09-08T17:59:16.967 に答える
0

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

于 2014-06-05T06:37:56.607 に答える