WebHostBuilder.ConfigureServices method not found when using nunit3testadapter 4.4.0 #494

Closed
opened 2025-12-29 15:25:15 +01:00 by adam · 1 comment
Owner

Originally created by @iamzhaoxu on GitHub (Feb 27, 2023).

Describe the bug

I try to update the WireMock.Net to 1.5.17 and the nunit3testadapter to 4.4.0 in the test project and I got an exception when starting the wiremock as below

System.MissingMethodException : Method not found: 'Microsoft.AspNetCore.Hosting.IWebHostBuilder Microsoft.AspNetCore.Hosting.IWebHostBuilder.ConfigureServices(System.Action`1<Microsoft.Extensions.DependencyInjection.IServiceCollection>)'.
StackTrace:    at WireMock.Owin.AspNetCoreSelfHost.StartAsync()
   at WireMock.Server.WireMockServer..ctor(WireMockServerSettings settings)
   at WireMock.Server.WireMockServer.Start(Nullable`1 port, Boolean ssl)
  Error Message:
   OneTimeSetUp: System.MissingMethodException : Method not found: 'Microsoft.AspNetCore.Hosting.IWebHostBuilder Microsoft.AspNetCore.Hosting.IWebHostBuilder.ConfigureServices(System.Action`1<Microsoft.Extensions.DependencyInjection.IServiceCollection>)'.
  Stack Trace:
  Failed WhenGetArticles_GivenApiReturnTwoErrorResponses_ShouldRetry [54 ms]
  Error Message:
   OneTimeSetUp: System.MissingMethodException : Method not found: 'Microsoft.AspNetCore.Hosting.IWebHostBuilder Microsoft.AspNetCore.Hosting.IWebHostBuilder.ConfigureServices(System.Action`1<Microsoft.Extensions.DependencyInjection.IServiceCollection>)'.
  Stack Trace:
  Failed WhenGetArticles_GivenQueryMoreThanBatchSize_ShouldReturnExpected [54 ms]
  Error Message:
   OneTimeSetUp: System.MissingMethodException : Method not found: 'Microsoft.AspNetCore.Hosting.IWebHostBuilder Microsoft.AspNetCore.Hosting.IWebHostBuilder.ConfigureServices(System.Action`1<Microsoft.Extensions.DependencyInjection.IServiceCollection>)'.
  Stack Trace: ....

After I downgrade the nunit3testadapter 4.4.0 back to 4.3.1 then the same test worked again. I am not sure this is issue from WireMock and Nunit3TestAdpter and thereby I raised this issue in both projects.

I heard that WebHostBuilder was depreciated https://github.com/dotnet/aspnetcore/issues/20964 before but I still can see the .NET 7 still try to support it from https://learn.microsoft.com/en-us/dotnet/api/microsoft.aspnetcore.hosting.webhostbuilder.-ctor?view=aspnetcore-7.0.

Expected behaviour:

I will expect the latest of WireMock.Net should work with the latest nunit3testadapter

Test to reproduce

  • 1 Refence WireMock.Net 1.5.17 and nunit3testadapter 4.4.0 in the same test project
Originally created by @iamzhaoxu on GitHub (Feb 27, 2023). ### Describe the bug I try to update the WireMock.Net to 1.5.17 and the nunit3testadapter to 4.4.0 in the test project and I got an exception when starting the wiremock as below ``` System.MissingMethodException : Method not found: 'Microsoft.AspNetCore.Hosting.IWebHostBuilder Microsoft.AspNetCore.Hosting.IWebHostBuilder.ConfigureServices(System.Action`1<Microsoft.Extensions.DependencyInjection.IServiceCollection>)'. StackTrace: at WireMock.Owin.AspNetCoreSelfHost.StartAsync() at WireMock.Server.WireMockServer..ctor(WireMockServerSettings settings) at WireMock.Server.WireMockServer.Start(Nullable`1 port, Boolean ssl) Error Message: OneTimeSetUp: System.MissingMethodException : Method not found: 'Microsoft.AspNetCore.Hosting.IWebHostBuilder Microsoft.AspNetCore.Hosting.IWebHostBuilder.ConfigureServices(System.Action`1<Microsoft.Extensions.DependencyInjection.IServiceCollection>)'. Stack Trace: Failed WhenGetArticles_GivenApiReturnTwoErrorResponses_ShouldRetry [54 ms] Error Message: OneTimeSetUp: System.MissingMethodException : Method not found: 'Microsoft.AspNetCore.Hosting.IWebHostBuilder Microsoft.AspNetCore.Hosting.IWebHostBuilder.ConfigureServices(System.Action`1<Microsoft.Extensions.DependencyInjection.IServiceCollection>)'. Stack Trace: Failed WhenGetArticles_GivenQueryMoreThanBatchSize_ShouldReturnExpected [54 ms] Error Message: OneTimeSetUp: System.MissingMethodException : Method not found: 'Microsoft.AspNetCore.Hosting.IWebHostBuilder Microsoft.AspNetCore.Hosting.IWebHostBuilder.ConfigureServices(System.Action`1<Microsoft.Extensions.DependencyInjection.IServiceCollection>)'. Stack Trace: .... ``` After I downgrade the nunit3testadapter 4.4.0 back to 4.3.1 then the same test worked again. I am not sure this is issue from WireMock and Nunit3TestAdpter and thereby I raised this issue in both projects. I heard that WebHostBuilder was depreciated https://github.com/dotnet/aspnetcore/issues/20964 before but I still can see the .NET 7 still try to support it from https://learn.microsoft.com/en-us/dotnet/api/microsoft.aspnetcore.hosting.webhostbuilder.-ctor?view=aspnetcore-7.0. ### Expected behaviour: I will expect the latest of WireMock.Net should work with the latest nunit3testadapter ### Test to reproduce - 1 Refence WireMock.Net 1.5.17 and nunit3testadapter 4.4.0 in the same test project
adam added the bug label 2025-12-29 15:25:15 +01:00
adam closed this issue 2025-12-29 15:25:15 +01:00
Author
Owner

@iamzhaoxu commented on GitHub (Feb 27, 2023):

I figure out this is related to the conflict caused by nunit3testadapter 4.4.0 and Microsoft.Extensions.Hosting 7.0.1 and closed this ticket. thanks!

@iamzhaoxu commented on GitHub (Feb 27, 2023): I figure out this is related to the conflict caused by nunit3testadapter 4.4.0 and Microsoft.Extensions.Hosting 7.0.1 and closed this ticket. thanks!
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/WireMock.Net-wiremock#494