none
Connection to Dynamics 365 in C# RRS feed

  • Question

  • 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

    Wednesday, July 10, 2019 12:38 PM

All replies

  • Hi YaraZakaria, 

    Thank you for posting here.

    For your question, Your issue is more related to Dynamics 365 and you have posted the same question on Dynamics 365  Forum. You can ask the person who answered the question  for more help.

    The C# forum is for C# related question, we discuss and ask the C# programming language, IDE, libraries, samples and tools here.

    Thank you for your understanding.

    Best Regards,

    Xingyu Zhao


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Thursday, July 11, 2019 6:11 AM
  • hi Xingyu Zhao

    i'm sorry i wasn't sure where to post it.

    Thank you



    YaraZ

    Thursday, July 11, 2019 7:42 AM