dependency-injection - Sitecore XConnect : an error occurred when trying to create a controller of type 'ContactsController'

标签 dependency-injection sitecore

我在 Sitecore 9 更新 1 中调用我的 xConnect 客户端时遇到问题。
客户端对象的初始化运行良好。
但是当我在客户端调用一个方法时,我得到这个异常:


{
    "Message":"An error has occurred.",
    "ExceptionMessage":"An error occurred when trying to create a controller of type 'ContactsController'. Make sure that the controller has a parameterless public constructor.",
    "ExceptionType":"System.InvalidOperationException",
    "StackTrace":"   at System.Web.Http.Dispatcher.DefaultHttpControllerActivator.Create(HttpRequestMessage request, HttpControllerDescriptor controllerDescriptor, Type controllerType)
   at Sitecore.XConnect.Web.DependencyInjection.WebApiServiceControllerActivator.Create(HttpRequestMessage request, HttpControllerDescriptor controllerDescriptor, Type controllerType)
   at System.Web.Http.Controllers.HttpControllerDescriptor.CreateController(HttpRequestMessage request)
   at System.Web.Http.Dispatcher.HttpControllerDispatcher.d__1.MoveNext()",
    "InnerException":{
        "Message":"An error has occurred.",
        "ExceptionMessage":"Type 'Sitecore.XConnect.Web.Controllers.ContactsController' does not have a default constructor",
        "ExceptionType":"System.ArgumentException",
        "StackTrace":"   at System.Linq.Expressions.Expression.New(Type type)
       at System.Web.Http.Internal.TypeActivator.Create[TBase](Type instanceType)
       at System.Web.Http.Dispatcher.DefaultHttpControllerActivator.GetInstanceOrActivator(HttpRequestMessage request, Type controllerType, Func`1& activator)
       at System.Web.Http.Dispatcher.DefaultHttpControllerActivator.Create(HttpRequestMessage request, HttpControllerDescriptor controllerDescriptor, Type controllerType)"}}

最佳答案

  • 检查证书是否具有 MMC 中 xconnect 应用程序池的托管私钥
  • 如果第一点现在不起作用,请尝试执行 power shell 命令:
  • Get-Childitem cert:\LocalMachine\root -Recurse | Where-Object {$_.Issuer -ne $_.Subject} | Move-Item -Destination Cert:\LocalMachine\CA
  • 如果第二点不起作用,请检查以下两个服务是否正在运行:
    enter image description here
  • 关于dependency-injection - Sitecore XConnect : an error occurred when trying to create a controller of type 'ContactsController' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48302183/

    相关文章:

    .net - 将 InterceptionBehaviour 添加到 IoC 容器中注册的所有内容

    javascript - 站点核心 "Uncaught ReferenceError: MultilistWithSearch is not defined"

    c# - 为什么 IOC 容器被认为是一种减少耦合的方式?

    spring - Spring 社交展示示例的 Autowire 环境接口(interface)始终返回 NULL

    ios - Sitecore 媒体库与 iOS 不兼容?

    Sitecore渲染数据源: Filter immediate children

    api - 当我以编程方式更新/添加内容时,内容编辑器未在 Sitecore 中更新

    solr - Sitecore _path 字段在 Solr 索引中返回 NULL

    Startup.Configure 中的 ASP.NET Core 依赖注入(inject)

    android - 在我的例子中,Dagger 在模块中声明子组件