首页 新闻 搜索 专区 学院

ASP.NET 5错误:Unable to resolve service for type 'Microsoft.Extensions.Logging.ILogger'

0
[已解决问题] 解决于 2015-11-28 16:35

在一个类的构造函数使用ILogger接口:

public class EnyimMemcached : IMemcached
{
    public EnyimMemcached(ILogger logger)
    {
    }
}

运行时却出现下面的错误:

[Error] An unhandled exception has occurred:
Unable to resolve service for type 'Microsoft.Extensions.Logging.ILogger' while attempting to activate 'CNBlogs.Infrastructure.Caching.EnyimMemcached'.
System.InvalidOperationException:
Unable to resolve service for type 'Microsoft.Extensions.Logging.ILogger' while attempting to activate 'CNBlogs.Infrastructure.Caching.EnyimMemcached'.

dudu的主页 dudu | 高人七级 | 园豆:38849
提问于:2015-11-28 13:28
< >
分享
最佳答案
1

将ILogger改为ILogger<EnyimMemcached>之后,问题解决。

public class EnyimMemcached : IMemcached
{
    public EnyimMemcached(ILogger<EnyimMemcached> logger)
    {
    }
}
dudu | 高人七级 |园豆:38849 | 2015-11-28 16:34
其他回答(1)
0

感谢大佬,刚刚看了一下,发现少了一个I

程铭 | 园豆:202 (菜鸟二级) | 2020-09-08 13:17
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册