This project has moved. For the latest updates, please go here.

getting "Sequence contains no matching element" error when running katana.exe

May 3, 2013 at 7:54 PM
Edited May 3, 2013 at 7:59 PM
Hi,

I have a Web API application which I manged to host through the katana bits on my own exe (the code is here: https://github.com/tugberkugurlu/PingYourPackage/tree/katana-host/src/apps/PingYourPackage.API.KatanaHost)

I also created a seperate application to host the the application through the katana.exe but I am unable to run it. I ran the exe with the following command under my application path and the bin directory exists with the assemblies inside it.
..\..\..\packages\Katana.0.22.0-pre-20417-201\tools\Katana.exe
The error I'm getting is the below one:
Error: System.InvalidOperationException
Sequence contains no matching element
The code is available here: https://github.com/tugberkugurlu/PingYourPackage/tree/katana-host/src/apps/PingYourPackage.API.OwinHost

What would be the problem?
Coordinator
May 3, 2013 at 10:36 PM
Can you post the whole stack trace?
May 4, 2013 at 7:09 AM
Edited May 4, 2013 at 7:11 AM
Hi Tratcher,

Thanks for the answer. I'm unable to view the stack trace (maybe I don't know how). I tried the verbose switch but it didn't get me the detailed error message, too:

Image

You can clone my project, switch to katana-host and get it working if you need to have a better view: https://github.com/tugberkugurlu/PingYourPackage/tree/katana-host

Here is the complete view of my Startup class:
using Owin;
using PingYourPackage.API.Config;
using System;
using System.Collections.Generic;
using System.Data.Entity.Migrations;
using System.Web.Http;

namespace PingYourPackage.API.OwinHost {

    public partial class Startup {

        public void Configuration(IAppBuilder app) {

            HttpConfiguration config = new HttpConfiguration();
            AutofacWebAPI.Initialize(config);
            RouteConfig.RegisterRoutes(config);
            WebAPIConfig.Configure(config);

            var efMigrationSettings = new PingYourPackage.Domain.Migrations.Configuration();
            var efMigrator = new DbMigrator(efMigrationSettings);
            efMigrator.Update();

            RegisterAddresses(app);
            app.UseWebApi(config);
        }

        private void RegisterAddresses(IAppBuilder app) {

            Uri HostUri = new Uri("http://localhost:16897/");
            Uri HostUriHttps = new Uri("https://localhost:44368/");

            // NOTE: OwinServerFactoryAttribute.Create method and 
            //       OwinHttpListener.Start should give you a hint on how
            //       to register the addresses.
            app.Properties["host.Addresses"] = new List<IDictionary<string, object>> {
                new Dictionary<string, object> { 
                    { "scheme", HostUri.Scheme },
                    { "host", HostUri.Host },
                    { "port", HostUri.Port.ToString()  }
                },

                new Dictionary<string, object> { 
                    { "scheme", HostUriHttps.Scheme },
                    { "host", HostUriHttps.Host },
                    { "port", HostUriHttps.Port.ToString()  }
                }
            };
        }
    }
}
May 4, 2013 at 12:59 PM
OK, I simplified the failing sample. Here it is: https://github.com/tugberkugurlu/OwinSamples/tree/master/WebApiHelloOwin/WebApiHelloOwin

Just run the Run.cmd there. You should see the "Sequence contains no matching element" error.

This is a class library project + it outputs the assemblies directly under the bin directory; not under bin\Debug or bin\Release.
Coordinator
May 4, 2013 at 3:46 PM
Ah, it looks like you're trying to mix package versions. You have v0.22 of Katana.exe but v1.1 of Microsoft.Owin.Host.HttpListener. There have been some updates in the loading contract between the two, so you need to use the same versions together. FYI: Katana.exe has been renamed to OwinHost.exe, which is probably why you're using an old version. It looks like it works with the new version.