Hi, I am having problems with structuremap again.
In Global.asax, I have an override of RegisterRoutes:
protected override void RegisterRoutes(RouteCollection routes)
ObjectFactory.BuildUp(this); // with or without this line, the next line breaks
var contentLoader = ServiceLocator.Current.GetInstance<IContentLoader>(); // breaks here
I have a configurable module, that gets called first (before RegisterRoutes):
public class DependencyResolverInitialization : IConfigurableModule
public void ConfigureContainer(ServiceConfigurationContext context)
IContainer container = IoC.Initialize();
GlobalConfiguration.Configuration.DependencyResolver = new StructureMapDependencyResolver(container);
I have referenced StructureMap from this location:
Now, in web.config, I am having this commented out:
<assemblyIdentity name="StructureMap" publicKeyToken="e60ad81abae3c223" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-220.127.116.11" newVersion="18.104.22.168" />
When I use ObjectFactory.WhatDoIHave();, I get the following error:
The type 'StructureMap.ObjectFactory' exists in both 'StructureMap.dll' and 'StructureMap.dll'
If I uncomment the web.config part, I get:
Missing requested Instance property "NamedIndexingService" for InstanceKey "6b1c69a3-1eba-470c-95fb-492045313561"
For the version with commented out dependentAssembly in web.config, I can comment out the problematic part of code, run the app, uncomment it and it works. I would really like a real solution instead of this tweak.
Any clues on what I'm doing wrong?
We need the versionredirect in order for the EPiServer core to load the correct version. Potentially you can try redirecting to a newer version given that it's backwards compatible with the old version. Removing the redirect will otherwise give you two different versions loaded in the same app domain which usually means trouble.
Hi, thx, but in that case I get:
Missing requested Instance property "NamedIndexingService" for InstanceKey "1c0b201e-8c75-49d0-90ce-2c9c25305f2a"
I have figured out that the line EndsWith("Service") makes the problem with NamedIndexingService.
policy => policy.NameMatches(name => name.EndsWith("Service")));
Without it, the exception doesn't occur.
I have removed it, since it is a part of a default convension and in the module public class ContentInitializableModule : IInitializableModule that subscibes to content events, I am manually getting the instance of my service class in public void Initialize(InitializationEngine context):
_contentService = ObjectFactory.GetInstance<IContentService>();