Can't start WireMock.Net server in Xamarin.UITest project (.NET Framework 4.7.2) on MacOS #325

Closed
opened 2025-12-29 15:20:53 +01:00 by adam · 16 comments
Owner

Originally created by @xamadev on GitHub (Jan 24, 2021).

Describe the bug

I have a Xamarin.UITest project (.NET Framework 4.7.2) where I use WireMock.Net 1.4.1. It's working fine on Windows but I can't start the server on MacOS. Using WireMock in a .NET 5 project on MacOS is working. Please have a look at the attached reproduction project. Thanks for your help.

XamarinUITest.zip

WireMock.Exceptions.WireMockException : Service start failed with error: One or more errors occurred. (Could not load type of field 'Microsoft.AspNetCore.Server.Kestrel.Transport.Sockets.SocketTransportOptions:<MemoryPoolFactory>k__BackingField' (1) due to: Could not load file or assembly 'System.Memory, Version=4.0.1.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51' or one of its dependencies.)
  ----> System.AggregateException : One or more errors occurred. (Could not load type of field 'Microsoft.AspNetCore.Server.Kestrel.Transport.Sockets.SocketTransportOptions:<MemoryPoolFactory>k__BackingField' (1) due to: Could not load file or assembly 'System.Memory, Version=4.0.1.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51' or one of its dependencies.)
  ----> System.TypeLoadException : Could not load type of field 'Microsoft.AspNetCore.Server.Kestrel.Transport.Sockets.SocketTransportOptions:<MemoryPoolFactory>k__BackingField' (1) due to: Could not load file or assembly 'System.Memory, Version=4.0.1.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51' or one of its dependencies.
TearDown : System.NullReferenceException : Object reference not set to an instance of an object

=== Visual Studio Community 2019 for Mac ===

Version 8.8.4 (build 30)
Installation UUID: 94accbf7-86e5-4735-9417-a34560e045b1
GTK+ 2.24.23 (Raleigh theme)
Xamarin.Mac 6.18.0.23 (d16-6 / 088c73638)

Package version: 612000113

=== Mono Framework MDK ===

Runtime:
Mono 6.12.0.113 (2020-02/4fdfb5b1fd5) (64-bit)
Package version: 612000113

=== Roslyn (Language Service) ===

3.8.0-5.20519.18+4c195c3ac1974edcefa76774d7a59a2350ec55fa

=== NuGet ===

Version: 5.8.0.6860

=== .NET Core SDK ===

SDK: /usr/local/share/dotnet/sdk/5.0.101/Sdks
SDK Versions:
5.0.101
5.0.100
3.1.404
3.1.402
MSBuild SDKs: /Applications/Visual Studio.app/Contents/Resources/lib/monodevelop/bin/MSBuild/Current/bin/Sdks

=== .NET Core Runtime ===

Runtime: /usr/local/share/dotnet/dotnet
Runtime Versions:
5.0.1
5.0.0
3.1.10
3.1.8
2.1.23
2.1.22

=== .NET Core 3.1 SDK ===

SDK: 3.1.404

=== Xamarin.Profiler ===

Version: 1.6.15.68
Location: /Applications/Xamarin Profiler.app/Contents/MacOS/Xamarin Profiler

=== Updater ===

Version: 11

=== Apple Developer Tools ===

Xcode 12.2 (17535)
Build 12B45b

=== Xamarin Designer ===

Version: 16.8.0.510
Hash: 44e3f3ce9
Branch: remotes/origin/d16-8
Build date: 2020-12-10 00:06:14 UTC

=== Xamarin.Android ===

Not Installed

=== Microsoft OpenJDK for Mobile ===

Java SDK: Not Found

Android Designer EPL code available here:
https://github.com/xamarin/AndroidDesigner.EPL

=== Android SDK Manager ===

Version: 16.8.0.32
Hash: 01a7774
Branch: remotes/origin/d16-8
Build date: 2020-12-10 00:32:24 UTC

=== Android Device Manager ===

Version: 16.8.0.46
Hash: 0a81419
Branch: remotes/origin/d16-8
Build date: 2020-12-10 00:32:44 UTC

=== Xamarin.Mac ===

Xamarin.Mac not installed. Can't find /Library/Frameworks/Xamarin.Mac.framework/Versions/Current/Version.

=== Xamarin.iOS ===

Version: 14.6.0.15 (Visual Studio Community)
Hash: 87a1b18d8
Branch: d16-8
Build date: 2020-11-16 21:39:41-0500

=== Build Information ===

Release ID: 808040030
Git revision: eaa21a8983aa5c4bcf6a665892478b4f3d413418
Build date: 2020-12-10 11:06:12-05
Build branch: release-8.8
Xamarin extensions: eaa21a8983aa5c4bcf6a665892478b4f3d413418

=== Operating System ===

Mac OS X 10.15.7
Darwin 19.6.0 Darwin Kernel Version 19.6.0
Mon Aug 31 22:12:52 PDT 2020
root:xnu-6153.141.2~1/RELEASE_X86_64 x86_64

Originally created by @xamadev on GitHub (Jan 24, 2021). ### Describe the bug I have a Xamarin.UITest project (.NET Framework 4.7.2) where I use WireMock.Net 1.4.1. It's working fine on Windows but I can't start the server on MacOS. Using WireMock in a .NET 5 project on MacOS is working. Please have a look at the attached reproduction project. Thanks for your help. [XamarinUITest.zip](https://github.com/WireMock-Net/WireMock.Net/files/5862868/XamarinUITest.zip) ``` WireMock.Exceptions.WireMockException : Service start failed with error: One or more errors occurred. (Could not load type of field 'Microsoft.AspNetCore.Server.Kestrel.Transport.Sockets.SocketTransportOptions:<MemoryPoolFactory>k__BackingField' (1) due to: Could not load file or assembly 'System.Memory, Version=4.0.1.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51' or one of its dependencies.) ----> System.AggregateException : One or more errors occurred. (Could not load type of field 'Microsoft.AspNetCore.Server.Kestrel.Transport.Sockets.SocketTransportOptions:<MemoryPoolFactory>k__BackingField' (1) due to: Could not load file or assembly 'System.Memory, Version=4.0.1.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51' or one of its dependencies.) ----> System.TypeLoadException : Could not load type of field 'Microsoft.AspNetCore.Server.Kestrel.Transport.Sockets.SocketTransportOptions:<MemoryPoolFactory>k__BackingField' (1) due to: Could not load file or assembly 'System.Memory, Version=4.0.1.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51' or one of its dependencies. TearDown : System.NullReferenceException : Object reference not set to an instance of an object ``` ### Other related info === Visual Studio Community 2019 for Mac === Version 8.8.4 (build 30) Installation UUID: 94accbf7-86e5-4735-9417-a34560e045b1 GTK+ 2.24.23 (Raleigh theme) Xamarin.Mac 6.18.0.23 (d16-6 / 088c73638) Package version: 612000113 === Mono Framework MDK === Runtime: Mono 6.12.0.113 (2020-02/4fdfb5b1fd5) (64-bit) Package version: 612000113 === Roslyn (Language Service) === 3.8.0-5.20519.18+4c195c3ac1974edcefa76774d7a59a2350ec55fa === NuGet === Version: 5.8.0.6860 === .NET Core SDK === SDK: /usr/local/share/dotnet/sdk/5.0.101/Sdks SDK Versions: 5.0.101 5.0.100 3.1.404 3.1.402 MSBuild SDKs: /Applications/Visual Studio.app/Contents/Resources/lib/monodevelop/bin/MSBuild/Current/bin/Sdks === .NET Core Runtime === Runtime: /usr/local/share/dotnet/dotnet Runtime Versions: 5.0.1 5.0.0 3.1.10 3.1.8 2.1.23 2.1.22 === .NET Core 3.1 SDK === SDK: 3.1.404 === Xamarin.Profiler === Version: 1.6.15.68 Location: /Applications/Xamarin Profiler.app/Contents/MacOS/Xamarin Profiler === Updater === Version: 11 === Apple Developer Tools === Xcode 12.2 (17535) Build 12B45b === Xamarin Designer === Version: 16.8.0.510 Hash: 44e3f3ce9 Branch: remotes/origin/d16-8 Build date: 2020-12-10 00:06:14 UTC === Xamarin.Android === Not Installed === Microsoft OpenJDK for Mobile === Java SDK: Not Found Android Designer EPL code available here: https://github.com/xamarin/AndroidDesigner.EPL === Android SDK Manager === Version: 16.8.0.32 Hash: 01a7774 Branch: remotes/origin/d16-8 Build date: 2020-12-10 00:32:24 UTC === Android Device Manager === Version: 16.8.0.46 Hash: 0a81419 Branch: remotes/origin/d16-8 Build date: 2020-12-10 00:32:44 UTC === Xamarin.Mac === Xamarin.Mac not installed. Can't find /Library/Frameworks/Xamarin.Mac.framework/Versions/Current/Version. === Xamarin.iOS === Version: 14.6.0.15 (Visual Studio Community) Hash: 87a1b18d8 Branch: d16-8 Build date: 2020-11-16 21:39:41-0500 === Build Information === Release ID: 808040030 Git revision: eaa21a8983aa5c4bcf6a665892478b4f3d413418 Build date: 2020-12-10 11:06:12-05 Build branch: release-8.8 Xamarin extensions: eaa21a8983aa5c4bcf6a665892478b4f3d413418 === Operating System === Mac OS X 10.15.7 Darwin 19.6.0 Darwin Kernel Version 19.6.0 Mon Aug 31 22:12:52 PDT 2020 root:xnu-6153.141.2~1/RELEASE_X86_64 x86_64
adam added the bug label 2025-12-29 15:20:53 +01:00
adam closed this issue 2025-12-29 15:20:53 +01:00
Author
Owner

@StefH commented on GitHub (Jan 24, 2021):

Hello @xamadev,

This issue looks a bit like : https://github.com/WireMock-Net/WireMock.Net/issues/534

Can you also try adding System.Memory same as described in that issue for System.Buffers?

@StefH commented on GitHub (Jan 24, 2021): Hello @xamadev, This issue looks a bit like : https://github.com/WireMock-Net/WireMock.Net/issues/534 Can you also try adding System.Memory same as described in that issue for System.Buffers?
Author
Owner

@xamadev commented on GitHub (Jan 24, 2021):

@StefH Thanks for your quick reply. Adding System.Memory and System.Threading.Tasks.Extensions as NuGet reference solved the exceptions and the server is starting. But unfortunately I'm not getting any reply. I can't see any exception. Can you confirm WireMock.Net ist working with Mono?

@xamadev commented on GitHub (Jan 24, 2021): @StefH Thanks for your quick reply. Adding System.Memory and System.Threading.Tasks.Extensions as NuGet reference solved the exceptions and the server is starting. But unfortunately I'm not getting any reply. I can't see any exception. Can you confirm WireMock.Net ist working with Mono?
Author
Owner

@xamadev commented on GitHub (Feb 6, 2021):

@StefH Any guess what the issue could be or what I can try to figure it out?
Does WireMock.Net generally work in a .NET Framework 4.7.2 project on MacOS?

@xamadev commented on GitHub (Feb 6, 2021): @StefH Any guess what the issue could be or what I can try to figure it out? Does WireMock.Net generally work in a .NET Framework 4.7.2 project on MacOS?
Author
Owner

@StefH commented on GitHub (Feb 6, 2021):

I did copy your test project and I was able to run it without any issue:
image

See my test:
https://github.com/WireMock-Net/WireMock.Net/tree/master/test/WireMock.Net.XamarinUI.Tests

@StefH commented on GitHub (Feb 6, 2021): I did copy your test project and I was able to run it without any issue: ![image](https://user-images.githubusercontent.com/249938/107114668-d6d2ee00-6867-11eb-9f68-5963bd34c2bc.png) See my test: https://github.com/WireMock-Net/WireMock.Net/tree/master/test/WireMock.Net.XamarinUI.Tests
Author
Owner

@xamadev commented on GitHub (Feb 6, 2021):

On Windows?

@xamadev commented on GitHub (Feb 6, 2021): On Windows?
Author
Owner

@StefH commented on GitHub (Feb 6, 2021):

On windows indeed, I dont have MacOS

@StefH commented on GitHub (Feb 6, 2021): On windows indeed, I dont have MacOS
Author
Owner

@StefH commented on GitHub (Feb 6, 2021):

(One thing : when the test started for the first time, I needed to approve the connections to private/public internet in the Windows Firewall, but I don't think that could be related to your issue?)

image

@StefH commented on GitHub (Feb 6, 2021): (One thing : when the test started for the first time, I needed to approve the connections to private/public internet in the Windows Firewall, but I don't think that could be related to your issue?) ![image](https://user-images.githubusercontent.com/249938/107114805-0fbf9280-6869-11eb-844f-d68f2d0c959c.png)
Author
Owner

@xamadev commented on GitHub (Feb 6, 2021):

Works fine on windows for me too. I only have issues running it on MacOS. Maybe it's a problem with Mono which is necessary on MacOS because there's no native .NET Framework support like on windows.

@xamadev commented on GitHub (Feb 6, 2021): Works fine on windows for me too. I only have issues running it on MacOS. Maybe it's a problem with [Mono](https://github.com/mono/mono) which is necessary on MacOS because there's no native .NET Framework support like on windows.
Author
Owner

@StefH commented on GitHub (Feb 6, 2021):

Can't you change the framework to netcoreapp3.1 ?

@StefH commented on GitHub (Feb 6, 2021): Can't you change the framework to netcoreapp3.1 ?
Author
Owner

@xamadev commented on GitHub (Feb 7, 2021):

I'd love to but unfortunately Xamarin.UITest isn't comaptible with .NET Core :/

@xamadev commented on GitHub (Feb 7, 2021): I'd love to but unfortunately [Xamarin.UITest isn't comaptible with .NET Core ](https://forums.xamarin.com/discussion/180329/xamarin-uitest-project-targeting-net-framework-vs-net-core-net-standard-implentation-support) :/
Author
Owner

@StefH commented on GitHub (Feb 7, 2021):

Note that your test project csproj is using the new format.

What happens when you create a old .NET Full Framework 4.7.2 test project ?

@StefH commented on GitHub (Feb 7, 2021): Note that your test project `csproj` is using the _new_ format. What happens when you create a _old_ .NET Full Framework 4.7.2 test project ?
Author
Owner

@StefH commented on GitHub (Feb 8, 2021):

Also, if you can help me setting up mono on WSL2 and running the tests, that would be useful to reproduce this issue, else I cannot help you.

@StefH commented on GitHub (Feb 8, 2021): Also, if you can help me setting up mono on WSL2 and running the tests, that would be useful to reproduce this issue, else I cannot help you.
Author
Owner

@StefH commented on GitHub (Mar 25, 2021):

@xamadev Any update?

@StefH commented on GitHub (Mar 25, 2021): @xamadev Any update?
Author
Owner

@StefH commented on GitHub (Dec 20, 2021):

@xamadev

Can you please try preview version 1.4.29-ci-15689 ?

Info : https://github.com/WireMock-Net/WireMock.Net/wiki/MyGet-preview-versions

@StefH commented on GitHub (Dec 20, 2021): @xamadev Can you please try preview version `1.4.29-ci-15689` ? Info : https://github.com/WireMock-Net/WireMock.Net/wiki/MyGet-preview-versions
Author
Owner

@StefH commented on GitHub (Dec 24, 2021):

@xamadev

I've added ConfigureAwait(false) to all await calls, so maybe this will solve your issue.

I'm closing this issue now, a new official version will be released in some days.

https://github.com/WireMock-Net/WireMock.Net/pull/704

@StefH commented on GitHub (Dec 24, 2021): @xamadev I've added `ConfigureAwait(false)` to all `await` calls, so maybe this will solve your issue. I'm closing this issue now, a new official version will be released in some days. https://github.com/WireMock-Net/WireMock.Net/pull/704
Author
Owner

@xamadev commented on GitHub (Mar 19, 2022):

@StefH Just tested with version 1.4.38 - it's working! Thanks a lot for your effort and sorry for the late reply :)

@xamadev commented on GitHub (Mar 19, 2022): @StefH Just tested with version 1.4.38 - it's working! Thanks a lot for your effort and sorry for the late reply :)
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/WireMock.Net-wiremock#325