{"action":"opened","issue":{"url":"https://api.github.com/repos/autofac/Autofac.Mef/issues/2","labels_url":"https://api.github.com/repos/autofac/Autofac.Mef/issues/2/labels{/name}","comments_url":"https://api.github.com/repos/autofac/Autofac.Mef/issues/2/comments","events_url":"https://api.github.com/repos/autofac/Autofac.Mef/issues/2/events","html_url":"https://github.com/autofac/Autofac.Mef/issues/2","id":99261482,"number":2,"title":"Parameters passed in Resolve() do not get injected into MEF classes","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-08-05T17:50:26Z","updated_at":"2015-08-05T17:50:26Z","closed_at":null,"body":"_From @passuied on August 5, 2015 17:47_\n\nI have a class defined in MEF as such:\r\n```\r\n[PartCreationPolicy(CreationPolicy.NonShared)]\r\n    [Export(typeof(CoreSystemEvent))]\r\n    [ExportMetadata(CoreSystemEvent.EventTypeIDKey, 603)]\r\n    public class DigestEmailProcessEvent : CoreSystemEvent\r\n    {\r\n        public Func<CoreModel.BO.Container, IDigestProcessor> DigestProcessorFactory { get; protected set; }\r\n        public Func<string, int, int, CoreModel.BO.Container> ContainerFactory { get; protected set; }\r\n\r\n        [ImportingConstructor]\r\n        public DigestEmailProcessEvent(string corpName, Func<CoreModel.BO.Container, IDigestProcessor> digestProcessorFactory, Func<string, int, int, CoreModel.BO.Container> containerFactory)\r\n            : base(corpName)\r\n        {\r\n            this.DigestProcessorFactory = digestProcessorFactory;\r\n            this.ContainerFactory = containerFactory;\r\n        }\r\n\r\n}\r\n```\r\n\r\nI am trying to resolve it inside an AutoFac Factory as follows:\r\n```\r\n// Container Factory\r\n            builder.Register<Func<string, int, int, CoreModel.BO.Container>>(c =>\r\n             {\r\n                 var context = c.Resolve<IComponentContext>();\r\n                 return (corpName, actorId, cultureId) =>\r\n                 {\r\n                     IUserContext userContext = UserContext.CreateUserContextWithOutTimeZoneID(corpName, actorId, cultureId);\r\n                     return new EntityManager(userContext).Container;\r\n                 };\r\n\r\n             }\r\n\r\n             ).Exported(c => c.As<Func<string, int, int, CoreModel.BO.Container>>());\r\n\r\n\r\n            // Digest Processor Factory\r\n            builder.Register<Func<CoreModel.BO.Container, IDigestProcessor>>(c =>\r\n            {\r\n                var context = c.Resolve<IComponentContext>();\r\n                return (container) => context.Resolve<IDigestProcessor>(new NamedParameter(\"container\", container));\r\n\r\n            }\r\n                ).Exported(c => c.As<Func<CoreModel.BO.Container, IDigestProcessor>>());\r\n\r\n            //builder.RegisterInstance(\"TestCorp\")\r\n            //        .Exported(c => c.AsNamed<string>(\"corpName\"));\r\n\r\n            //// CoreSystemEvent Factory\r\n            builder.Register<Func<string, int, CoreSystemEvent>>(c =>\r\n            {\r\n                var context = c.Resolve<IComponentContext>();\r\n\r\n                return (corpName, eventTypeID) =>\r\n                {\r\n                    var plugins = context.Resolve<IEnumerable<Meta<Lazy<CoreSystemEvent>>>>(new NamedParameter(\"corpName\", corpName));\r\n                    var plugin = plugins\r\n                         // extension method I created myself to return the plugin with targeted metadata value\r\n                        .WithMetadata(CoreSystemEvent.EventTypeIDKey, eventTypeID);\r\n\r\n                    return plugin;\r\n\r\n                };\r\n            }\r\n```\r\nHowever, I get the error:\r\n\"The requested service 'ContractName=System.String' has not been registered. To avoid this exception, either register a component to provide the service, check for service registration using IsRegistered(), or use the ResolveOptional() method to resolve an optional dependency.\"\r\n\r\nIsn't it possible to inject parameter values to MEF defined classes?\r\n\r\nIf I mark corpName with [Import(AllowDefault=true)], the object gets instantiated but obviously corpName stays null...\r\n\r\n\r\nThanks,\r\nPatrick\n\n_Copied from original issue: autofac/Autofac#671_"}}