{"action":"created","issue":{"url":"https://api.github.com/repos/autofac/Autofac/issues/907","repository_url":"https://api.github.com/repos/autofac/Autofac","labels_url":"https://api.github.com/repos/autofac/Autofac/issues/907/labels{/name}","comments_url":"https://api.github.com/repos/autofac/Autofac/issues/907/comments","events_url":"https://api.github.com/repos/autofac/Autofac/issues/907/events","html_url":"https://github.com/autofac/Autofac/issues/907","id":314310006,"number":907,"title":"NoConstructorsFoundException for valid internal registrations","user":{"login":"0x084E","id":7345141,"avatar_url":"https://avatars1.githubusercontent.com/u/7345141?v=4","gravatar_id":"","url":"https://api.github.com/users/0x084E","html_url":"https://github.com/0x084E","followers_url":"https://api.github.com/users/0x084E/followers","following_url":"https://api.github.com/users/0x084E/following{/other_user}","gists_url":"https://api.github.com/users/0x084E/gists{/gist_id}","starred_url":"https://api.github.com/users/0x084E/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/0x084E/subscriptions","organizations_url":"https://api.github.com/users/0x084E/orgs","repos_url":"https://api.github.com/users/0x084E/repos","events_url":"https://api.github.com/users/0x084E/events{/privacy}","received_events_url":"https://api.github.com/users/0x084E/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2018-04-14T08:12:22Z","updated_at":"2018-04-14T15:55:28Z","closed_at":null,"author_association":"NONE","body":"I have a own ConstructorFinder which also searches for non-public constructors and an extension method ``WithNonPublicConstructors`` which calls ``FindConstructorsWith`` with my ConstructorFinder.\r\n\r\nThis has (partially) stopped working after the 4.7.0 update. If i now call\r\n```\r\nbuilder.RegisterType<MyType>().AsSelf().WithNonPublicConstructors().SingleInstance();\r\n```\r\nthis throws an NoConstructorsFoundException in the call to AsSelf\r\n```\r\nAutofac.Core.Activators.Reflection.NoConstructorsFoundException: No accessible constructors were found for the type 'MyType'.\r\n   at Autofac.Core.Activators.Reflection.DefaultConstructorFinder.GetDefaultPublicConstructors(Type type)\r\n   at Autofac.Core.Activators.Reflection.DefaultConstructorFinder.FindConstructors(Type targetType)\r\n   at Autofac.Core.Activators.Reflection.ReflectionActivator..ctor(Type implementationType, IConstructorFinder constructorFinder, IConstructorSelector constructorSelector, IEnumerable`1 configuredParameters, IEnumerable`1 configuredProperties)\r\n   at Autofac.Builder.ConcreteReflectionActivatorData.get_Activator()\r\n   at Autofac.RegistrationExtensions.AsSelf[TLimit,TConcreteActivatorData](IRegistrationBuilder`3 registration)\r\n   at AutofacModule.Load(ContainerBuilder builder)\r\n   at Autofac.Module.Configure(IComponentRegistry componentRegistry)\r\n   at Autofac.ContainerBuilder.Build(IComponentRegistry componentRegistry, Boolean excludeDefaultModules)\r\n   at Autofac.ContainerBuilder.UpdateRegistry(IComponentRegistry componentRegistry)\r\n   at Autofac.Core.Lifetime.LifetimeScope.CreateScopeRestrictedRegistry(Object tag, Action`1 configurationAction)\r\n   at Autofac.Core.Lifetime.LifetimeScope.BeginLifetimeScope(Object tag, Action`1 configurationAction)\r\n```\r\n\r\nIf I call WithNonPublicConstructors before AsSelf everything is working as before.\r\n"},"comment":{"url":"https://api.github.com/repos/autofac/Autofac/issues/comments/381338898","html_url":"https://github.com/autofac/Autofac/issues/907#issuecomment-381338898","issue_url":"https://api.github.com/repos/autofac/Autofac/issues/907","id":381338898,"user":{"login":"tillig","id":1156571,"avatar_url":"https://avatars2.githubusercontent.com/u/1156571?v=4","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},"created_at":"2018-04-14T15:55:28Z","updated_at":"2018-04-14T15:55:28Z","author_association":"CONTRIBUTOR","body":"This is definitely something we need to look at. The _order_ of those calls is now important. Wow.\r\n\r\nWell, I'm glad you have a workaround so you're not stuck. Let us see what we can do. I'm not sure why AsSelf is invoking a constructor finder at registration time. I don't think it should be."}}
{"actor":{"display_login":"tillig"}}