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

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

C# Connect to CRM server Exception at some PC Client

(1) ShareShare
ReportReport
Posted on by

Dear All !

I have code Winform C# connect to CRM. But It OK in my computer and window server CRM, It throw exception in orther clients.

help me because I don't know cause of it.

This is my code : 

private void Connect(string server, string org, string domain, string user, string pass)
{
try
{
string url = "http://" + server + "/" + org + "/XRMServices/2011/Organization.svc";
Uri OrganizationUri = new Uri(url);

ClientCredentials Credentials = new ClientCredentials();
Credentials.Windows.ClientCredential = new System.Net.NetworkCredential(user, pass, domain);
serviceProxy = new OrganizationServiceProxy(OrganizationUri, null, Credentials, null);

serviceProxy.EnableProxyTypes();
service = (IOrganizationService)serviceProxy;
CheckConnection();
}
catch (Exception ex)
{
MethodBase method = System.Reflection.MethodBase.GetCurrentMethod();
string fullMethodName = Logfile.getFullMethodNameAndParam(method);
Logfile.Write(fullMethodName, ex.StackTrace, string.Empty);
throw new Exception("Kết nối CRM bị lỗi " + ex.Message);
}

and this is 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 IVG.ConnectCRM.CrmConnector.Connect(String server, String org, String domain, String user, String pass)

*This post is locked for comments

I have the same question (0)

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…

Andrés Arias – Community Spotlight

We are honored to recognize Andrés Arias as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
Aric Levin - MVP Profile Picture

Aric Levin - MVP 2 Moderator

#2
MA-04060624-0 Profile Picture

MA-04060624-0 1

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans