我试图在没有依赖注入的Kentico项目中使用他们的DeliveryClient调用Kentico。这个项目想要迁移到肯特,但希望在转换之前用Kontent实现精练项目中的一个新特性。
在安装之后,下面是我的代码
var clientTest = DeliveryClientBuilder.WithProjectId("MyProjectId").Build();我得到一个运行时错误
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.'显然,这个项目没有依赖注入,我听说在门户项目中设置它是困难的,如果不是不可能的话。因此,我决定像Kentico的博客帖子中所概述的那样,更新我自己的交付客户端。
var test = new DeliveryClient(options);但是DeliveryClient被标记为内部:'DeliveryClient' is inaccessible due to its protection level
我该怎么做?
详细信息
发布于 2020-03-12 20:24:28
实际的问题很愚蠢。我已经在另一个项目中安装了,并且只在这个项目中引用了它。为这个项目安装它解决了这个问题。我现在可以打电话给建筑商了,没有任何错误。
发布于 2020-03-12 19:07:44
虽然Kentico.Kontent.Delivery 12.*的目标是netstandard2.0 (这意味着它是应该与.NET框架4.6.1兼容 ),但是存在这样的设置可能导致问题的证物。在尝试其他东西之前,有几件事我想推荐:
<PropertyGroup>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<GenerateBindingRedirectsOutputType>true</GenerateBindingRedirectsOutputType>
</PropertyGroup>无论如何实例化/注册DeliveryClient (DeliveryClientBuilder services.AddDeliveryClient()),SDK总是在内部使用Microsoft.Extensions.DependencyInjection,因此没有解决办法。您需要解决程序集绑定问题。
https://stackoverflow.com/questions/60657260
复制相似问题