6

What is the proper way to dispose a CoreServiceClient in SDL Web 8.5?

Some great Core Service posts from 2012 and 2013 instruct to check the state, and call Abort() or Close(). The Tridion-PowerShell-Modules project does something similar in Close-TridionCoreServiceClient.

         if (_client.State == CommunicationState.Faulted)
        {
            _client.Abort();
        }
        else
        {
            _client.Close();
        }

However, the Core Service client API has a CoreServiceClient.Dispose() method, which calls ClientHelper.DisposeClient() which does those checks already. Maybe this has changed over time, but I think the API handles this for us.

4

Documentation for 8.5 states that there are two ways for disposal:

  1. Dispose method
  2. Using method

https://docs.sdl.com/LiveContent/content/en-US/SDL%20Web-v5/GUID-CB0DBEF4-3A0D-4389-BAA3-92B1B15D1D35

  • 3
    This is the right answer for Web 8 and later. The PowerShell modules still does it the old way, as it still supports the earlier versions (where Dispose does not abort or close correctly) – Peter Kjaer Aug 22 '18 at 8:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.