For<IActionInvoker>().Use<InjectingActionInvoker>();
I have a web application developed in ASP.NET 2010. I have used the Dependency Injection with StructureMap in ASP.NET MVC. I'm trying to get started with Structure Map. This code is working on another machine but didn't run on my machine.
I've built a simple boot strapper, but when I run the website I get the following error:
StructureMap.Configuration.DSL.Expressions.CreatePluginFamilyExpression`1[System.Web.Mvc.IActionInvoker].Use: type argument 'TestWebsite.Web.Controllers.Factories.InjectingActionInvoker' violates the constraint of type parameter 'CONCRETETYPE'.
Code Blockpublic static void ConfigureStructureMap() { ObjectFactory.Initialize(x => { //registry per assembly recommended x.AddRegistry<WebRegistry>(); x.AddRegistry<ServiceRegistry>(); x.AddRegistry<SHARE.Data.DataRegistry>(); }); //if a class needs configuring on load then this is done here. Inherit from IStartUpTask ObjectFactory.GetAllInstances<IStartUpTask>() .Where(x => x.IsEnabled).ToList() .ForEach(t => t.Configure()); //This checks all is well. Not ideal to do in application_start though cause of calls to request object.... //ObjectFactory.AssertConfigurationIsValid(); } public class WebRegistry : Registry { public WebRegistry() { For<IFormsAuthentication> ().Use<FormsAuthenticationService>(); For<IAuthentication>().Use<BasicMembership>(); Scan(x => { x.AssemblyContainingType<IStartUpTask>(); x.AddAllTypesOf<IStartUpTask>(); x.WithDefaultConventions(); }); For<IActionInvoker>().Use<InjectingActionInvoker>(); SetAllProperties(c => { c.OfType<IActionInvoker>(); c.WithAnyTypeFromNamespaceContainingType<UserService>(); //our services c.WithAnyTypeFromNamespaceContainingType<AdminCookies>(); //cookie services }); }Could anyone please suggest on this issue. how it could be resolved? I am really getting troubled with it and need to resolve it asap. Any help would be greatly appreciated.
Thanks
Deepak
--
You received this message because you are subscribed to the Google Groups "structuremap-users" group.
To post to this group, send email to structure...@googlegroups.com.
To unsubscribe from this group, send email to structuremap-us...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msg/structuremap-users/-/Qp1hoewSMdIJ.
For more options, visit https://groups.google.com/groups/opt_out.