InjectProperties Throws Exception "Operation could destablilize the runtime" with 3 or more injectable properties

May 14, 2012 at 3:05 PM

Hello,

When a class has has 3 or more injectable properties, I'm getting the error "operation could destablize the runtime".  When I comment down to 2, it runs fine.  It's always 3 or more in my testing.

What is the cause of this error?

Thanks.

Coordinator
May 14, 2012 at 5:25 PM

Thanks for reporting this, but unfortunately I'm not able to reproduce this issue. Can you please supply me with the following information:

  1. Which version of the Simple Injector are you using?
  2. Which version of .NET or Silverlight are you using?
  3. Are you running in full trust, partial trust, or some custom configuration?
  4. What is the exact stack trace of the exception?
  5. Please supply me with the minimum code that reproduces this issue: the container configuration, types that are injected and the type that is being injected into.

If you are able to supply this, I'll do my best to give a solution for your problem in the form of advice, a workaround or possibly a new release of the container.

Oct 2, 2012 at 10:34 PM

This is not the detail you requested, but I encountered this today while experimenting with implicit property injection. Going back to either constructor injection or service locator works around the issue. (Not that I particularly wanted to use implicit property injection, mind you.)

Coordinator
Oct 3, 2012 at 6:53 AM

If you can give more information to reproduce this issue, it would be highly appreciated. I'm very anxious to solve this issue, but I really need more information, since I'm unable to reproduce it.

Nov 13, 2012 at 7:31 AM

Hello,

I seem to have encountered a similar problem. Here comes the sample code to reproduce it. After spending some time by observation, it seems to be combination of following parameters: .NET 4 AND  UserControl successor AND number of properties to inject greater than 2. 

 

 

using System.Windows.Forms;
using SimpleInjector;

namespace ConsoleApplication1
{
    public interface ITest1
    {
        void Test();
    }

    public class Test1 : ITest1
    {
        public void Test()
        { }
    }


    public interface ITest2
    {
        void Test();
    }

    public class Test2 : ITest2
    {
        public void Test()
        {}
    }

    public interface ITest3
    {
        void Test();
    }

    public class Test3 : ITest3
    {
        public void Test()
        {}
    }

    public class TestConsumer: UserControl
    {
        public ITest1 Test1 { get; set; }
        public ITest2 Test2 { get; set; }
        public ITest3 Test3 { get; set; }
    }

    class Program
    {
        static void Main(string[] args)
        {
            var container = new Container();
            container.RegisterSingle<ITest1>(new Test1());
            container.RegisterSingle<ITest2>(new Test2());
            container.RegisterSingle<ITest3>(new Test3());

            var testConsumer = new TestConsumer();
            container.InjectProperties(testConsumer);
        }


    }
}

 

 

Coordinator
Nov 13, 2012 at 8:33 AM
This discussion has been copied to a work item. Click here to go to the work item and continue the discussion.
Coordinator
Nov 13, 2012 at 8:36 AM

Thanks for reporting this. I've been able to reproduce the issue and will try to fix this a.s.a.p.

Coordinator
Nov 15, 2012 at 4:24 PM
Edited Nov 15, 2012 at 4:30 PM

I'm pleased to announce this bug has been fixed in version 1.6 that just has been released.

Marked as answer by dot_NET_Junkie on 11/4/2013 at 2:03 AM
Nov 16, 2012 at 6:04 AM

Thank you very much! I can confirm that new version 1.6 resolved that..