简体   繁体   中英

CRM Dynamics - Get service uri from FaultException<OrganizationServiceFault> or IOrganizationService

I'd like to log an error message containing the service uri of the CRM connection in the catch block shown below. How can I get to it?

protected static SystemUser ReallyCreateSystemUser(IOrganizationService service, SystemUser user) {
    try {
       var systemUserId = service.Create(user);
    } catch (FaultException<OrganizationServiceFault> ex) {
        // I want to trace the service uri of the crm connection here
    }
}

The ServiceUri information is contained in the CrmConnection class.

If you are building something like a console application you can create the IOrganizationService from a CrmConnection , for example:

var connection = new CrmConnection("CRMOnline");
var service = new OrganizationService(connection);

So I suggest retrieving the ServiceUri information at that point, for example:

var serviceUri = connection.ServiceUri;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM