我正在尝试连接到 MS Dynamics 2011 Online。在我的代码的 using xrm 部分,我收到此错误:
值“Xrm.XrmServiceContext, Xrm”未被识别为有效类型或不是“Microsoft.Xrm.Sdk.Client.OrganizationServiceContext”类型。
这是我的代码:
var contextName = "Xrm";
using (var xrm = CrmConfigurationManager.CreateContext(contextName) as XrmServiceContext)
{
WriteExampleContacts(xrm);
//Create a new contact called Allison Brown.
var allisonBrown = new Xrm.Contact
{
FirstName = "Allison",
LastName = "Brown",
Address1_Line1 = "23 Market St.",
Address1_City = "Sammamish",
Address1_StateOrProvince = "MT",
Address1_PostalCode = "99999",
Telephone1 = "12345678",
EMailAddress1 = "allison.brown@example.com"
};
xrm.AddObject(allisonBrown);
xrm.SaveChanges();
WriteExampleContacts(xrm);
}
应用程序配置:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
<section name="microsoft.xrm.client" type="Microsoft.Xrm.Client.Configuration.CrmSection, Microsoft.Xrm.Client"/>
</configSections>
<connectionStrings>
<add name="Xrm"
connectionString="Url=https://MYORG.crm.dynamics.com/XRMServices"/>
</connectionStrings>
<microsoft.xrm.client>
<contexts>
<add name="Xrm" type="Xrm.XrmServiceContext, Xrm"/>
</contexts>
</microsoft.xrm.client>
</configuration>
Xrm.XrmServiceContext 是我的实际 XrmServiceContext 名称。它保存在我的控制台应用程序的 Xrm.cs 文件中。