Lars Kemmann
Lars Kemmann

Reputation: 5674

Cannot repeatedly F5-deploy an OWIN Service Fabric application in VS 2015 RC

Steps to reproduce:

  1. Create an application (in my case, with two stateless services following the OWIN+Web API tutorial, and leaving each instance count at 1)
  2. F5-deploy to start the application -- everything works, and I can see the application in the Service Fabric Explorer
  3. Shift-F5 in VS 2015 (RC) to stop debugging -- the application continues to run in Service Fabric Explorer
  4. F5-deploy again -- an exception occurs in each stateless service, as follows:
System.Reflection.TargetInvocationException was unhandled by user code
  HResult=-2146232828
  Message=Exception has been thrown by the target of an invocation.
  Source=mscorlib
  StackTrace:
       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.Start(StartContext context)
       at Microsoft.Owin.Hosting.WebApp.Start(String url, Action`1 startup)
       at Infrastructure.OwinCommunicationListener.OpenAsync(CancellationToken cancellationToken) in C:\Users\Lars\Documents\Visual Studio 2015\Projects\WebApiSF\Infrastructure\OwinCommunicationListener.cs:line 47
       at Microsoft.ServiceFabric.Services.StatelessServiceBase.<OpenCommunicationListenerAsync>d__8.MoveNext()
  InnerException: 
       ErrorCode=5
       HResult=-2147467259
       Message=Access is denied
       NativeErrorCode=5
       Source=System
       StackTrace:
            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)
       InnerException: 

It works if I delete each application after step 3, and then unprovision the application type as well, before F5-deploying again in step 4. Merely deleting each application does not.

UPDATE: Rebuilding and F5-deploying seems to work intermittently, but simply F5-deploying doesn't, at least from what I could tell. I also thought for a little while that incrementing the ServiceManifest Version and ApplicationTypeVersion would help, but that didn't work consistently either. The only thing that consistently works is deleting and unprovisioning the application & application type.

I'm running VS 2015 RC as administrator, on Windows 8.1 Pro x64, and the services are .NET 4.5 just like in the tutorial.

Upvotes: 1

Views: 880

Answers (1)

Vaclav Turecek
Vaclav Turecek

Reputation: 9050

The error message here is key: Message=Access is denied.

Usually this means one of two things:

  1. The account that your service is running as (Network Service by default) doesn't have access to open a listener on the URL you want. A URL ACL must be set. Service Fabric does this automatically for you when you specify an input endpoint with type HTTP in your ServiceManifest.xml.
  2. Some other process is already using the port.

Given that it works the first time you deploy, it's probably not #1. And given that it works when you delete and unprovision the application, I would guess your host process isn't being terminated when you F5 again. When you F5 the second time, can you check to see if your service's service host process is still running?

Upvotes: 0

Related Questions