Parts get constructed multiple times

Jul 19, 2013 at 11:23 PM
I want to use MEF in my WP8 app, so I grabbed the OOB sources and recompiled adding only the WP8 target to the PCLs - nothing else has been changed.

My problem is that I have a couple of exports of which two of them require the same import. What happens is that the import in question gets constructed twice - contrary to what I would have expected. In the assemblies produced, there is no PartCreationPolicy - and I would have expected that the default sharing would been preserved.

Any ideas how to solve this?

Jul 20, 2013 at 12:04 AM
Hi did you try using Microsoft.composition on nuget. ? It is mef for the win8.

Jul 20, 2013 at 12:14 AM
I did. But, I want this to work for WP8.

I did however, find the solution. For some reason I had gotten things wrong that parts are by default non-shared, and then I found the [Shared] attribute, which solved my problem. Thanks for the reply, tough :)