November Happy Hour will be moved to Thursday December 5th.

System.InvalidOperationException on ImageServiceClient

Vote:
 

I use EPiServer.ImageLibrary ImageServiceClient RenderImage method to render a cropped image. This was the code before upgrade to EPiServer CMS 11.5 and this was working fine.

var imageService = new ImageServiceClient("ImageServiceClientEndPoint");

After the upgrade, this code shows a compile error;

'ImageServiceClient.ImageServiceClient(string)' is obsolete: 'Use constructor that takes options instead, read options from container' 

Accordingly, I changed the code as follows;

ImageServiceOptions options = new ImageServiceOptions();
options.ClientEndpoint = "ImageServiceClientEndPoint";
var imageService = new ImageServiceClient(options);

Then I was able to compile successfully. But now this throws this exception;

System.InvalidOperationException: 'Could not find endpoint element with name 'ImageServiceClientEndPoint' and contract 'EPiServer.ImageLibrary.IImageService' in the ServiceModel client configuration section. This might be because no configuration file was found for your application, or because no endpoint element matching this name could be found in the client element.'

What have I done wrong here? 

#190803
Edited, Apr 17, 2018 11:40
Vote:
 

Hi Helani,

Do you have something like the following in your web.config:

<system.serviceModel>
   <client>
      <endpoint name="ImageServiceClientEndPoint"
                address="net.tcp://serverxyz:8000/ImageService"
                binding="netTcpBinding"
                bindingConfiguration="ImageServiceBinding"
                contract="EPiServer.ImageLibrary.IImageService" />
   </client>
   <bindings>
      <netTcpBinding >
         <binding name="ImageServiceBinding" maxReceivedMessageSize="20000000">
            <readerQuotas maxArrayLength="20000000" />
            <security mode="None">
            </security>
         </binding>
      </netTcpBinding >
   </bindings>
</system.serviceModel>
#190830
Apr 17, 2018 15:13
Vote:
 

Hi Paul,

Thanks for the reply. I added this endpoint configuration to web.config and now the System.InvalidOperationException is fixed. 

However the imageService.RenderImage() method now returns a null. 

byte[] newImageBuffer = imageService.RenderImage(imageBuffer, operations, imageMimeType, zoomFactor, 100);

This method correctly worked when using the ImageServiceClient("ImageServiceClientEndPoint") constructor before EPiServer upgrade. Am I missing something?

#190872
Apr 18, 2018 6:17
Vote:
 

Hi Helani,

Do you also have the image service itself configured in <system.serviceModel>?

<services>
    <service name="EPiServer.ImageLibrary.ImageService">
        <endpoint address="net.tcp://serverxyz:8000/ImageService"
                   binding="netTcpBinding"
                   bindingConfiguration="ImageServiceBinding"
                   contract="EPiServer.ImageLibrary.IImageService" /> 
    </service>
</services>
#190883
Apr 18, 2018 10:46
Vote:
 

No. Now I added ImageService configuration as well.

But the RenderImage() method still returns a null. 

#190885
Apr 18, 2018 11:21
Vote:
 

Any error message in the logs?

Try iisreset.

#191093
Apr 19, 2018 23:46
Vote:
 

The setting ClientEndpoint property on ImageServiceOptions is to be used if you want to host the ImageService in another application/process as your web application, in that case you need to specify an endpoint in web.config as stated before. You can also (which is the default behavior) run the image service in-process then you just leave the ClientEndpoint property empty/null on then imageServiceOptions class. 

#191113
Apr 20, 2018 9:12
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.