我为此搜索了原因,但找不到任何原因。
我试图创建一个类型为“可调用”的类型化属性。但是 PHP 给了我一个致命错误“不能有可调用的类型”。在 RFC 中,没有提到 callable 不是属性类型提示所允许的类型。相反,有一些示例,其中使用“可调用”作为类型属性。
请参阅:https : //wiki.php.net/rfc/typed-properties
这是什么原因?网上有关于这个话题的讨论吗?
我正在尝试在基于 .NET Core 2.1 的 C# 控制台应用程序中登录并运行。
我在 DI 声明中添加了以下代码:
var sc = new ServiceCollection();
sc.AddLogging(builder =>
{
builder.AddFilter("Microsoft", LogLevel.Warning);
builder.AddFilter("System", LogLevel.Warning);
builder.AddFilter("Program", LogLevel.Warning);
builder.AddConsole();
builder.AddEventLog();
});
Run Code Online (Sandbox Code Playgroud)
我试图通过在服务Microsoft.Extensions.Logging.ILogger的构造函数中使用接口来注入服务,但出现以下错误:
未处理的异常:System.InvalidOperationException:尝试激活“MyService”时无法解析“Microsoft.Extensions.Logging.ILogger”类型的服务。
at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteFactory.CreateArgumentCallSites(Type serviceType, Type implementationType, CallSiteChain callSiteChain, ParameterInfo[] parameters, Boolean throwIfCallSiteNotFound)
at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteFactory.CreateConstructorCallSite(ResultCache lifetime, Type serviceType, Type implementationType, CallSiteChain callSiteChain)
at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteFactory.TryCreateExact(ServiceDescriptor descriptor, Type serviceType, CallSiteChain callSiteChain, Int32 slot)
at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteFactory.TryCreateExact(Type serviceType, CallSiteChain callSiteChain)
at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteFactory.CreateCallSite(Type serviceType, CallSiteChain callSiteChain)
at System.Collections.Concurrent.ConcurrentDictionary`2.GetOrAdd(TKey key, Func`2 valueFactory)
at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteFactory.CreateArgumentCallSites(Type serviceType, Type implementationType, …Run Code Online (Sandbox Code Playgroud)