如何在linqpad中获取.NET核心默认服务集合

发布于 2025-01-27 14:56:14 字数 1027 浏览 2 评论 0原文

我在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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文