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. The program connects to the CRM server, fetches data, and uses the aforementioned early bound classes to manipulate this data.
The core of my problems is based around the connection to the CRM server. 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:
<?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; [email protected]; 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:
- Changing the authentication type to AD, instead of IFD
- Adding a line of code that could negate the Token security check
- Trying to get the code on this page working
- In this one, I don't know what is a relying party though.
- Trying a lot of things around the connection String, all of them don't mess up with the working code, but don't seem to do anything either.
- Removing the Organization Name part in the server connection.
- Removing the /XRMServices/2011/Organization.svc since it's an IFD connection
- Changing the attribute "Url" into "Server" or "ServiceUri"
- Adding "LoginPrompt=Never" at the end of the connection String
- Adding Xrm.Tooling.Connector reference, using CrmServiceClient to connect to the server.
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?