0

添加参考:

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

我得到的错误:

错误 2“CrmService”不包含“Url”的定义,并且找不到接受“CrmService”类型的第一个参数的扩展方法“Url”(您是否缺少 using 指令或程序集引用?)

错误 3“CrmService”不包含“CrmAuthenticationTokenValue”的定义,并且找不到接受“CrmService”类型的第一个参数的扩展方法“CrmAuthenticationTokenValue”(您是否缺少 using 指令或程序集引用?)

错误 4“CrmService”不包含“Credentials”的定义,并且找不到接受“CrmService”类型的第一个参数的扩展方法“Credentials”(您是否缺少 using 指令或程序集引用?)

代码:

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;
        }
    }
}

我在这里忘记了什么?谢谢。

4

2 回答 2

1

我不确定为什么会出现编译错误,但这可能是因为您似乎在混合 Crm 4 和 Crm 2011 dll。

目前尚不清楚您要在这里实现什么,您正在使用 CrmService(Crm 4 类)尝试连接到 2011 端点,我从未尝试过,但我不希望它能够工作。

我猜您正在尝试为 Crm 2011 编写 Web 服务调用,在这种情况下,我建议您看一下:http: //msdn.microsoft.com/en-us/library/gg309557

于 2012-09-08T17:59:16.967 回答
0

我认为您需要添加对“System.Web.Services”的引用才能使其正常工作。

于 2014-06-05T06:37:56.607 回答