1

I've created a new fresh vanilla MVC 5 .net 4.5 project, and added StructureMap as a Nuget package. Nothing extra added like models or interfaces yet.

All works fine until I add this row in Global.asax.cs: StructuremapMvc.Start();

I get error that I can't register a module when application have initialized?!

My IoC.cs file looks like this:

public static IContainer Initialize() {
            ObjectFactory.Initialize(x =>
                        {
                           x.Scan(scan =>
                                    {
                                        scan.TheCallingAssembly();
                                        scan.WithDefaultConventions();
                                    });
                        });
            return ObjectFactory.Container;

1 Answer 1

3

All works fine until I add this row in Global.asax.cs: StructuremapMvc.Start(); I get error that I can't register a module when application have initialized?!

You don't need to use 'StructuremapMvc.Start();' method because it's been already defined in StructureMapMvc.cs:

[assembly: PreApplicationStartMethod(typeof(StructuremapMvc), "Start")]
[assembly: ApplicationShutdownMethod(typeof(StructuremapMvc), "End")]
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.