Search code examples
c#kenticokentico-kontent

Kentico Kontent DeliveryClient.Build in Kentico Portal could not load file or assembly Microsoft.Extensions.DependencyInjection


I am attempting to call Kentico Kontent using their DeliveryClient in a Kentico Portal project that doesn't have dependency injection. This project would like to migrate to Kontent but would like a new feature in the extisting project to be implemented with Kontent before the transition.

After installing the Kontent Delivery SDK, here's my code

var clientTest = DeliveryClientBuilder.WithProjectId("MyProjectId").Build();

I get a runtime error

System.IO.FileNotFoundException: 'Could not load file or assembly 'Microsoft.Extensions.DependencyInjection, Version=2.1.1.0, Culture=neutral, PublicKeyToken=adb9793829ddae60' or one of its dependencies. The system cannot find the file specified.'

Obviously, this project doesn't have dependency injection and I hear setting it up in a portal project is difficult if not impossible. So I decide to new up my own delivery client as outlined in Kentico's blog post

var test = new DeliveryClient(options);

But DeliveryClient is marked internal: 'DeliveryClient' is inaccessible due to its protection level

How do I proceed?

Details

  • Kentico.Kontent.Delivery 12.3.0
  • Kentico version 12.0.22
  • .Net Framework 4.6.1

Solution

  • The actual issue was much dumber. I had installed the Kontent Delivery Client nuget sdk in another project and only referenced it in this one. Installing it for this project solved the problem. I am able to call the builder without any errors now.