web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

Can't connect to CRM any longer using OrganizationServiceProxy, error: Metadata contains a reference that cannot be resolved: 'https://hulten.api.crm4.dynamics.com/XRMServices/2011/Organization.svc?wsdl&sdkversion=82'

(0) ShareShare
ReportReport
Posted on by

Since today I siddenly can't connect to my CRM through my C# application. This jsut worked fine 2 weeks ago but now doesn't. 

I try to connect using this bit of code:

ClientCredentials credentials = new ClientCredentials();
                credentials.UserName.UserName = UserName;
                credentials.UserName.Password = Password;
                Uri serviceUri = new Uri(SoapOrgServiceUri);
                OrganizationServiceProxy proxy = new OrganizationServiceProxy(serviceUri, null, credentials, null);
                proxy.EnableProxyTypes(Assembly.GetExecutingAssembly());
                _service = (IOrganizationService)proxy;


On the line :

OrganizationServiceProxy proxy = new OrganizationServiceProxy(serviceUri, null, credentials, null);

I get the following error: 

ErrorDynamics.png

Additional Info:

  • Microsoft Dynamics 365 version 1612 (9.0.0.3172) (DB 9.0.0.3172) online
  • Microsoft.Xrm.Sdk : Microsoft.CrmSdk.CoreAssemblies.8.2.0\lib\net45\Microsoft.Xrm.Sdk.dll
  • Microsoft.Crm.Sdk.Proxy : Microsoft.CrmSdk.CoreAssemblies.8.2.0\lib\net45\Microsoft.Crm.Sdk.Proxy.dll
  • For connection I used the endpoint defined in Dynamics CRM: Organizationservice Endpoint (found in developer resources)

Posible problems?

  • I had to change my Office 365 password today, I also updated my application to use that new password. When I log into Dynamics online 365 with this new password it works fine, however I tried to regenerate my new entities and that gave me the following error as well:
Microsoft.Xrm.Tooling.Connector.CrmServiceClient Error: 2 : Source      : System.ServiceModel
Method  : Retrieve
Date    : 9-1-2018
Time    : 16:49:47
Error   : Metadata contains a reference that cannot be resolved: 'hulten.api.crm4.dynamics.com/.../Organization.svc;sdkversion=82'.
Stack Trace     : 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 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.CreateManagement[TService](Uri serviceUri, Boolean enableProxyTypes, Assembly assembly)
   at Microsoft.Xrm.Tooling.Connector.CrmWebSvc.CreateAndAuthenticateProxy[T](IServiceManagement`1 servicecfg, Uri ServiceUri, Uri homeRealm, ClientCredentials userCredentials, ClientCredentials deviceCredentials, String LogString)
   at Microsoft.Xrm.Tooling.Connector.CrmWebSvc.ConnectAndInitCrmOrgService(OrganizationDetail orgdata, Boolean IsOnPrem, Uri homeRealmUri)
   at Microsoft.Xrm.Tooling.Connector.CrmWebSvc.InitCRM2011Service()
======================================================================================================================
Inner Exception Level 1 :
Source  : System
Method  : GetResponse
Date    : 9-1-2018
Time    : 16:49:47
Error   : The underlying connection was closed: An unexpected error occurred on a send.
Stack Trace     : at System.Net.HttpWebRequest.GetResponse()
   at System.ServiceModel.Description.MetadataExchangeClient.MetadataLocationRetriever.DownloadMetadata(TimeoutHelper timeoutHelper)
   at System.ServiceModel.Description.MetadataExchangeClient.MetadataRetriever.Retrieve(TimeoutHelper timeoutHelper)
======================================================================================================================
Inner Exception Level 2 :
Source  : System
Method  : Read
Date    : 9-1-2018
Time    : 16:49:47
Error   : Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host.
Stack Trace     : at System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 size)
   at System.Net.FixedSizeReader.ReadPacket(Byte[] buffer, Int32 offset, Int32 count)
   at System.Net.Security.SslState.StartReceiveBlob(Byte[] buffer, AsyncProtocolRequest asyncRequest)
   at System.Net.Security.SslState.CheckCompletionBeforeNextReceive(ProtocolToken message, AsyncProtocolRequest asyncRequest)
   at System.Net.Security.SslState.ForceAuthentication(Boolean receiveFirst, Byte[] buffer, AsyncProtocolRequest asyncRequest)
   at System.Net.Security.SslState.ProcessAuthentication(LazyAsyncResult lazyResult)
   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.ConnectStream.WriteHeaders(Boolean async)
======================================================================================================================
Inner Exception Level 3 :
Source  : System
Method  : Read
Date    : 9-1-2018
Time    : 16:49:47
Error   : An existing connection was forcibly closed by the remote host
Stack Trace     : at System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 size)
======================================================================================================================

Microsoft.Xrm.Tooling.Connector.CrmServiceClient Error: 2 : Unable to Login to Dynamics CRM
Unable to Login to Dynamics CRM

Exiting program with exception: Connection to CRM is not established. Aborting process.
CrmSvcUtil Error: 2 : Exiting program with exit code 2 due to exception : System.Exception: Connection to CRM is not established. Aborting process.
   at Microsoft.Crm.Services.Utility.SdkMetadataProviderService.LoadMetadata(IServiceProvider service)
   at Microsoft.Crm.Services.Utility.CrmSvcUtil.Run()
   at Microsoft.Crm.Services.Utility.CrmSvcUtil.Main(String[] args)
CrmSvcUtil Error: 2 : ===== DETAIL ======
CrmSvcUtil Error: 2 : Source    : CrmSvcUtil
Method  : LoadMetadata
Date    : 16:49:47
Time    : 9-1-2018
Error   : Connection to CRM is not established. Aborting process.
Stack Trace     : at Microsoft.Crm.Services.Utility.SdkMetadataProviderService.LoadMetadata(IServiceProvider service)
   at Microsoft.Crm.Services.Utility.CrmSvcUtil.Run()
   at Microsoft.Crm.Services.Utility.CrmSvcUtil.Main(String[] args)



*This post is locked for comments

I have the same question (0)
  • Verified answer
    Rawish Kumar Profile Picture
    13,758 on at

    Hi Nicolas,

    This has been experienced by many users lately.

    reference post : community.dynamics.com/.../254341

    community.dynamics.com/.../263162

    kindly try suggested method.

    mark my suggestion as verified if helpful.

  • Community Member Profile Picture
    on at

    I thought I searched pretty well on the internet but couldn't find relating issues, probably me using wrong search keywords :) Nonetheless I will try the solutions provided in the 2 other posts! Thank you!

  • James AT Hallstudios Profile Picture
    on at

    I am also getting this issue today.  It also seems to happen using XrmToolbox.  I have recompiled my application with .NET Framework 4.6.2 as suggested, also tried adding in the TLS hack as well, but still nothing.  It seems to work connecting to some CRM systems, but not others.

  • James AT Hallstudios Profile Picture
    on at

    Using Fiddler, it looks like what I am getting back is :

    AADSTS70002: Error validating credentials. AADSTS50126: Invalid username or password

    I know my username/password is correct, so anyone got any ideas whats wrong.  Is it something to do with usernames needing to be enabled for app access or something.

  • Community Member Profile Picture
    on at

    I haven't had the chance yet to test the proposed solution, however, if you are experiencing the same issue as of today / yesterday and the suggested solution is not working for you, then it might be something else? I seems we both got the exact same problem.. 

    Wish I could adjust the question to not answered ;) 

  • Suggested answer
    tw0sh3ds Profile Picture
    5,600 on at

    You should connect like that:

    msdn.microsoft.com/.../jj602970.aspx

    or even better (ways different from connection string)

    https://msdn.microsoft.com/en-us/library/dn688177.aspx

    The way you are trying to connect is really outdated and not supported. Currently the only correct way of connecting to CRM from external apps is using WebAPI or Xrm.Tooling like in the link I provided

  • James AT Hallstudios Profile Picture
    on at

    Thanks Pawel, but, even following those articles, and trying out some of the examples, I am still ultimately getting the error

    AADSTS70002: Error validating credentials. AADSTS50126: Invalid username or password

    And its on this URL that the error occurs :

    login.microsoftonline.com/RST2.srf

    This is even happening on a new Dynamics 365 Trial, without any 2 factor authentication.  The user is an admin, and the account works fine when logging in to the User Interface of Dynamics.

  • tw0sh3ds Profile Picture
    5,600 on at

    Ok but is your application using .NET 4.6.2?

  • Community Member Profile Picture
    on at

    I assume his application is, see his upper post:

    I am also getting this issue today.  It also seems to happen using XrmToolbox.  I have recompiled my application with .NET Framework 4.6.2 as suggested, also tried adding in the TLS hack as well, but still nothing.  It seems to work connecting to some CRM systems, but not others.


  • James AT Hallstudios Profile Picture
    on at

    Thanks, yes, so its .NET Framework 4.6.2, I have also tried it with the TLS12 hack, tried it with old and new methods of using the SDK, it always seems to fail at the same point.  The other day, we did have similar issues where it reported an error similar to the original post, changing the app to 4.6.2 fixed that, but for these environments, its still not working.

    Should I create a new post with my new error that I am getting?

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
SA-08121319-0 Profile Picture

SA-08121319-0 4

#1
Calum MacFarlane Profile Picture

Calum MacFarlane 4

#3
Alex Fun Wei Jie Profile Picture

Alex Fun Wei Jie 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans