可访问性不一致:字段类型

时间:2012-07-26 14:31:22

标签: c# dynamics-crm-2011 azure-worker-roles

我正在尝试通过Windows Azure服务角色到WCF Web服务连接到CRM 2011。我创建了一个WCF Web服务。但是在运行应用程序时,它显示错误为“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;
            }
        }
    }
 }

这段代码怎么了?

1 个答案:

答案 0 :(得分:4)

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