小编Maa*_*ers的帖子

.NET 6 - 将服务注入program.cs

我知道如何在 .NET 5(或之前版本)的 Startup.cs 中进行依赖项注入,但是如何对 .NET 6 中的顶级 Program.cs 执行相同的操作?

.NET 5:例如,我可以在Configure方法中注入一个类

public class Startup
{
    public IConfiguration _configuration { get; }
    public IWebHostEnvironment _env { get; set; }

    public Startup(IConfiguration configuration, IWebHostEnvironment env)
    {
        _configuration = configuration;
        _env = env;
    }

    public void ConfigureServices(IServiceCollection services)
    {
        // TODO
    }

    public void Configure(IApplicationBuilder app, IWebHostEnvironment env, IToInjectService serviceToInject)
    {
        // USE SERVICE
    }
}
Run Code Online (Sandbox Code Playgroud)

如何在 .NET 6 中实现这一目标?

.net c# dependency-injection class startup

32
推荐指数
4
解决办法
5万
查看次数

待办事项导航级别中没有用户故事 (Azure Devops)

我看不到在哪里激活 DevOps 的用户故事。我只有史诗和问题。我可以在哪里更改此设置?

在此输入图像描述

agile settings sprint backlog azure-devops

3
推荐指数
1
解决办法
2297
查看次数

DevOps 注册脚本错误:Current() ).IsInRole(...)

我无法让我的注册脚本在 PowerShell (admin) 中运行。它可以在 Powershell ISE 中运行,但随后脚本卡在“正在连接到服务器...”

\n

难道我做错了什么?

\n

在此输入图像描述

\n

这是脚本:

\n
 $ErrorActionPreference="Stop";If(-NOT ([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent() ).IsInRole( [Security.Principal.WindowsBuiltInRole] \xe2\x80\x9cAdministrator\xe2\x80\x9d)){ throw "Run command in an administrator PowerShell prompt"};If($PSVersionTable.PSVersion -lt (New-Object System.Version("3.0"))){ throw "The minimum version of Windows PowerShell that is required by the script (3.0) does not match the currently running version of Windows PowerShell." };If(-NOT (Test-Path $env:SystemDrive\\\'azagent\')){mkdir $env:SystemDrive\\\'azagent\'}; cd $env:SystemDrive\\\'azagent\'; for($i=1; $i -lt 100; $i++){$destFolder="A"+$i.ToString();if(-NOT (Test-Path ($destFolder))){mkdir $destFolder;cd $destFolder;break;}}; $agentZip="$PWD\\agent.zip";$DefaultProxy=[System.Net.WebRequest]::DefaultWebProxy;$securityProtocol=@();$securityProtocol+=[Net.ServicePointManager]::SecurityProtocol;$securityProtocol+=[Net.SecurityProtocolType]::Tls12;[Net.ServicePointManager]::SecurityProtocol=$securityProtocol;$WebClient=New-Object Net.WebClient; $Uri=\'[url]\';if($DefaultProxy -and (-not $DefaultProxy.IsBypassed($Uri))){$WebClient.Proxy= New-Object Net.WebProxy($DefaultProxy.GetProxy($Uri).OriginalString, $True);}; $WebClient.DownloadFile($Uri, $agentZip);Add-Type -AssemblyName …
Run Code Online (Sandbox Code Playgroud)

deployment iis vps azure devops

2
推荐指数
1
解决办法
807
查看次数