Connection to Dynamics 365 in C#

  • Thread starter Thread starter YaraZakaria
  • Start date Start date
Y

YaraZakaria

Guest
Hi,

I am using C# to connect to Dynamics 365. I used the same code and it works for one instance and not for another one. I get the following error : "ID3007: The element 'pp' with namespace 'http://schemas.microsoft.com/Passport/SoapServices/SOAPFault' is unrecognized."


The code is the following

namespace ConnectToCRM {
class Program {
static void Main(string[] args) {

try
{
IOrganizationService organizationService = null;

ClientCredentials clientCredentials = new ClientCredentials();
clientCredentials.UserName.UserName = "y@MyDomain.onmicrosoft.com";
clientCredentials.UserName.Password ="MyPass";

// For Dynamics 365 Customer Engagement V9.X, set Security Protocol as TLS12
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
// Get the URL from CRM, Navigate to Settings -> Customizations -> Developer Resources
// Copy and Paste Organization Service Endpoint Address URL
organizationService = (IOrganizationService)new OrganizationServiceProxy(new Uri("https://MyDomain.api.crm12.dynamics.com/XRMServices/2011/Organization.svc"),
null, clientCredentials, null);

if (organizationService != null)
{
Guid userid = ((WhoAmIResponse)organizationService.Execute(new WhoAmIRequest())).UserId;

if (userid != Guid.Empty)
{
Console.WriteLine("DOTNET 2015 : Connection Established Successfully...");
}

}
else
{
Console.WriteLine("DOTNET 2015 : Failed to Established Connection!!!");
}
}
catch (Exception ex)
{
Console.WriteLine("DOTNET 2015 : Exception caught - " + ex.Message);

}
Console.ReadKey();



}
}
}


I have the "Microsoft.CrmSdk.CoreAssemblies" package installed V 9.0.2.12 and targeting the .NET Framework 4.7.2.

the first instance in CRM that works fine with my code is a free trial with Server version: 9.1.0000.6227

the second instance that is giving me the error is another free trial with Server version: 9.1.0000.6421





YaraZ

Continue reading...
 
Back
Top