Quantcast
Channel: MEF Import problem
Viewing all articles
Browse latest Browse all 3

MEF Import problem

$
0
0

I have used MEF with Prism before without issues. Now I try the simplest "stand-alone" MEF and I get problems.

I have 2 assemblies, one of them is a wpf application, the other is a lib (dll).

In the lib assembly one class (public, non-static) is named ExportedType and attributed with Export.
[Export]
public class ExportedType {... parameterless constructor here};

In the wpf assembly one class (the main window) has a field which is of the same type as the exported type mentioned above and is attributed with Import.
[Import]
public ExportedType exportedType;

In the wpf app OnStartup() method I set up the compositions as follows:
AssemblyCatalog catalogWithExports = new AssemblyCatalog(typeof(ExportedType).Assembly);
CompositionContainer container = new CompositionContainer(catalogWithExports);

But the exportedType field in the wpf assembly is always null (I am not trying to access it from the constructor of the main window).

What is the basics not working here ?
(output window does not give any clue, other tools available ?)


Viewing all articles
Browse latest Browse all 3

Trending Articles


HOY PANGIT, MAGBAYAD KA!


Henry el monstruo feliz para colorear e imprimir


Dama y vagabundo para pintar


Girasoles para colorear


Good Morning Quotes


RE: Mutton Pies (jameskoiman)


Hagibis (1946) by Francisco V. Coching


Ka riam ka beit bad ka por riam


Vimeo Create - Video Maker & Editor 1.6.0 by Vimeo Inc


Vimeo 3.42.1 by Vimeo Inc



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>