webadvanced / Structuremap.MVC5

Apache License 2.0
21 stars 9 forks source link

StructureMap initialized twice when used with Structuremap.WebApi2 #4

Closed pcoulter closed 10 years ago

pcoulter commented 10 years ago

I installed both StructureMap.MVC5 and StructureMap.WebApi2 in the same project. Doing so, caused IoC.Initialize() to be called twice. As a result, it seems that my singleton was created twice, leading to same strange results later on. I wrapped the method with a static _IsInitialized variable check, which solved the problem.

valmont commented 10 years ago

Both packages need to be updated with some current changes. These will be live today and will solve this problem.

valmont commented 10 years ago

It is also important to note that WebAPI and MVC do not use the same Resolver, you can read more here http://www.webadvanced.com/blog/asp.net-mvc-4-web-api-and-structuremap