MEF Exception Exception

I have a CompositionException with this message: "A ComposablePart of type" SomeService "cannot be re-arranged because it is in an invalid state. It can only be re-arranged if it has already been fully viewed or compiled."

An exception is thrown by this code:

public class SomeService : ISomeService
{       
   [Import(typeof(ISomeType))]
   public ISomeType SomeType { get; set; }

   public SomeService()
   {
      Container.ComposeParts(this);
   }
}

but everything is fine with this:

public class SomeService : ISomeService
{       
   [Import(typeof(ISomeType))]
   public ISomeType SomeType { get; set; }

   public SomeService()
   {
      this.SomeType = Container.GetExportedValue<ISomeType>();
   }
}

I have this code "Container.ComposeParts (this)" in other places and it works, but it doesn’t do it here.

I did not find anything interesting after googling with "cannot be redone because it is in an invalid state."

what does this message mean? Thank!

+3
source share
1 answer

, , CompositionContainer . diong, ?

+1

Source: https://habr.com/ru/post/1777664/


All Articles