November Happy Hour will be moved to Thursday December 5th.
AI OnAI Off
November Happy Hour will be moved to Thursday December 5th.
So if you have registered an instance as a named instance in StructureMap, e.g like:
public void ConfigureContainer(ServiceConfigurationContext context) { context.StructureMap().Configure(c => { c.For<IMyInterface>().Use<MyInstance>().Named("myKey"); }); }
then to receive your named instance using ServiceLocator.Current you need to cast it to StructureMapServiceLocator, like:
(ServiceLocator.Current as StructureMapServiceLocator).GetInstance<IMyInterface>("myKey");
I am responsible for a customer site that we want to upgrade from Epi v.10.10.0 to newest 11.x version.
We have upgraded as many components to as recent versions as as possible, including EPiServer.Location.StructureMap.
The main problem we are facing is in fact connected to StructureMap,
We have a lot of this type of code in the existing application:
var myObj= ServiceLocator.Current.GetInstance();
However, this is failing with the following message:
An exception of type 'EPiServer.ServiceLocation.ActivationException' occurred in EPiServer.Framework.dll but was not handled in user code
Additional information: Activation error occurred while trying to get instance of type IMemberShipLoader, key ""
This code worked perfectly well in Epi 10.
How would we go about obtaining the same result in Epi 11? The release notes from EPiServer tell us "The specific implementation in EPiServer.ServiceLocation.StructureMap supports named instances.", but which calls are we actualy supposed to make?
Any help would be appreciated.
Below I have also attached the packages.config for the main project.