如何在linqpad中获取.NET核心默认服务集合
我在Visual Studio中使用.NET 6创建一个Azure功能,并且我使用AutoFac进行依赖注入,并且所有功能都很好,
但是,当我想在linqpad中使用解决方案的某些功能时,我会引用DLL文件, 但是我有一些类,这些类别在constructor  from nbsp; iConfiguration和  ilogger等中都有参数,默认情况下是在.NET中添加到.NET中的服务集合中的,但是当我从Linqpad中使用它,因此IT in collection in Collection i,所以I,所以I,所以I,所以I,所以I,所以I,所以I,所以I in Collection i,所以I通过解决服务获得例外
'autofac.core.activators.reflection.defaultConstructorfinder'type'my class'''都无法使用“ autofac.core.activators.defaultconstructorfinder”找到的一个构造函数。 无法解析参数'microsoft.extensions.configuration.iconfiguration config's构造器'void .ctor(microsoft.extensions.configuration.iconfiguration.iconfiguration,system.func'2 [system.boolean,system.boolean,restsharp.restrequest]'。
>
如果有人可以帮助我
var builder = new ContainerBuilder();
builder.RegisterType<RestApiRequsts>().As<IRestApiRequsts>().SingleInstance();
var scope = builder.Build();
var restapirequests = scope.Resolve<IRestApiRequsts>();
获得.NET默认服务&nbsp;在linqpad中
i create a azure function with .net 6 in visual studio and i use autofac for dependency injection and all works fine,
but when i want to use some functions from the solution in linqpad i make reference to the dll files,
but i have some classes that have parameters in the constructor from IConfiguration and ILogger etc., that is by default added to service collection in .net, but when i use it from linqpad it's not in the collection, so i get a exception from autofac by resolving services
None of the constructors found with 'Autofac.Core.Activators.Reflection.DefaultConstructorFinder' on type 'my class ' can be invoked with the available services and parameters:
Cannot resolve parameter 'Microsoft.Extensions.Configuration.IConfiguration config' of constructor 'Void .ctor(Microsoft.Extensions.Configuration.IConfiguration, System.Func`2[System.Boolean,RestSharp.RestRequest])'.
here is my linqpad code
var builder = new ContainerBuilder();
builder.RegisterType<RestApiRequsts>().As<IRestApiRequsts>().SingleInstance();
var scope = builder.Build();
var restapirequests = scope.Resolve<IRestApiRequsts>();
if anyone can help me to get the .net default services in linqpad
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论