Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics CRM (Archived)

C# Connect to CRM server Exception at some PC Client

Posted on by Microsoft Employee

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

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,269 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,198 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans