title: Dynamics 365 on premise exception Metadata contains a reference that cannot be resolved:
body: <p>Try to debug my console app from yesterday but no success. My script keep throwing: </p>
  
  <p><strong>Metadata contains a reference that cannot be resolved: '<a href="https://xxxxxxx/XRMServices/2011/Organization.svc?wsdl&amp;sdkversion=8.2" rel="nofollow noreferrer">https://xxxxxxx/XRMServices/2011/Organization.svc?wsdl&amp;sdkversion=8.2</a>'.</strong></p>
  
  <p><strong>xxxxxxx is place holder for my crm domain.</strong></p>
  
  <p>I m using Dynamics 365 on premise version 1612(8.2.0.749)(DB 8.2.0.749). The Dynamics 365 was IFD.</p>
  
  <p>To create console app,  I already,</p>
  
  <p>1) Using latest dynamics  365 Sdk version 8.2.1.1 <a href="https://www.microsoft.com/en-us/download/details.aspx?id=50032" rel="nofollow noreferrer">Microsoft Dynamics 365 SDK</a></p>
  
  <p>2) Yeah, also install this sdk into my GAC. Then reboot my server.</p>
  
  <p>3) To check wether my organization service endpoint is correct, I also paste my OrganizationService endpoint address <code>https://xxxxxxx/XRMServices/2011/Organization.svc</code> in browser and its working by return the service.**</p>
  
  <p>4) I m using Visual studio 2013, .net framework 4.5.2</p>
  
  <p>weird things when using Dynamics 365 online trial its working fine.</p>
  
  <p>This is my sample code:</p>
  
  <pre><code>static void Main(string[] args)
          {
  
              IOrganizationService organizationservice;
              // Get the CRM connection string and connect to the CRM Organization
  
              ClientCredentials Credentials = new ClientCredentials();
              Credentials.UserName.UserName = "username";
              Credentials.UserName.Password = "password";
  
              Credentials.Windows.ClientCredential = System.Net.CredentialCache.DefaultNetworkCredentials;
  
              organizationservice = new OrganizationServiceProxy(
                  new Uri("https://xxxxxxx/XRMServices/2011/Organization.svc"), null, Credentials, null);
  
          }
  </code></pre>
  
  <p>Exception throw:
  <a href="https://i.stack.imgur.com/QZRiZ.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/QZRiZ.png" alt="Exception throw:"></a></p>
  
  <p>Details:</p>
  
  <pre><code>System.InvalidOperationException was unhandled
  HResult=-2146233079
  Message=Metadata contains a reference that cannot be resolved: 
  'https://xxxxxxx/XRMServices/2011/Organization.svc?wsdl&amp;sdkversion=8.2'.
  Source=System.ServiceModel
  StackTrace:
     at System.ServiceModel.Description.MetadataExchangeClient.MetadataRetriever.Retrieve(TimeoutHelper timeoutHelper)
     at System.ServiceModel.Description.MetadataExchangeClient.ResolveNext(ResolveCallState resolveCallState)
     at System.ServiceModel.Description.MetadataExchangeClient.GetMetadata(MetadataRetriever retriever)
     at System.ServiceModel.Description.MetadataExchangeClient.GetMetadata(Uri address, MetadataExchangeClientMode mode)
     at Microsoft.Xrm.Sdk.Client.ServiceMetadataUtility.RetrieveServiceEndpointMetadata(Type contractType, Uri serviceUri, Boolean checkForSecondary)
     at Microsoft.Xrm.Sdk.Client.ServiceConfiguration`1..ctor(Uri serviceUri, Boolean checkForSecondary)
     at Microsoft.Xrm.Sdk.Client.OrganizationServiceConfiguration..ctor(Uri serviceUri, Boolean enableProxyTypes, Assembly assembly)
     at Microsoft.Xrm.Sdk.Client.ServiceConfigurationFactory.CreateConfiguration[TService](Uri serviceUri, Boolean enableProxyTypes, Assembly assembly)
     at Microsoft.Xrm.Sdk.Client.ServiceConfigurationFactory.CreateConfiguration[TService](Uri serviceUri)
     at Microsoft.Xrm.Sdk.Client.ServiceProxy`1..ctor(Uri uri, Uri homeRealmUri, ClientCredentials clientCredentials, ClientCredentials deviceCredentials)
     at Microsoft.Xrm.Sdk.Client.OrganizationServiceProxy..ctor(Uri uri, Uri homeRealmUri, ClientCredentials clientCredentials, ClientCredentials deviceCredentials)
     at ConsoleConnectToCRM.Program.Main(String[] args) in d:\CRM2015\SSIS\TestCRMConnection\TestCRMConnection\Program.cs:line 45
     at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
     at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
     at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
     at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
     at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
     at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
     at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
     at System.Threading.ThreadHelper.ThreadStart()
     InnerException: System.Net.WebException
     HResult=-2146233079
     Message=The underlying connection was closed: An unexpected error occurred on a receive.
     Source=System
     StackTrace:
          at System.Net.HttpWebRequest.GetResponse()
          at System.ServiceModel.Description.MetadataExchangeClient.MetadataLocationRetriever.DownloadMetadata(TimeoutHelper timeoutHelper)
          at System.ServiceModel.Description.MetadataExchangeClient.MetadataRetriever.Retrieve(TimeoutHelper timeoutHelper)
     InnerException: System.ComponentModel.Win32Exception
          HResult=-2147467259
          Message=The client and server cannot communicate, because they do not possess a common algorithm
          Source=System
          ErrorCode=-2147467259
          NativeErrorCode=-2146893007
          StackTrace:
               at System.Net.SSPIWrapper.AcquireCredentialsHandle(SSPIInterface SecModule, String package, CredentialUse intent, SecureCredential scc)
               at System.Net.Security.SecureChannel.AcquireCredentialsHandle(CredentialUse credUsage, SecureCredential&amp; secureCredential)
               at System.Net.Security.SecureChannel.AcquireClientCredentials(Byte[]&amp; thumbPrint)
               at System.Net.Security.SecureChannel.GenerateToken(Byte[] input, Int32 offset, Int32 count, Byte[]&amp; output)
               at System.Net.Security.SecureChannel.NextMessage(Byte[] incoming, Int32 offset, Int32 count)
               at System.Net.Security.SslState.StartSendBlob(Byte[] incoming, Int32 count, AsyncProtocolRequest asyncRequest)
               at System.Net.Security.SslState.ForceAuthentication(Boolean receiveFirst, Byte[] buffer, AsyncProtocolRequest asyncRequest)
               at System.Net.Security.SslState.ProcessAuthentication(LazyAsyncResult lazyResult)
               at System.Net.TlsStream.CallProcessAuthentication(Object state)
               at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
               at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
               at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
               at System.Net.TlsStream.ProcessAuthentication(LazyAsyncResult result)
               at System.Net.TlsStream.Write(Byte[] buffer, Int32 offset, Int32 size)
               at System.Net.PooledStream.Write(Byte[] buffer, Int32 offset, Int32 size)
               at System.Net.ConnectStream.WriteHeaders(Boolean async)
          InnerException: 
  </code></pre>
  
  <p>Thanks in advance.</p>