Visual studio 2017 problem

47 views
Skip to first unread message

turkam

unread,
Oct 12, 2017, 10:49:32 AM10/12/17
to structuremap-users
Hi guys !

I'm trying to use StructureMap with Visual Studio 2017 and I have an Stackoverflow exception without knowing why.
If I open the project with Visual Studio 2012 and run it... every thing is working fine !

My test project is made with .Net 4.5 and the latest structuremap version.

Here is my simple test case :


        public interface IMyInterface{}

        public class MyClass : IMyInterface{}

        public void StructureMapTest()
        {
            //Using scan method
            var scanContainer = new Container(_ =>
            {
                _.Scan(x =>
                {
                    x.TheCallingAssembly();
                    x.WithDefaultConventions();
                });
            });

            //All good class1 is my MyClass
            var class1 = scanContainer.GetInstance<MyClass>();

            //Boom throws the stackoverflow exception
            var container = new Container(c =>
            {
                c.For<IMyInterface>().Use<MyClass>();
            }
            );

            //Never goes here because of exception
            var class2 = container.GetInstance<MyClass>();
        }


Do you have any idea what I am missing ?
Reply all
Reply to author
Forward
0 new messages