I am trying to Connect CRM with a WebService using C#.
But I am getting Error given below:
System.NullReferenceException HResult=0x80004003 Message=Object reference not set to an instance of an object. Source=Microsoft.Xrm.Tooling.Connector StackTrace: at Microsoft.Xrm.Tooling.Connector.CrmWebSvc.get_CrmWebClient() at Microsoft.Xrm.Tooling.Connector.CrmServiceClient.get_OrganizationWebProxyClient() at ContactCreation.ConnectionClass.GetOrganizationServiceClientSecret(String clientId, String clientSecret, String organizationUri) in C:\Users\HamzaHafeez\source\repos\ContactCreation\ContactCreation\ConnectionClass.cs:line 41
Same connection code is working fine on Console and WebApp.
try { IOrganizationService service = GetOrganizationServiceClientSecret("My App ID", "My Secret ID", "https://MyURL/"); if (service != null) { return "weldone"; } return "Done"; } catch (Exception ex) { throw ex; } } public IOrganizationService GetOrganizationServiceClientSecret(string clientId, string clientSecret, string organizationUri) { try { var conn = new CrmServiceClient($@"AuthType=ClientSecret; url={organizationUri}; ClientId={clientId}; ClientSecret={clientSecret}"); return conn.OrganizationWebProxyClient != null ? conn.OrganizationWebProxyClient : (IOrganizationService)conn.OrganizationServiceProxy; } catch (Exception ex) { // Handle the exception here throw ex; } } } }
Please help to solve the Error.Thank You
Abdul Wahab Hi,
My code is working fine on console and web APP. But I am getting Error in Web Service
Hi Hamza Bhatti,
The link: learn.microsoft.com/.../quick-start-org-service-console-app might be the solution to your problem. Please follow.
Stay up to date on forum activity by subscribing. You can also customize your in-app and email Notification settings across all subscriptions.
André Arnaud de Cal... 291,253 Super User 2024 Season 2
Martin Dráb 230,188 Most Valuable Professional
nmaenpaa 101,156