我正在尝试通过 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;
}
}
}
}
这段代码有什么问题??