0

我正在尝试通过 WCF Web 服务从 Windows azure worker 角色连接到本地 CRM 2011。我创建了一个 WCF 网络服务。但是在运行应用程序时,它显示错误为“Inconsistent accessibility: field type SampleData_WcfService.OrganizationServiceProxy' is less accessible than field 'SampleData_WcfService.Service1._SDKObject".我已将代码编写为

namespace SampleData_WcfService
{
    public class Service1 : IService1
    {
    public static OrganizationServiceProxy _SDKObject;
       public bool CRMCall()
        {
            try
            {
                if (!CRM_Connection("http://orgname/dattgtdev/XRMServices/2011/Organization.svc", "false", "user2", "pwd", "domain"))
                    return false;

                Entity _entity = new Entity();
                _entity.LogicalName = "account";
                _entity.Attributes.Add(new KeyValuePair<string, object>("name", "Testing123456787"));

               _SDKObject.Create(_entity);
                return true;
            }
            catch (Exception ex)
            {
                return false;
                           }
        }

  public bool CRM_Connection(string WebServiceURL, string Authentication, string UserName, string Password,string DomainName)
        {
            try
            {
                Uri organizationUri = new Uri(WebServiceURL);
                Uri homeRealmUri = null;
               System.ServiceModel.Description.ClientCredentials credentials = new System.ServiceModel.Description.ClientCredentials();
                if (Authentication == "false")
                {
                    credentials.Windows.ClientCredential = new System.Net.NetworkCredential(UserName, Password, DomainName);
                }

                _SDKObject = new OrganizationServiceProxy(organizationUri, homeRealmUri, credentials, null);

                return true;
            }
            catch (Exception ex)
            {
                return false;
            }
        }
    }
 }

这段代码有什么问题??

4

1 回答 1

4

_SDKObject是公开的,而OrganizationServiceProxy课程很可能是内部的。使类访问器公开,或使_SDKObject声明不易访问,如内部、受保护或私有。

于 2012-07-26T14:35:07.777 回答