[英]CRM Dynamics SDK 2016 Throwing Error 3242
我一直在研究一個程序,通過電子郵件將有關報價的提醒發送給他人。 該程序使用CRM Dynamics 2016 SDK,並利用了早期綁定的類。 該程序連接到CRM服務器,獲取數據,並使用上述早期綁定類來處理此數據。
我問題的核心在於與CRM服務器的連接。 它的連接類似於以下內容:
var result123 = from r in xrm.QuoteSet where r.kro_QuotationNumber.StartsWith("123") select r;
連接在App.config中配置:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
<section name="microsoft.xrm.client" type="Microsoft.Xrm.Client.Configuration.CrmSection, Microsoft.Xrm.Client" />
</configSections>
<microsoft.xrm.client>
<contexts>
<add name="Xrm" type="Itelios.Crm.Business.Dynamics.XrmServiceContext" />
</contexts>
</microsoft.xrm.client>
<connectionStrings>
<add name="Xrm" connectionString="Server=https://crm.OrganizationName.com/XRMServices/2011/Organization.svc; Domain:OrganizationDomain; authtype=IFD; Username=username@OrganizationDomain.com; Password=password"/>
</connectionStrings>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2" />
</startup>
這是主要功能中的連接代碼:
//To create the contexte, we should create an IOrganizationService
OrganizationServiceProxy serviceproxy = null;
try
{
ServerConnection server = new ServerConnection();
server.ReadConfigurations();
ServerConnection.Configuration config = server.configurations[0];
//config = server.configurations.GetRange(1,1).First<ServerConnection.Configuration>();
serviceproxy = new OrganizationServiceProxy(config.OrganizationUri, config.HomeRealmUri, config.Credentials, config.DeviceCredentials);
}
catch (Exception e)
{
Console.WriteLine(e);
}
serviceproxy.EnableProxyTypes();
IOrganizationService service = (IOrganizationService)serviceproxy;
ServicePointManager.ServerCertificateValidationCallback = delegate { return true; };
//CRM Context Creation
using (var xrm = new Xrm(service)) { etc. }
在我們嘗試從該程序創建可執行文件之前,代碼一直有效,以便可以將其用作計划任務,並從其他服務器運行。 經過幾次嘗試,我得出的結論是我面臨的問題不是由於可執行文件,而是由於計算機的更改。
我嘗試了以下方法:
是否有人對如何解決此錯誤有任何建議,或者對為什么引發此錯誤有深入的了解?
沒關系,我找到了問題的根源。
剛開始使用SDK時,正如我在問題中所說的那樣,我鏈接了CrmServiceHelper。 盡管由於這是一個非常通用的文件,但仍有一些庫需要安裝,尤其是Microsoft.IdentityModel。 目前,我不知道這對我的程序的運行至關重要,因此我只評論了有關安全令牌的部分。
在嘗試將所有內容重新安裝到另一台服務器上時,我發現了相同的錯誤,這一次意識到安全令牌很重要。
長話短說,您只需從Nuget Package Tool Manager導入Microsoft.IdentityModel。
由於此問題與連接功能異常有關,因此我被誘使認為該錯誤來自我的代碼的Connection部分。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.