mirror of
https://github.com/wiremock/WireMock.Net.git
synced 2026-01-11 21:10:32 +01:00
WireMock.Net will not run with certain .net5 dependencies installed in the project #330
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @MikaelEliasson on GitHub (Jan 30, 2021).
Describe the bug
When running on .net 4.7.2 and with the Microsoft.Extensions.* packages being upgraded to 5.0.0.0 WireMock will crash on even the simplest calls.
The caller then gets the following exception
Expected behavior:
I expect the call to go through and return the response.
Test to reproduce
Repro code: https://github.com/bokio/WireMockExperiment
The exceptions thrown is:
You can see it if you put the breakpoint in https://github.com/bokio/WireMockExperiment/blob/master/Class1.cs#L55
I tested to install WireMock 1.4.2.0 in the 4.7.2 project without upgrading any libraries and then it worked. So it has to be one of the following dependencies. Because these were the ones we upgraded when we first saw the problem.
Other related info
The test project is a simplification of what happened in our real project where we have Wiremock installed in .netstandard2.0 project and run the tests in 4.7.2. But as shown it becomes the same on 4.7.2.
@MikaelEliasson commented on GitHub (Jan 30, 2021):
I will try to nail down which of these dependencies that cause the issue. But if anyone have an idea it would be a welcome way to speed up the process.
@MikaelEliasson commented on GitHub (Jan 30, 2021):
Ok, updating
Microsoft.Extensions.Configurationbreaks WireMock. It pulls down these dependencies too:@StefH commented on GitHub (Jan 30, 2021):
Do you have same issue with lower versions from Microsoft.Extensions?
@MikaelEliasson commented on GitHub (Jan 30, 2021):
No. I'm not sure exactly which version that introduce the issue but we were on 3.1.8.0 before we had to upgrade and then it worked. But considering 3.1.11.0 is the last version before 5.0.0.0 it seems likely it's 5.0.0.0 that cause the issue.
I just very confused to how it would cause a null ref in the kestrel pipeline. Is there any way to force WireMock to use the old Owin pipeline to see if it works better?
@StefH commented on GitHub (Jan 30, 2021):
I never tried using WireMock in .net 5.0
It could be that indeed some Owing pipeline functionality is changed / obsolete / broken.
@StefH commented on GitHub (Jan 31, 2021):
@MikaelEliasson
The root cause is likely related to this:
https://github.com/dotnet/aspnetcore/issues/28112#issuecomment-733635589
However, I could not find a way yet to fix this in WireMock.Net
Can't you move your unit test project to .net 5 or 3.1 ?
@MikaelEliasson commented on GitHub (Feb 1, 2021):
@StefH Going to 3.1 and then 5 is what we are doing and why we needed to upgrade those dependencies. The problem is that our project is a bit too large to update in one go so we need to take it in steps. And sadly this needs to be the next step.
Is it possible to force it using the old Owin host somehow? Otherwise we can probably fork the repo and hard code it to use that one while getting past this period.
@StefH commented on GitHub (Feb 1, 2021):
Hello @MikaelEliasson
If your unit test project is still 4.7.2, then also the version from WireMock.Net is matching that one (this will be the .NET 4.6.1 version)
Maybe adding a .NET 4.7.2 framework target to WireMock.Net could help using the correct OWIN implementation, I'll take a look tonight.
Another work-around is maybe adding manually a
dateheader in the setup from the mapping.Because if this code:
https://github.com/aspnet/KestrelHttpServer/blob/master/src/Kestrel.Core/Internal/Http/HttpProtocol.cs#L1190
Does not find a date-header, an then tries to call that InplaceStringBuilder which is removed in .net 50
@StefH commented on GitHub (Feb 1, 2021):
@MikaelEliasson
I've created a preview version on MyGet (WireMock.Net.1.4.2-ci-14604), can you try this one?
@xadvfh commented on GitHub (Feb 2, 2021):
I seem to be having a similar issue in dotnet core. I'm getting the following error when starting the server:
My dotnet info:
@xadvfh commented on GitHub (Feb 2, 2021):
@StefH I tried the latest
1.4.3-ci-14595from myget and still face the same issue@StefH commented on GitHub (Feb 2, 2021):
In my example project : https://github.com/WireMock-Net/WireMock.Net/tree/net5-issue/examples/WireMock.Net.Console.Net472.Classic adding a
.net 5nuget will work (that means that the "Date" issue is gone)However this last issue seems be a different one.
Can you also create a example project for this please?
@xadvfh commented on GitHub (Feb 2, 2021):
@StefH it seems my issue is caused by nunit.engine package which might be overwriting a dependency that wiremock.net uses. When i uninstall the nunit.engine package it works
@StefH commented on GitHub (Feb 2, 2021):
#579