当我在web.config中更改连接字符串中的用户名,密码和URL的值时,我得到空引用异常。它适用于环境但是当我更改这些值时,我得到错误。
<connectionStrings>
<add name="CRM" connectionString="AuthType=Office365;Url=url; Username=""; Password="" />
</connectionStrings>
以下是连接代码:
public class get
{
private CrmServiceClient crmSvc = null;
private IOrganizationService crmService = null;
public get()
{
this.crmSvc = new CrmServiceClient(ConfigurationManager.ConnectionStrings["CRM"].ConnectionString);
this.crmService = this.crmSvc.OrganizationServiceProxy;
}
}
答案 0 :(得分:1)
你可以添加一个断点并检查this.crmSvc.LastCrmError
和this.crmSvc.LastCrmException
这些可能会给你一些关于出错的小线索
如果您要从CRM 8.0迁移到CRM 9.0,请确保您已完成以下操作:
以下是强制您的代码使用TLS 1.2的方法:
public class get
{
private CrmServiceClient crmSvc = null;
private IOrganizationService crmService = null;
public get()
{
// New line to force TLS 1.2
System.Net.ServicePointManager.SecurityProtocol = System.Net.SecurityProtocolType.Tls12;
this.crmSvc = new CrmServiceClient(ConfigurationManager.ConnectionStrings["CRM"].ConnectionString);
this.crmService = this.crmSvc.OrganizationServiceProxy;
}
}
这是我的blog,其中包含相同的步骤和更多文档:)