Search code examples
c#.netdependency-injectionuwpmef

MEF CompositionContainer in UWP


How and where to use MEF CompositionContainer in UWP? I tried to use it on OnLaunched() and in the builder of the start page, but the BadImageFormatException error occurred during the startup.

        public LoadingWindow()
    {
        InitializeComponent();
        var container = new CompositionContainer();
    }

Solution

  • UWP use Nuget package Microsoft.Composition instead System.Composition. https://blog.softwarepotential.com/porting-to-net-standard-2-0-part-2-porting-mef-1-0-to-mef-2-0-on-net-core/