MockServer not starting #267

Closed
opened 2025-12-29 15:19:23 +01:00 by adam · 7 comments
Owner

Originally created by @Rutenioh on GitHub (Apr 16, 2020).

Originally assigned to: @StefH on GitHub.

Hello
I am trying to use WireMock but I am having a problem and I don´t know why. My project is .NET Framework 4.52 and I installed the last version of WireMock.Net.

When I Start the server with .Start() method this is the error:

Initialization method Tests.TestShould.OnTestInitialize threw exception. WireMock.Exceptions.WireMockException: Service start failed with error: Se produjo una excepción en el destino de la invocación. ---> System.Reflection.TargetInvocationException: Se produjo una excepción en el destino de la invocación. ---> System.Net.HttpListenerException: El parámetro no es correcto. en System.Net.HttpListener.AddAllPrefixes() en System.Net.HttpListener.Start() en Microsoft.Owin.Host.HttpListener.OwinHttpListener.Start(HttpListener listener, Func2 appFunc, IList1 addresses, IDictionary2 capabilities, Func2 loggerFactory) en Microsoft.Owin.Host.HttpListener.OwinServerFactory.Create(Func2 app, IDictionary2 properties) --- End of inner exception stack trace --- en System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor) en System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[] parameters, Object[] arguments) en System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture) en Microsoft.Owin.Hosting.ServerFactory.ServerFactoryAdapter.Create(IAppBuilder builder) en Microsoft.Owin.Hosting.Engine.HostingEngine.StartServer(StartContext context) en Microsoft.Owin.Hosting.Engine.HostingEngine.Start(StartContext context) en Microsoft.Owin.Hosting.WebApp.StartImplementation(IServiceProvider services, StartOptions options, Action1 startup)
en WireMock.Owin.OwinSelfHost.StartServers()
--- End of inner exception stack trace ---
en WireMock.Server.WireMockServer..ctor(IWireMockServerSettings settings)
en WireMock.Server.WireMockServer.Start(Nullable1 port, Boolean ssl) en Tests.TestShould.OnTestInitialize() en C:\Dev\Tests\TestShould.cs:línea 36

Any idea?
Thanks.

Originally created by @Rutenioh on GitHub (Apr 16, 2020). Originally assigned to: @StefH on GitHub. Hello I am trying to use WireMock but I am having a problem and I don´t know why. My project is .NET Framework 4.52 and I installed the last version of WireMock.Net. When I Start the server with .Start() method this is the error: `Initialization method Tests.TestShould.OnTestInitialize threw exception. WireMock.Exceptions.WireMockException: Service start failed with error: Se produjo una excepción en el destino de la invocación. ---> System.Reflection.TargetInvocationException: Se produjo una excepción en el destino de la invocación. ---> System.Net.HttpListenerException: El parámetro no es correcto. en System.Net.HttpListener.AddAllPrefixes() en System.Net.HttpListener.Start() en Microsoft.Owin.Host.HttpListener.OwinHttpListener.Start(HttpListener listener, Func`2 appFunc, IList`1 addresses, IDictionary`2 capabilities, Func`2 loggerFactory) en Microsoft.Owin.Host.HttpListener.OwinServerFactory.Create(Func`2 app, IDictionary`2 properties) --- End of inner exception stack trace --- en System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor) en System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[] parameters, Object[] arguments) en System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture) en Microsoft.Owin.Hosting.ServerFactory.ServerFactoryAdapter.Create(IAppBuilder builder) en Microsoft.Owin.Hosting.Engine.HostingEngine.StartServer(StartContext context) en Microsoft.Owin.Hosting.Engine.HostingEngine.Start(StartContext context) en Microsoft.Owin.Hosting.WebApp.StartImplementation(IServiceProvider services, StartOptions options, Action`1 startup) en WireMock.Owin.OwinSelfHost.StartServers() --- End of inner exception stack trace --- en WireMock.Server.WireMockServer..ctor(IWireMockServerSettings settings) en WireMock.Server.WireMockServer.Start(Nullable`1 port, Boolean ssl) en Tests.TestShould.OnTestInitialize() en C:\Dev\Tests\TestShould.cs:línea 36` Any idea? Thanks.
adam added the bug label 2025-12-29 15:19:23 +01:00
adam closed this issue 2025-12-29 15:19:23 +01:00
Author
Owner

@StefH commented on GitHub (Apr 16, 2020):

Can you provide the C# code, or maybe a full example project?

@StefH commented on GitHub (Apr 16, 2020): Can you provide the C# code, or maybe a full example project?
Author
Owner

@Rutenioh commented on GitHub (Apr 17, 2020):

Yes, of course.
This is the most simple, one project in 4.5.2 .Net Framework with a test calling the Start() method.

TestWiremock.zip

@Rutenioh commented on GitHub (Apr 17, 2020): Yes, of course. This is the most simple, one project in 4.5.2 .Net Framework with a test calling the Start() method. [TestWiremock.zip](https://github.com/WireMock-Net/WireMock.Net/files/4491579/TestWiremock.zip)
Author
Owner

@StefH commented on GitHub (Apr 17, 2020):

Yes I can confirm your issue:

Test method UnitTestProject_net452.UnitTest1.TestMethod1 threw exception: 
WireMock.Exceptions.WireMockException: Service start failed with error: Exception has been thrown by the target of an invocation. ---> System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.Net.HttpListenerException: The parameter is incorrect
    at System.Net.HttpListener.AddAllPrefixes()
   at System.Net.HttpListener.Start()
   at Microsoft.Owin.Host.HttpListener.OwinHttpListener.Start(HttpListener listener, Func`2 appFunc, IList`1 addresses, IDictionary`2 capabilities, Func`2 loggerFactory)
   at Microsoft.Owin.Host.HttpListener.OwinServerFactory.Create(Func`2 app, IDictionary`2 properties)
--- End of inner exception stack trace ---
    at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor)
   at System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[] parameters, Object[] arguments)
   at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
   at Microsoft.Owin.Hosting.ServerFactory.ServerFactoryAdapter.Create(IAppBuilder builder)
   at Microsoft.Owin.Hosting.Engine.HostingEngine.StartServer(StartContext context)
   at Microsoft.Owin.Hosting.Engine.HostingEngine.Start(StartContext context)
   at Microsoft.Owin.Hosting.WebApp.StartImplementation(IServiceProvider services, StartOptions options, Action`1 startup)
   at WireMock.Owin.OwinSelfHost.StartServers()
--- End of inner exception stack trace ---
    at WireMock.Server.WireMockServer..ctor(IWireMockServerSettings settings)
   at WireMock.Server.WireMockServer.Start(Nullable`1 port, Boolean ssl)
   at UnitTestProject_net452.UnitTest1.TestMethod1() in C:\Users\Heyenrath SWW\Downloads\UnitTestProject-net452\UnitTest1.cs:line 13
@StefH commented on GitHub (Apr 17, 2020): Yes I can confirm your issue: ``` Test method UnitTestProject_net452.UnitTest1.TestMethod1 threw exception: WireMock.Exceptions.WireMockException: Service start failed with error: Exception has been thrown by the target of an invocation. ---> System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.Net.HttpListenerException: The parameter is incorrect at System.Net.HttpListener.AddAllPrefixes() at System.Net.HttpListener.Start() at Microsoft.Owin.Host.HttpListener.OwinHttpListener.Start(HttpListener listener, Func`2 appFunc, IList`1 addresses, IDictionary`2 capabilities, Func`2 loggerFactory) at Microsoft.Owin.Host.HttpListener.OwinServerFactory.Create(Func`2 app, IDictionary`2 properties) --- End of inner exception stack trace --- at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor) at System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[] parameters, Object[] arguments) at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture) at Microsoft.Owin.Hosting.ServerFactory.ServerFactoryAdapter.Create(IAppBuilder builder) at Microsoft.Owin.Hosting.Engine.HostingEngine.StartServer(StartContext context) at Microsoft.Owin.Hosting.Engine.HostingEngine.Start(StartContext context) at Microsoft.Owin.Hosting.WebApp.StartImplementation(IServiceProvider services, StartOptions options, Action`1 startup) at WireMock.Owin.OwinSelfHost.StartServers() --- End of inner exception stack trace --- at WireMock.Server.WireMockServer..ctor(IWireMockServerSettings settings) at WireMock.Server.WireMockServer.Start(Nullable`1 port, Boolean ssl) at UnitTestProject_net452.UnitTest1.TestMethod1() in C:\Users\Heyenrath SWW\Downloads\UnitTestProject-net452\UnitTest1.cs:line 13 ```
Author
Owner

@StefH commented on GitHub (Apr 17, 2020):

I did fix it.

If you would like, you can test a preview version: WireMock.Net.1.2.4-ci-13183.

See https://github.com/WireMock-Net/WireMock.Net/wiki/MyGet-preview-versions for information.

@StefH commented on GitHub (Apr 17, 2020): I did fix it. If you would like, you can test a preview version: `WireMock.Net.1.2.4-ci-13183`. See https://github.com/WireMock-Net/WireMock.Net/wiki/MyGet-preview-versions for information.
Author
Owner

@Rutenioh commented on GitHub (Apr 17, 2020):

Yes, it works @StefH !!
Thanks for the fix.

@Rutenioh commented on GitHub (Apr 17, 2020): Yes, it works @StefH !! Thanks for the fix.
Author
Owner

@StefH commented on GitHub (Apr 17, 2020):

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

@StefH commented on GitHub (Apr 17, 2020): https://github.com/WireMock-Net/WireMock.Net/pull/454
Author
Owner

@StefH commented on GitHub (Apr 17, 2020):

A new official nuget will be released shortly.

@StefH commented on GitHub (Apr 17, 2020): A new official nuget will be released shortly.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/WireMock.Net-wiremock#267