{"id":5224,"date":"2014-03-30T19:56:07","date_gmt":"2014-03-30T19:56:07","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2014\/03\/30\/problem-about-simple-injector-collection-of-common-programming-errors\/"},"modified":"2014-03-30T19:56:07","modified_gmt":"2014-03-30T19:56:07","slug":"problem-about-simple-injector-collection-of-common-programming-errors","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2014\/03\/30\/problem-about-simple-injector-collection-of-common-programming-errors\/","title":{"rendered":"problem about simple-injector-Collection of common programming errors"},"content":{"rendered":"<ul>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/9a2f6938014ee61a983046e4cad6e233?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nqujck<br \/>\nc# dependency-injection ioc-container simple-injector<br \/>\nI have this code:using (container.BeginLifetimeScope()) {RenderWord instruction = new RenderWord();var instances = container.GetAllInstances&lt;IInstructionHandler&lt;RenderWord&gt;&gt;();var firstInstance = result.First(); }instances is of type IEnumerable&lt;IInstructionHandler&lt;RenderWord&gt;&gt;firstInstance is of type IInstructionHandler&lt;RenderWord&gt; that in reality is an instance of a decorator that decorates another decorator that decorates another decorator &#8230;At runtime the actua<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/b9f81801b50ddbd023d2bf3ef5c03e91?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nSteven<br \/>\nc# .net dependency-injection quartz.net simple-injector<br \/>\nCurrently I am writing a service using Quartz.NET to schedule the running of it.I was wondering if anyone has any experience of using constructor injection with Quartz.NET and Simple Injector.Below is essentially what I wish to achievepublic class JobImplementation: IJob {private readonly IInjectedClass injectedClass;public JobImplementation(IInjectedClass _injectedClass){injectedClass = _injectedClass}public void Execute(IJobExecutionContext _context){\/\/Job code}<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/b9f81801b50ddbd023d2bf3ef5c03e91?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nSteven<br \/>\nc# dependency-injection inversion-of-control simple-injector<br \/>\nCan I register initializers for Generic types with SimpleInjector at runtime? (see the last line of code below)public class BootStrapper {Type baseTypeGeneric = typeof(Sample&lt;&gt;);public void BootStrap(Container container){var types =from type in Assembly.GetExecutingAssembly().GetTypes()where type.Namespace == &#8220;NS.xyz&#8221; select type;foreach (Type type in types){Type baseType = baseTypeGeneric.MakeGenericType(type);if (type.BaseType == baseType){container.Register(type);}\/\/how do I get this li<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/8fcf279def5c1abd4cdf30b974dd8787?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nDavid<br \/>\nc# .net dependency-injection simple-injector webformsmvp<br \/>\nI&#8217;m trying to combine SimpleInjector with WebFormsMvp.To facilitate DI WebFormsMvp provides the IPresenterFactory interface. It contains the Create method which provides the presenter type to resolve and the view instance. I need to inject the view instance into the constructor of the presenter. The presenter also has other dependencies that need creating by the container.This is what I got so far, but it is not ideal. What&#8217;s the correct solution for the problem?Presenter constructor:public FooP<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/bf3eafe58d6aba3dbab9d64307aeb6fb?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nADNow<br \/>\nentity-framework dependency-injection simple-injector<br \/>\nI am trying to switch to Simple Injector Dependency Injection framework as I am impressed with its speed.private static void RegisterServices(Container container){container.RegisterPerWebRequest&lt;IDbContext, DbContext1&gt;();\/\/\/\/container.RegisterPerWebRequest&lt;IDbContext, DbContext2&gt;(); container.RegisterPerWebRequest&lt;IUnitOfWork, UnitOfWork&gt;();container.RegisterPerWebRequest&lt;IColourRepository, ColourRepository&gt;();where DbContext1 and DbContext2 inherit from a BaseDbContex<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/b9f81801b50ddbd023d2bf3ef5c03e91?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nSteven<br \/>\nasp.net-mvc entity-framework dependency-injection ninject simple-injector<br \/>\nSimple Inject is throwing the following exception when attempting to register my DbContext. The supplied connection string is not valid, because it contains insufficient mapping or metadata information.Parameter name: connectionStringI&#8217;m new to DI and could be missing something fairly obvious. The connection string looks fine. It is the same one that gets used to create the DbContext normally. I was attempting the solution herepublic static class SimpleInjectorInitializer {\/\/\/ &lt;summary&gt;Ini<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/b9f81801b50ddbd023d2bf3ef5c03e91?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nSteven<br \/>\n.net architecture dependency-injection simple-injector<br \/>\nI have an Entity Framework application connecting to an SQL server on a separate box. The program flow can be broken down in to two states:Init the composition root and register types using the Simple Injector DI framework Init application (does some reads and writes with the SQL database using Entity Framework) Based on a timer, a task function gets an instance for a command that is due to run ICommandHandler&lt;CommandType&gt; (command types vary) Calls Handle(commandType) on this instance to<\/li>\n<\/ul>\n<p>Web site is in building<\/p>\n","protected":false},"excerpt":{"rendered":"<p>qujck c# dependency-injection ioc-container simple-injector I have this code:using (container.BeginLifetimeScope()) {RenderWord instruction = new RenderWord();var instances = container.GetAllInstances&lt;IInstructionHandler&lt;RenderWord&gt;&gt;();var firstInstance = result.First(); }instances is of type IEnumerable&lt;IInstructionHandler&lt;RenderWord&gt;&gt;firstInstance is of type IInstructionHandler&lt;RenderWord&gt; that in reality is an instance of a decorator that decorates another decorator that decorates another decorator &#8230;At runtime the actua Steven c# .net dependency-injection [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-5224","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/5224","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/comments?post=5224"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/5224\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=5224"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=5224"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=5224"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}