{"action":"opened","issue":{"url":"https://api.github.com/repos/autofac/Autofac.WebApi/issues/4","labels_url":"https://api.github.com/repos/autofac/Autofac.WebApi/issues/4/labels{/name}","comments_url":"https://api.github.com/repos/autofac/Autofac.WebApi/issues/4/comments","events_url":"https://api.github.com/repos/autofac/Autofac.WebApi/issues/4/events","html_url":"https://github.com/autofac/Autofac.WebApi/issues/4","id":95764527,"number":4,"title":"Null Reference with a combination of ODataController and RegisterWebApiFilterProvider when starting the app in the Owin pipeline.","user":{"login":"tillig","id":1156571,"avatar_url":"https://avatars.githubusercontent.com/u/1156571?v=3","gravatar_id":"","url":"https://api.github.com/users/tillig","html_url":"https://github.com/tillig","followers_url":"https://api.github.com/users/tillig/followers","following_url":"https://api.github.com/users/tillig/following{/other_user}","gists_url":"https://api.github.com/users/tillig/gists{/gist_id}","starred_url":"https://api.github.com/users/tillig/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tillig/subscriptions","organizations_url":"https://api.github.com/users/tillig/orgs","repos_url":"https://api.github.com/users/tillig/repos","events_url":"https://api.github.com/users/tillig/events{/privacy}","received_events_url":"https://api.github.com/users/tillig/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2015-07-17T23:29:39Z","updated_at":"2015-07-17T23:29:39Z","closed_at":null,"body":"_From @SpiegelSoft on January 24, 2015 19:3_\n\nThis is similar to Issue https://github.com/autofac/Autofac/issues/561, but I think I have an accurate way to reproduce it.\r\n\r\nUsing Autofac.WebApi2, Version 3.4.0.\r\n\r\nBecause of the rules around SignalR integration, it is recommended to set up the container in the Owin startup pipeline.\r\n\r\nCreate a new web project, and add Microsoft.Owin.Host.SystemWeb.\r\n\r\nAdd a new file, called Startup.cs, containing the following content:\r\n\r\nusing System.Reflection;\r\nusing System.Web.Http;\r\nusing Autofac;\r\nusing Autofac.Integration.WebApi;\r\nusing Microsoft.Owin;\r\nusing Owin;\r\nusing SpiegelSoftUsers;\r\n\r\n[assembly: OwinStartup(typeof(Startup))]\r\n\r\nnamespace MyWebApp\r\n{\r\n    public class Startup\r\n    {\r\n        public void Configuration(IAppBuilder appBuilder)\r\n        {\r\n            var containerBuilder = new ContainerBuilder();\r\n            containerBuilder.RegisterApiControllers(Assembly.GetExecutingAssembly());\r\n            var config = GlobalConfiguration.Configuration;\r\n            containerBuilder.RegisterWebApiFilterProvider(config);\r\n            var container = containerBuilder.Build();\r\n            config.DependencyResolver = new AutofacWebApiDependencyResolver(container);\r\n        }\r\n    }\r\n}\r\n\r\nRun the web app, and navigate to /odata.\r\n\r\nThe result is\r\n\r\n{\r\n  \"error\":{\r\n    \"code\":\"\",\"message\":\"An error has occurred.\",\"innererror\":{\r\n      \"message\":\"Object reference not set to an instance of an object.\",\"type\":\"System.NullReferenceException\",\"stacktrace\":\"   at Autofac.Integration.WebApi.AutofacWebApiFilterProvider.GetFilters(HttpConfiguration configuration, HttpActionDescriptor actionDescriptor)\\r\\n   at System.Web.Http.Controllers.HttpActionDescriptor.<InitializeFilterPipeline>b__0(IFilterProvider fp)\\r\\n   at System.Linq.Enumerable.<SelectManyIterator>d__14`2.MoveNext()\\r\\n   at System.Linq.Buffer`1..ctor(IEnumerable`1 source)\\r\\n   at System.Linq.OrderedEnumerable`1.<GetEnumerator>d__0.MoveNext()\\r\\n   at System.Linq.Buffer`1..ctor(IEnumerable`1 source)\\r\\n   at System.Linq.Enumerable.<ReverseIterator>d__a0`1.MoveNext()\\r\\n   at System.Web.Http.Controllers.HttpActionDescriptor.<RemoveDuplicates>d__3.MoveNext()\\r\\n   at System.Linq.Buffer`1..ctor(IEnumerable`1 source)\\r\\n   at System.Linq.Enumerable.<ReverseIterator>d__a0`1.MoveNext()\\r\\n   at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)\\r\\n   at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)\\r\\n   at System.Web.Http.Controllers.HttpActionDescriptor.InitializeFilterPipeline()\\r\\n   at System.Lazy`1.CreateValue()\\r\\n   at System.Lazy`1.LazyInitValue()\\r\\n   at System.Lazy`1.get_Value()\\r\\n   at System.Web.Http.Controllers.HttpActionDescriptor.GetFilterPipeline()\\r\\n   at System.Web.Http.Controllers.HttpActionDescriptor.GetFilterGrouping()\\r\\n   at System.Web.Http.ApiController.ExecuteAsync(HttpControllerContext controllerContext, CancellationToken cancellationToken)\\r\\n   at System.Web.Http.Dispatcher.HttpControllerDispatcher.<SendAsync>d__1.MoveNext()\"\r\n    }\r\n  }\r\n}\r\n\r\nIf you move all of that setup code into WebApiConfig, the error goes away.\r\n\r\n\n\n_Copied from original issue: autofac/Autofac#617_"}}