Search code examples
inversion-of-controlstructuremapobjectfactory

"StructureMapConfigurationException was caught" Could not find an Instance named 'cert5' for plugintype


my controller class

 IPaymentProcessor _paymentProcessor = ObjectFactory.Container.GetInstance<IPaymentProcessor>("cert5"); 

my IoC class

   x.For<IX509Cert>().Use<X509Cert>().Ctor<string>().Is(Settings.GetCreditCardCertFile(5)).Named("cert5");    

Solution

  • When using multiple credit card cert files it may be a better option to not use the IoC container. You can use an instance of the IPaymentprocesssor inside your controller directly instead.