{"action":"closed","issue":{"url":"https://api.github.com/repos/introtocomputerscience/azure-function-autofac-dependency-injection/issues/15","repository_url":"https://api.github.com/repos/introtocomputerscience/azure-function-autofac-dependency-injection","labels_url":"https://api.github.com/repos/introtocomputerscience/azure-function-autofac-dependency-injection/issues/15/labels{/name}","comments_url":"https://api.github.com/repos/introtocomputerscience/azure-function-autofac-dependency-injection/issues/15/comments","events_url":"https://api.github.com/repos/introtocomputerscience/azure-function-autofac-dependency-injection/issues/15/events","html_url":"https://github.com/introtocomputerscience/azure-function-autofac-dependency-injection/issues/15","id":335306922,"node_id":"MDU6SXNzdWUzMzUzMDY5MjI=","number":15,"title":"Not working with Azure durable activity function","user":{"login":"goldytech","id":1241633,"node_id":"MDQ6VXNlcjEyNDE2MzM=","avatar_url":"https://avatars0.githubusercontent.com/u/1241633?v=4","gravatar_id":"","url":"https://api.github.com/users/goldytech","html_url":"https://github.com/goldytech","followers_url":"https://api.github.com/users/goldytech/followers","following_url":"https://api.github.com/users/goldytech/following{/other_user}","gists_url":"https://api.github.com/users/goldytech/gists{/gist_id}","starred_url":"https://api.github.com/users/goldytech/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/goldytech/subscriptions","organizations_url":"https://api.github.com/users/goldytech/orgs","repos_url":"https://api.github.com/users/goldytech/repos","events_url":"https://api.github.com/users/goldytech/events{/privacy}","received_events_url":"https://api.github.com/users/goldytech/received_events","type":"User","site_admin":false},"labels":[{"id":733325460,"node_id":"MDU6TGFiZWw3MzMzMjU0NjA=","url":"https://api.github.com/repos/introtocomputerscience/azure-function-autofac-dependency-injection/labels/bug","name":"bug","color":"ee0701","default":true},{"id":1013608722,"node_id":"MDU6TGFiZWwxMDEzNjA4NzIy","url":"https://api.github.com/repos/introtocomputerscience/azure-function-autofac-dependency-injection/labels/fixed","name":"fixed","color":"0052cc","default":false},{"id":1010925728,"node_id":"MDU6TGFiZWwxMDEwOTI1NzI4","url":"https://api.github.com/repos/introtocomputerscience/azure-function-autofac-dependency-injection/labels/verified","name":"verified","color":"0e8a16","default":false}],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":17,"created_at":"2018-06-25T08:27:22Z","updated_at":"2018-08-03T12:19:50Z","closed_at":"2018-08-03T12:19:50Z","author_association":"NONE","body":"Hi,\r\nI'm using this library in my Azure durable functions app.\r\nI've defined my DIConfig as follows, and when the function app starts I can see the ctor of this class is called with my activity function class name as functionName parameter value.\r\n\r\n\r\n```\r\n public  class DIConfig\r\n    {\r\n        /// <summary>\r\n        /// Initializes a new instance of the <see cref=\"DIConfig\"/> class.\r\n        /// </summary>\r\n        /// <param name=\"functionName\">\r\n        /// The function name.\r\n        /// </param>\r\n        public DIConfig(string functionName)\r\n        {\r\n            DependencyInjection.Initialize(\r\n                containerBuilder =>\r\n                    {\r\n                        containerBuilder.RegisterType<AuthenticationService>().As<IOAuthService>();\r\n                        containerBuilder.RegisterType<GenericAPIService>().As<IGenericAPIService>();\r\n                        containerBuilder.RegisterType<EmailTemplateNotificationService>().As<IEmailTemplateNotificationService>();\r\n                        containerBuilder.RegisterType<AicGenericSdk>().As<IAicGenericSdk>();\r\n                       containerBuilder.RegisterType<AgreementExpiryService>().As<IAgreementExpiryService>();\r\n                        containerBuilder.RegisterType<EmailReminderService>().As<IEmailReminderService>();\r\n                    },\r\n                functionName);\r\n        }\r\n    }\r\n```\r\n\r\nBelow is the code of my activity function , where I'm want to use DI\r\n\r\n```\r\n  [DependencyInjectionConfig(typeof(DIConfig))]\r\n    public static  class EmailReminderActivities\r\n    {\r\n     \r\n        [FunctionName(\"A_GetAgreementsForEmailReminder\")]\r\n        public static List<AgreementModel> GetAgreementsForEmailReminder(\r\n            [ActivityTrigger] string input,\r\n            TraceWriter log,\r\n            [Inject] IEmailReminderService emailReminderService)\r\n        {\r\n            \r\n          return (List<AgreementModel>)emailReminderService.GetAgreementsForReminderDate(input);\r\n        }\r\n    }\r\n```\r\n\r\nThis is the error I'm getting\r\n\r\n> A ScriptHost error has occurred\r\n[6/25/2018 8:20:44 AM] Exception while executing function: A_GetAgreementsForEmailReminder. Microsoft.Azure.WebJobs.Host: Exception binding parameter 'emailReminderService'. AzureFunctions.Autofac: DependencyInjection.Initialize must be called before dependencies can be resolved.\r\nIf I would have not use DI then this is how I would have initialize my EmailReminderService\r\n\r\n ` var emailReminderSvc = new EmailReminderService(new AicGenericSdk(new GenericAPIService(new AuthenticationService()),null ));`\r\n\r\nI hope I've registered dependencies in the right order.\r\nPlease help\r\n\r\n"}}
{"actor":{"display_login":"vandersmissenc"}}