首页 新闻 会员 周边 捐助
1
回答数

回答被采纳 30 Lucene.Net: 创建 IndexWriter 实例时出现 "Could not find file _1bx.fnm"

在更新索引中的文档创建 IndexWriter 实例时出现下面的错误,请问如何解决? System.IO.FileNotFoundException: Could not find file '/zz
1
回答数

回答被采纳 30 Lucene.Net: 更新索引后搜索时出现 "no segments* file found" 问题

从索引中删除并添加一个文档后,搜索时报错 Lucene.Net.Index.IndexNotFoundException: no segments* file found in MMapDirecto
1
回答数

已解决问题 30 .NET: 集成测试中如何覆盖目标 Web 项目 Program 中注册的 HttpClient

在 asp.net core integration testing 中,测试的目标 web 项目的 Program 中已经注册了 HttpClient,集成测试中需要用 HttpClient moc
1
回答数

回答被采纳 30 .NET: 集成测试报错 "The entry point exited without ever building an IHost"

将 asp.net core web api 项目的 Program 改为 top-level statements 后集成测试出现下面的异常 System.InvalidOperationExcep
1
回答数

回答被采纳 30 如何让 Serilog 日志在遇到空行时显示默认内容

日志模板如下 "outputTemplate": "{Timestamp:yyyy-MM-dd HH:mm:ss.fff} [{Level}] {Message:l}{NewLine}{Request
1
回答数

回答被采纳 30 C#: Program 使用 top-level statements 如何指定 namespace

在 Program 中写上 namespace 语句,之后的代码全部报错
1
回答数

回答被采纳 30 EF Core: LINQ GroupBy ToDictionaryAsync 问题

下面的 LINQ 查询生成的 SQL 语句会 SELECT 两张表的所有字段,期望的是只 SELECT PostId 与 Tag.Name 对应的字段,请问如何实现? var dict = await
1
回答数

回答被采纳 30 不用 try...catch ,如果处理启动过程在 Program.cs 中发生的异常

Program.cs 中有很多代码,如果为了处理异常将一堆代码包裹在 try...catch 中不美观,有没有什么办法在不加 try...catch 的情况下处理异常?
2
回答数

回答被采纳 50 C#: 接口继承的依赖注入问题

想把一个已有接口 IZzkDocService public interface IZzkDocService { Task<SearchResult> SearchAsync(string appN
4
回答数

已解决问题 80 如何通过 .editorconfig 让 VS 2022 新建的 class 默认使用 public 访问修饰符

VS 2022 新建的 class 默认使用 internal 访问修饰符(access modifier),如何通过 .editorconfig 的配置默认使用 public? internal c
1
回答数

回答被采纳 30 code style: file scoped namespace 之后缺少空行的问题

在 .editorconfig 中添加 csharp_style_namespace_declarations 配置后(详见之前的博问),VS 2022 新建的 class 会默认使用 file sc
1
回答数

回答被采纳 30 如何让 VS 2022 新建的 class 默认使用 file scoped namespace

在 Visual Studio 2022 中新建类时如何默认就使用 file scoped namespace?
1
回答数

回答被采纳 30 .NET/C#: 集成测试中实现进程内通信的最简单方法

在集成测试中验证测试结果时需要用到,请问如何用 C# 实现简单的进程内通信(In-Process Communication)?
1
回答数

回答被采纳 30 .NET: 如何基于 WebApplication 创建 WebHostBuilder 给 TestServer 使用

想在测试用例中不使用 WebApplicationFactory,直接使用 TestServer,TestServer 的构造函数需要传参 IWebHostBuilder 的实例, 如果能通过 Web
1
回答数

回答被采纳 30 .NET: 如何检查一个接口是否已经在DI容器中注册过

想在 IEndpointRouteBuilder 的扩展方法中检查 IEventBus 接口(Interface) 是否已经注册过,请问如何实现? 尝试下面的代码,却发现即使没有注册,eventBus
1
回答数

回答被采纳 30 ASP.NET Core: 如何通过 Request.BodyReader 读取 request body 的内容

今天在排查 web api 问题时需要输出 request body 的内容看一下,之前都是通使用 Request.Body ,今天想试试 Request.BodyReader,它的类型是 PipeR
1
回答数

回答被采纳 30 集成测试中如何让 Refit 使用 WebApplicationFactory 创建的 HttpClient

我们当前使用 HttpClientFactory 方式创建 Refit 所需要的 HttpClient services.AddRefitClient<IBlogPostClient>() .Conf
1
回答数

回答被采纳 30 Kubernetes: 如何用命令查看当前使用的 namespace

如题,如何用 kubectl 命令查看查看当前使用的命名空间?
1
回答数

回答被采纳 30 Kubernetes: helm 部署应用时出现 Unauthorized 错误

通过 helm 向 k8s 集群部署应用时出现下面的错误,请问如何解决? error: You must be logged in to the server (Unauthorized) Error
1
回答数

回答被采纳 50 C#: 当 web api dns 解析失败时 Refit 会出现 NullReferenceException

当所请求的 web api 遭遇 dns 解析失败 Name or service not know,refit 就投降了,直接抛 null 引用异常 System.NullReferenceExce
1
回答数

已解决问题 50 ASP.NET Core: 如何通过依赖注入的方式获取 IConfiguration 绑定到 Options

在 实现 ServiceCollection extension methods 时,如果需要 bind Options,通常的做法是增加 IConfiguration 类型的参数,让调用方传入。 为
2
回答数

回答被采纳 50 C#: 如何从 Refit 的注解(annotation) 中获取请求路径

Refit 是一个 REST 库 ,可以根据 annotation 自动生成 HttpClient 请求代码 https://github.com/reactiveui/refit 想从 annota
1
回答数

已解决问题 50 .NET: ConfigureServices 中究竟能不能使用 BuildServiceProvider

在 Startup.ConfigureServices 中使用 services.BuildServiceProvider 的场景之一是在实现基于 IServiceCollection 的扩展方法时,
1
回答数

回答被采纳 30 C#/.NET: 求 mock HttpClient 的好姿势

想在测试中 mock HttpClient,请问有什么以假乱真的好姿势?
1
回答数

回答被采纳 30 C#: 如何创建忽略大小写的 key 类型为 char 的 Dictionary

如果是 string 类型的 key,可以使用 StringComparer.OrdinalIgnoreCase var dict = new Dictionary<string, TrieNode>
Top