webadvanced / Structuremap.MVC5

Apache License 2.0
21 stars 9 forks source link

System InvalidOperationException when using SM.MVC5 and SM AssertConfigurationIsValid #11

Open mdmoura opened 9 years ago

mdmoura commented 9 years ago

Hello,

When I added the following on DefaultRegistry:

For<IExample>().HttpContextScoped().Use<Example>();

I get the following error when using container.AssertConfigurationIsValid():

An exception of type 'System.InvalidOperationException' occurred in System.Core.dll but was not handled in user code.

I know that if I remove HttpContextScoped() it works. Why is that?

Thank You

eddiegroves commented 9 years ago

With SM3 you don't use HttpContextScoped. HttpContextScopedis replaced with the use of nested containers which SM.MVC5 implements for us. So just use For..Use with default Transient lifecycle.