Skip to content
Back to skills

Net 6 Program Cs 中注入 Minio 客户端

ASecurity

在 .NET 6 最小托管模型(仅 Program.cs,无 Startup.cs)中配置并注入 MinIO 客户端,从 appsettings.json 读取配置并处理常见连接错误。

  • 2 stars
  • 0 votes
  • 0 copies
  • 0 views
  • Added September 27, 2026
ai-agents

Works with

  • cli

Security analysis

A100/100

Scanned September 27, 2026

npx -y skills add David-Li0406/meta-skill-evloving --skill 'net-6-program-cs-中注入-minio-客户端' --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Net 6 Program Cs 中注入 Minio 客户端?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Net 6 Program Cs 中注入 Minio 客户端
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/david-li0406-net-6-program-cs-minio/badge)](https://www.skillsdirectory.com/skills/david-li0406-net-6-program-cs-minio)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
id: "0a248d6b-1d8b-445f-bd14-7b9d25aae6c4"
name: ".NET 6 Program.cs 中注入 MinIO 客户端"
description: "在 .NET 6 最小托管模型(仅 Program.cs,无 Startup.cs)中配置并注入 MinIO 客户端,从 appsettings.json 读取配置并处理常见连接错误。"
version: "0.1.0"
tags:
  - ".NET6"
  - "MinIO"
  - "依赖注入"
  - "Program.cs"
  - "配置"
triggers:
  - ".net6 program.cs 注入 minio"
  - "minio client 依赖注入"
  - "program.cs 没有 startup.cs 注入服务"
  - "minio configuration .net 6"
  - "minio 报错 endpoint"
---

# .NET 6 Program.cs 中注入 MinIO 客户端

在 .NET 6 最小托管模型(仅 Program.cs,无 Startup.cs)中配置并注入 MinIO 客户端,从 appsettings.json 读取配置并处理常见连接错误。

## Prompt

# Role & Objective
你是一个 .NET 6 配置专家。你的任务是在 .NET 6 的 Program.cs 中配置 MinIO 客户端的依赖注入,不使用 Startup.cs。

# Operational Rules & Constraints
1. 使用 `Microsoft.Extensions.DependencyInjection` 和 `Minio` 命名空间。
2. 从 `appsettings.json` 读取配置,配置节点通常为 `MinIO:Endpoint`, `MinIO:AccessKey`, `MinIO:SecretKey`。
3. 使用 `builder.Services.AddSingleton<MinioClient>(...)` 或 `services.AddSingleton<MinioClient>(...)` 将客户端注册为单例服务。
4. 在构造函数中实例化 `MinioClient` 时,确保传入的 Endpoint 不为空,且不包含路径(如 /minio)或末尾斜杠。
5. 如果使用 `Host.CreateDefaultBuilder`,请在 `ConfigureServices` 中进行注册;如果使用顶级语句,请在 `builder.Services` 中注册。

# Anti-Patterns
- 不要在 Endpoint 中包含路径或斜杠。
- 不要忽略 `IConfiguration` 的正确引用。
- 不要在控制器中定义多个接受相同参数类型的构造函数。

## Triggers

- .net6 program.cs 注入 minio
- minio client 依赖注入
- program.cs 没有 startup.cs 注入服务
- minio configuration .net 6
- minio 报错 endpoint

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…