[英]CRM Dynamics SDK 2016 Throwing Error 3242
I have been working on a few weeks on a program to e-mail reminders about quotes. 我一直在研究一个程序,通过电子邮件将有关报价的提醒发送给他人。 The program uses the CRM Dynamics 2016 SDK, leveraging early bound classes.
该程序使用CRM Dynamics 2016 SDK,并利用了早期绑定的类。 The program connects to the CRM server, fetches data, and uses the aforementioned early bound classes to manipulate this data.
该程序连接到CRM服务器,获取数据,并使用上述早期绑定类来处理此数据。
The core of my problems is based around the connection to the CRM server. 我问题的核心在于与CRM服务器的连接。 It is connecting similar to the below:
它的连接类似于以下内容:
var result123 = from r in xrm.QuoteSet where r.kro_QuotationNumber.StartsWith("123") select r;
The connection is configured in App.config: 连接在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>
Here is the code of the connection in the main fonction : 这是主要功能中的连接代码:
//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. }
The code was working until we tried to create a executable file from this program, so that it could be utilized as a schedule task, and be run from a different server. 在我们尝试从该程序创建可执行文件之前,代码一直有效,以便可以将其用作计划任务,并从其他服务器运行。 With a few tries, I conclude the problem I was facing wasn't due to the executable file, but due to the computer change.
经过几次尝试,我得出的结论是我面临的问题不是由于可执行文件,而是由于计算机的更改。
I tried the following: 我尝试了以下方法:
The error is happening right after fetching the data I've searched for with the request. 提取我随请求搜索的数据后,错误就发生了。
Does anyone have advice on how to resolve this error, or perhaps insight into why it is being thrown? 是否有人对如何解决此错误有任何建议,或者对为什么引发此错误有深入的了解?
Nevermind, I found the root of my problems. 没关系,我找到了问题的根源。
When I first started to use the SDK, I linked CrmServiceHelper as I said in my question. 刚开始使用SDK时,正如我在问题中所说的那样,我链接了CrmServiceHelper。 Although, since it was a very generic file, there was some libraries to install, especially Microsoft.IdentityModel.
尽管由于这是一个非常通用的文件,但仍有一些库需要安装,尤其是Microsoft.IdentityModel。 At this time, I didn't know it would be something crucial for my program to run, so I just commented the part concerning the Security Token.
目前,我不知道这对我的程序的运行至关重要,因此我只评论了有关安全令牌的部分。
While trying to re-install everything in another server, I found this the same bug, this time aware that Security Tokens were important. 在尝试将所有内容重新安装到另一台服务器上时,我发现了相同的错误,这一次意识到安全令牌很重要。
Long story short, you have just to import Microsoft.IdentityModel from Nuget Package Tool Manager. 长话短说,您只需从Nuget Package Tool Manager导入Microsoft.IdentityModel。
Since this problem was very related to connection disfunctionments, I was lured into thinking the bug was coming from the Connection part of my code. 由于此问题与连接功能异常有关,因此我被诱使认为该错误来自我的代码的Connection部分。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.