<?xml version="1.0" encoding="utf-8" ?>
<?xml-stylesheet type="text/xsl" href="RSS_xslt_style.asp" version="1.0" ?>
<rss version="2.0" xmlns:WebWizForums="http://syndication.webwiz.co.uk/rss_namespace/">
 <channel>
  <title>DevForce Community Forum : Composition issue on Shared instance</title>
  <link>http://www.ideablade.com/forum/</link>
  <description>This is an XML content feed of; DevForce Community Forum : Community Forum : Composition issue on Shared instance</description>
  <pubDate>Wed, 22 Apr 2026 14:40:50 -700</pubDate>
  <lastBuildDate>Fri, 22 Mar 2013 09:49:26 -700</lastBuildDate>
  <docs>http://blogs.law.harvard.edu/tech/rss</docs>
  <generator>Web Wiz Forums 9.69</generator>
  <ttl>360</ttl>
  <WebWizForums:feedURL>www.ideablade.com/forum/RSS_post_feed.asp?TID=3625</WebWizForums:feedURL>
  <image>
   <title>DevForce Community Forum</title>
   <url>http://www.ideablade.com/forum/forum_images/IdeaBlade_logo_tm.png</url>
   <link>http://www.ideablade.com/forum/</link>
  </image>
  <item>
   <title>Composition issue on Shared instance : This is most often the case if...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=3625&amp;PID=16113#16113</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=1005" rel="nofollow">mgood</a><br /><strong>Subject:</strong> 3625<br /><strong>Posted:</strong> 22-Mar-2013 at 9:49am<br /><br />This is most often the case if one of their direct or indirect dependencies cannot be resolved. I would make sure first that the dependencies are actually in the catalog. Are you using .NET 4.5? If so you should see quite detailed diagnostic messages from MEF in your output window pointing you towards the issue.]]>
   </description>
   <pubDate>Fri, 22 Mar 2013 09:49:26 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=3625&amp;PID=16113#16113</guid>
  </item> 
  <item>
   <title>Composition issue on Shared instance : Any advice then, we have classes...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=3625&amp;PID=16111#16111</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=1570" rel="nofollow">KitKat</a><br /><strong>Subject:</strong> 3625<br /><strong>Posted:</strong> 22-Mar-2013 at 9:34am<br /><br />Any advice then, we have classes that are Exported in an external module, that are not getting imported to classes in the main xap. &nbsp;We are using Composition.AddXapAsync.<div><br></div><div>Thank you,</div><div>Kat</div>]]>
   </description>
   <pubDate>Fri, 22 Mar 2013 09:34:13 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=3625&amp;PID=16111#16111</guid>
  </item> 
  <item>
   <title>Composition issue on Shared instance : Honestly, I don&amp;#039;t know where...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=3625&amp;PID=16109#16109</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=1005" rel="nofollow">mgood</a><br /><strong>Subject:</strong> 3625<br /><strong>Posted:</strong> 22-Mar-2013 at 9:18am<br /><br />Honestly, I don't know where to look for it anymore. Looks like I cleaned up my SkyDrive. I probably deleted the whole sample.]]>
   </description>
   <pubDate>Fri, 22 Mar 2013 09:18:17 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=3625&amp;PID=16109#16109</guid>
  </item> 
  <item>
   <title>Composition issue on Shared instance :  Good morning Marcel,	Any chance...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=3625&amp;PID=16103#16103</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=1570" rel="nofollow">KitKat</a><br /><strong>Subject:</strong> 3625<br /><strong>Posted:</strong> 22-Mar-2013 at 6:32am<br /><br />Good morning Marcel,<div><span ="apple-tab-span"="" style="white-space:pre">	</span>Any chance to get the test program you posted a link to above. &nbsp;As we are having a problem where the exports in our external modules are not being added to the composition.</div><div><br></div><div>Thank you,</div><div>Katerina</div><span style="font-size:10px"><br /><br />Edited by KitKat - 22-Mar-2013 at 6:33am</span>]]>
   </description>
   <pubDate>Fri, 22 Mar 2013 06:32:24 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=3625&amp;PID=16103#16103</guid>
  </item> 
  <item>
   <title>Composition issue on Shared instance : Great, I&amp;#039;ll talk with them.Thank...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=3625&amp;PID=15019#15019</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=1485" rel="nofollow">cefernan</a><br /><strong>Subject:</strong> 3625<br /><strong>Posted:</strong> 31-Oct-2012 at 3:41am<br /><br />Great, I'll talk with them.<div><br></div><div>Thank you so much.</div>]]>
   </description>
   <pubDate>Wed, 31 Oct 2012 03:41:26 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=3625&amp;PID=15019#15019</guid>
  </item> 
  <item>
   <title>Composition issue on Shared instance :   I wouldn&amp;#039;t use MEF in...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=3625&amp;PID=15016#15016</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=1005" rel="nofollow">mgood</a><br /><strong>Subject:</strong> 3625<br /><strong>Posted:</strong> 30-Oct-2012 at 5:18pm<br /><br />I wouldn't use MEF in the domain model. Using IoC in the domain model is a pretty frowned upon practice. To do proper dependency injection, the entities would have to be owned by the container, but that doesn't work, because they are owned by the EntityManager or OData, so what you are doing is pulling dependencies from a container, which is quite a bit of an&nbsp;anti-pattern. <div>&nbsp;</div><div>This non-standard use of Cocktail goes beyond the free support provided on this forum, but our Professional Services team will be more than happy to advise you on a proper approach and architecture for your situation. I'll have my sales team follow up.</div>]]>
   </description>
   <pubDate>Tue, 30 Oct 2012 17:18:10 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=3625&amp;PID=15016#15016</guid>
  </item> 
  <item>
   <title>Composition issue on Shared instance :  Yes, we are using Cocktail 2012...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=3625&amp;PID=15002#15002</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=1485" rel="nofollow">cefernan</a><br /><strong>Subject:</strong> 3625<br /><strong>Posted:</strong> 30-Oct-2012 at 9:53am<br /><br />Yes, we are using Cocktail 2012 in the Silverlight side.<div><br></div><div>We are developing an application in Silverlight and we intend to expose services through OData. We will use the same features in different technologies. So, we decided to put our main business logic in the DomainModel project. The better approach that we found was that, because we don't want to duplicate code. We are using MEF in the DomainModel logic, because of this we need to start a MEF container in Silverlight/OData and pass them to the DomainModel.</div><div><br></div><div>OData:</div><div><div>&nbsp; &nbsp; &nbsp; &nbsp; private void Compose()</div><div>&nbsp; &nbsp; &nbsp; &nbsp; {</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; var catalog = new AggregateCatalog();</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; catalog.Catalogs.Add(new AssemblyCatalog(Assembly.GetExecutingAssembly()));</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; catalog.Catalogs.Add(new AssemblyCatalog(Assembly.Load("DomainModel")));</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; var container = new CompositionContainer(catalog);</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; container.ComposeParts(this);</div><div><br></div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<b> StaticContainer.DefaultContainer = container;</b></div><div>&nbsp; &nbsp; &nbsp; &nbsp; }</div></div><div><br></div><div>Silverlight:</div><div><div>&nbsp; &nbsp; public class AppBootstrapper : BootstrapperBase&lt;ShellViewModel&gt;</div><div>&nbsp; &nbsp; {</div><div>&nbsp; &nbsp; &nbsp; &nbsp; protected override void PrepareCompositionContainer(CompositionBatch batch)</div><div>&nbsp; &nbsp; &nbsp; &nbsp; {</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; base.PrepareCompositionContainer(batch);</div><div><br></div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <b>&nbsp; StaticContainer.DefaultContainer = IdeaBlade.Core.Composition.CompositionHost.Instance.Container;</b></div><div>&nbsp; &nbsp; &nbsp; &nbsp; }</div><div>&nbsp; &nbsp; }</div></div><div><br></div><div>Do you have any suggestion? Do you see any problem in the strategy? Is there any problem in use DevForce container?</div><div><br></div><div>Regards.</div><span style="font-size:10px"><br /><br />Edited by cefernan - 30-Oct-2012 at 9:54am</span>]]>
   </description>
   <pubDate>Tue, 30 Oct 2012 09:53:20 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=3625&amp;PID=15002#15002</guid>
  </item> 
  <item>
   <title>Composition issue on Shared instance :   Originally posted by cefernanI...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=3625&amp;PID=14994#14994</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=1005" rel="nofollow">mgood</a><br /><strong>Subject:</strong> 3625<br /><strong>Posted:</strong> 29-Oct-2012 at 1:34pm<br /><br /><table width="99%"><tr><td class="BBquote"><strong><em>Originally posted by cefernan</strong></em><br /><br />I found it.<div><br></div><div>IdeaBlade.Core.Composition.CompositionHost.Instance.Container</div><div><br></div><div>Thanks</div></td></tr></table><div><br></div><div>That's the container DevForce uses internally. Cocktail doesn't use this container. It uses it's own container.&nbsp;</div><div><br></div><div>Are you using Cocktail 2012 by any chance? In Cocktail 2012 the container is no longer publicly&nbsp;accessible. This is due to the fact that the Composition API is now implementation independent. The container is an implementation detail specific to the underlying IoC technology.&nbsp;</div><div><br></div><div>By implementing ICompositionProvider and setting it with Compositon.SetProvider you can supply your own container to Cocktail. Your Bootstrapper should extend CocktailBootstrapper instead of CocktailMefBootstrapper so you can configure the composition yourself. You can follow what CocktailMefBootstrapper does. As you can see from the source code it configures composition with the&nbsp;MefCompositionProvider, the Cocktail internal implementation of ICompositionProvider.</div>]]>
   </description>
   <pubDate>Mon, 29 Oct 2012 13:34:16 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=3625&amp;PID=14994#14994</guid>
  </item> 
  <item>
   <title>Composition issue on Shared instance : I found it.IdeaBlade.Core.Comp...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=3625&amp;PID=14993#14993</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=1485" rel="nofollow">cefernan</a><br /><strong>Subject:</strong> 3625<br /><strong>Posted:</strong> 29-Oct-2012 at 12:51pm<br /><br />I found it.<div><br></div><div>IdeaBlade.Core.Composition.CompositionHost.Instance.Container</div><div><br></div><div>Thanks</div>]]>
   </description>
   <pubDate>Mon, 29 Oct 2012 12:51:45 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=3625&amp;PID=14993#14993</guid>
  </item> 
  <item>
   <title>Composition issue on Shared instance : Marcel,How can I use Composition.Container?...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=3625&amp;PID=14992#14992</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=1485" rel="nofollow">cefernan</a><br /><strong>Subject:</strong> 3625<br /><strong>Posted:</strong> 29-Oct-2012 at 12:38pm<br /><br />Marcel,<div><br></div><div>How can I use Composition.Container? I've tried to do that but Container doesn't appear in this context.</div>]]>
   </description>
   <pubDate>Mon, 29 Oct 2012 12:38:48 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=3625&amp;PID=14992#14992</guid>
  </item> 
  <item>
   <title>Composition issue on Shared instance : Ah, wasn&amp;#039;t aware of that....</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=3625&amp;PID=14526#14526</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=1207" rel="nofollow">stevef</a><br /><strong>Subject:</strong> 3625<br /><strong>Posted:</strong> 23-Sep-2012 at 8:33am<br /><br />Ah, wasn't aware of that.&nbsp; Ok, will do.<br>BTW, have had no issues with Cocktail in this app, though it doesn't do much other than some compute-intensive calculations, with just a smattering of console output.<br>]]>
   </description>
   <pubDate>Sun, 23 Sep 2012 08:33:43 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=3625&amp;PID=14526#14526</guid>
  </item> 
  <item>
   <title>Composition issue on Shared instance :   First of all, Cocktail is...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=3625&amp;PID=14523#14523</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=1005" rel="nofollow">mgood</a><br /><strong>Subject:</strong> 3625<br /><strong>Posted:</strong> 22-Sep-2012 at 10:23pm<br /><br />First of all, Cocktail is not designed for console applications, so use it at your own risk. <div></div><div>The problem you are having here is that Cocktail creates and owns it's own CompositionContainer. It knows nothing about the CompositionContainer you are creating in your Compose method, so when you call Composition.GetInstance.... the instance comes from the container that Cocktail created and not the container you created in Compose. &nbsp;</div><div>&nbsp;</div><div>If anything you should use Composition.Container throughout your application and not create your own container.</div>]]>
   </description>
   <pubDate>Sat, 22 Sep 2012 22:23:34 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=3625&amp;PID=14523#14523</guid>
  </item> 
  <item>
   <title>Composition issue on Shared instance : Marcel,I have a related issue,...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=3625&amp;PID=14522#14522</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=1207" rel="nofollow">stevef</a><br /><strong>Subject:</strong> 3625<br /><strong>Posted:</strong> 22-Sep-2012 at 5:16pm<br /><br />Marcel,<br>I have a related issue, so I thought I'd continue on this thread.<br>I have a console app that makes use of DF, Cocktail, and MEF.<br><br>I have an interface called IStatusUpdater defined in an external DLL.<br>In order to resolve references to this (and other) external references, I have a Compose() method called from the main:<br><table width="99%"><tr><td><pre class="BBcode"><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; private void Compose()<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; var execAssembly = System.Reflection.Assembly.GetExecutingAssembly();<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; var catalog = new AssemblyCatalog(execAssembly);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; var curPath = System.IO.Path.GetDirectoryName(execAssembly.Location);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; var dirCatalog = new DirectoryCatalog(curPath,"*.dll");<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; var aggCatalog = new AggregateCatalog();<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; aggCatalog.Catalogs.Add(catalog);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; aggCatalog.Catalogs.Add(dirCatalog);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; var container = new CompositionContainer(aggCatalog);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; container.ComposeParts(this);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br></pre></td></tr></table><br><br>I have some other classes that have an importing constructor, for example:<br><table width="99%"><tr><td><pre class="BBcode"><br>&nbsp; &#091;ImportingConstructor&#093;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; public ProjectCreator(IEntityManagerProvider&lt;POEntities&gt; emp, IStatusUpdater statusUpdater, IOptimizer optimizer)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; _emp = emp;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; _statusUpdater = statusUpdater;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; _optimizer = optimizer;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br></pre></td></tr></table><br><br>In my main class, I also have a property:<br><table width="99%"><tr><td><pre class="BBcode"><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &#091;Import&#093;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; public IStatusUpdater StatusUpdater { get; set; }<br></pre></td></tr></table><br><br>I have one class that implements and exports IStatusUpdater, having the following declaration, and constructor:<br><table width="99%"><tr><td><pre class="BBcode"><br>&nbsp;&nbsp;&nbsp; &#091;Export(typeof(IStatusUpdater))&#093;<br>&nbsp;&nbsp;&nbsp; public class StatusUpdater : IStatusUpdater<br>&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; private readonly IEntityManagerProvider&lt;POEntities&gt; _emp;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; private List&lt;MyTextListener&gt; _myListeners;<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &#091;ImportingConstructor&#093;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; public StatusUpdater(&#091;Import(RequiredCreationPolicy = CreationPolicy.NonShared)&#093;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; IEntityManagerProvider&lt;POEntities&gt; emp)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; _emp = emp;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; em.AuthorizedThreadId = null;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; _myListeners = new List&lt;MyTextListener&gt;();<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br></pre></td></tr></table><br><br><br>Everything works just fine this way.<br><br>However, I needed to change the way StatusUpdater was disposed of in the main class, so I changed it from a property with an &#091;Import&#093;, to:<br><table width="99%"><tr><td><pre class="BBcode"><br>using (var StatusUpdater = Composition.GetInstance&lt;IStatusUpdater&gt;(CreationPolicy.Shared)) {...<br></pre></td></tr></table><br><br>Once I did that, however, I started getting 2 instantiations of my StatusUpdater class, the first for the importing constructor of the other classes, and the second from my call to Composition.GetInstance.<br><br>Why is GetInstance not sharing the already instantiated instance??<br>]]>
   </description>
   <pubDate>Sat, 22 Sep 2012 17:16:42 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=3625&amp;PID=14522#14522</guid>
  </item> 
  <item>
   <title>Composition issue on Shared instance : yes and unfortunatly the project...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=3625&amp;PID=14428#14428</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=998" rel="nofollow">Walid</a><br /><strong>Subject:</strong> 3625<br /><strong>Posted:</strong> 13-Sep-2012 at 2:30am<br /><br />yes and unfortunatly the project seems dead.]]>
   </description>
   <pubDate>Thu, 13 Sep 2012 02:30:35 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=3625&amp;PID=14428#14428</guid>
  </item> 
  <item>
   <title>Composition issue on Shared instance : Ah! Looks like you found a bug...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=3625&amp;PID=14427#14427</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=1005" rel="nofollow">mgood</a><br /><strong>Subject:</strong> 3625<br /><strong>Posted:</strong> 13-Sep-2012 at 1:53am<br /><br />Ah! Looks like you found a bug in MefContrib. Good to know.]]>
   </description>
   <pubDate>Thu, 13 Sep 2012 01:53:42 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=3625&amp;PID=14427#14427</guid>
  </item> 
  <item>
   <title>Composition issue on Shared instance : I was able to reproduce it with...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=3625&amp;PID=14426#14426</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=998" rel="nofollow">Walid</a><br /><strong>Subject:</strong> 3625<br /><strong>Posted:</strong> 13-Sep-2012 at 1:42am<br /><br />I was able to reproduce it with some code change.<div><br></div><div><img src="uploads/998/mefc&#111;ntrib.png" height="115" width="499" border="0" /><br></div><div><br></div><div><br></div><div>My bootstrapper is using MefContrib as you do in Temphire for "auto registering" any new instance to the event aggregator</div><div>So if you add those lines to the bootstrapper the issue is there !</div><div><br></div><div>I guess I will have to get rid of this librairy and manually register to the event aggregator in my screens.</div><div><br></div><div><pre style="font-family: C&#111;nsolas; font-size: 13px; : white; -: initial initial; -repeat: initial initial; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:blue;">protected</span>&nbsp;<span style="color:blue;">override</span>&nbsp;<span style="color:#2b91af;">ComposablePartCatalog</span>&nbsp;PrepareCompositionCatalog()&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:#2b91af;">InterceptionConfiguration</span>&nbsp;cfg&nbsp;=&nbsp;<span style="color:blue;">new</span>&nbsp;<span style="color:#2b91af;">InterceptionConfiguration</span>().AddInterceptor(<span style="color:blue;">this</span>);&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:blue;">return</span>&nbsp;<span style="color:blue;">new</span>&nbsp;<span style="color:#2b91af;">InterceptingCatalog</span>(<span style="color:#2b91af;">Composition</span>.Catalog,&nbsp;cfg);&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;} &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:blue;">private</span>&nbsp;<span style="color:blue;">static</span>&nbsp;<span style="color:blue;">void</span>&nbsp;SubscribeToEventAggregator(<span style="color:blue;">object</span>&nbsp;instance)&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:blue;">if</span>&nbsp;(!(instance&nbsp;<span style="color:blue;">is</span>&nbsp;<span style="color:#2b91af;">IHandle</span>))&nbsp;<span style="color:blue;">return</span>; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:#2b91af;">LogFns</span>.DebugWriteLine(<span style="color:blue;">string</span>.Format(<span style="color:#a31515;">"Automatically&nbsp;subscribing&nbsp;instance&nbsp;of&nbsp;</span><span style="color:mediumseagreen;">{0}</span><span style="color:#a31515;">&nbsp;to&nbsp;EventAggregator."</span>,&nbsp;instance.GetType().Name));&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:#2b91af;">EventFns</span>.Subscribe(instance);&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;} &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:blue;">object</span>&nbsp;<span style="color:#2b91af;">IExportedValueInterceptor</span>.Intercept(<span style="color:blue;">object</span>&nbsp;value)&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;SubscribeToEventAggregator(value);&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:blue;">return</span>&nbsp;value;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}</pre></div>]]>
   </description>
   <pubDate>Thu, 13 Sep 2012 01:42:32 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=3625&amp;PID=14426#14426</guid>
  </item> 
  <item>
   <title>Composition issue on Shared instance :     Here you go: http://sdrv.ms/QVuo6SWhen...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=3625&amp;PID=14425#14425</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=1005" rel="nofollow">mgood</a><br /><strong>Subject:</strong> 3625<br /><strong>Posted:</strong> 13-Sep-2012 at 12:49am<br /><br />Here you go: <a href="http://sdrv.ms/QVuo6S" target="_blank">http://sdrv.ms/QVuo6S<div></div></a><div>When you start it you should get "Service not available" and two buttons. Click the "Load Service" button. This loads the second XAP which contains the Service and you should see the service creation date/time above the button. Wait a few seconds and then click "Load Content". That loads the third assembly which contains a ViewModel that gets composed into the first ViewModel and that also gets the Service injected and then displays the service creation date/time in the View. You should see the exact same date/time now in both places indicating that the second VM got the same service injected as the first VM.</div>]]>
   </description>
   <pubDate>Thu, 13 Sep 2012 00:49:31 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=3625&amp;PID=14425#14425</guid>
  </item> 
  <item>
   <title>Composition issue on Shared instance : I have only one bootstrapper in...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=3625&amp;PID=14424#14424</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=998" rel="nofollow">Walid</a><br /><strong>Subject:</strong> 3625<br /><strong>Posted:</strong> 13-Sep-2012 at 12:17am<br /><br />I have only one bootstrapper in the application.<div>I checked if the Harness assembly was by mistake referenced by some modules and it isn't.</div><div><br></div><div>Would you mind sharing your test project so I can see what is different with my application (maybe I wasn't clear in my description) and I could modify it to try to reproduce the issue ?</div><div><br></div>]]>
   </description>
   <pubDate>Thu, 13 Sep 2012 00:17:32 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=3625&amp;PID=14424#14424</guid>
  </item> 
  <item>
   <title>Composition issue on Shared instance :   Neither. I believe this is...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=3625&amp;PID=14423#14423</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=1005" rel="nofollow">mgood</a><br /><strong>Subject:</strong> 3625<br /><strong>Posted:</strong> 12-Sep-2012 at 10:45pm<br /><br />Neither. I believe this is a problem in your application. I recreated the scenario you are describing here and I can't reproduce this issue. The only thing that would explain this that I can think of is if your dynamically loaded XAPs instantiate additional bootstrappers. The bootstrapper creates the MEF container, so if you have more than one bootstrapper, each one creates a new container. You should have only one bootstrapper, otherwise bad things will happen if each XAP attempts to bootstrap the appliction all over again.]]>
   </description>
   <pubDate>Wed, 12 Sep 2012 22:45:50 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=3625&amp;PID=14423#14423</guid>
  </item> 
  <item>
   <title>Composition issue on Shared instance : Hi,I have an issue with a service...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=3625&amp;PID=14419#14419</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=998" rel="nofollow">Walid</a><br /><strong>Subject:</strong> 3625<br /><strong>Posted:</strong> 12-Sep-2012 at 3:58pm<br /><br />Hi,<div><br></div><div>I have an issue with a service exported as Shared :</div><div><br></div><div><span style=": white; font-family: C&#111;nsolas; font-size: 13px; ">&#091;</span><span style="font-family: C&#111;nsolas; font-size: 13px; color: rgb43, 145, 175; ">Export</span><span style=": white; font-family: C&#111;nsolas; font-size: 13px; ">(</span><span style="font-family: C&#111;nsolas; font-size: 13px; color: blue; ">typeof</span><span style=": white; font-family: C&#111;nsolas; font-size: 13px; ">(</span><span style="font-family: C&#111;nsolas; font-size: 13px; color: rgb43, 145, 175; ">IContextRequirementSelection</span><span style=": white; font-family: C&#111;nsolas; font-size: 13px; ">))&#093;</span></div><div><span style=": white; font-family: C&#111;nsolas; font-size: 13px; ">&#091;</span><span style="font-family: C&#111;nsolas; font-size: 13px; color: rgb43, 145, 175; ">ExportMetadata</span><span style=": white; font-family: C&#111;nsolas; font-size: 13px; ">(</span><span style="font-family: C&#111;nsolas; font-size: 13px; color: rgb163, 21, 21; ">"ContextName"</span><span style=": white; font-family: C&#111;nsolas; font-size: 13px; ">,&nbsp;</span><span style="font-family: C&#111;nsolas; font-size: 13px; color: rgb163, 21, 21; ">"Company"</span><span style=": white; font-family: C&#111;nsolas; font-size: 13px; ">)&#093;</span></div><div><span style=": white; font-family: C&#111;nsolas; font-size: 13px; ">&#091;</span><span style="font-family: C&#111;nsolas; font-size: 13px; color: rgb43, 145, 175; ">PartCreationPolicy</span><span style=": white; font-family: C&#111;nsolas; font-size: 13px; ">(</span><span style="font-family: C&#111;nsolas; font-size: 13px; color: rgb43, 145, 175; ">CreationPolicy</span><span style=": white; font-family: C&#111;nsolas; font-size: 13px; ">.Shared)&#093;</span></div><div><br></div><div>This service is located &nbsp;in a XAP which is dynamically loaded once the user login.</div><div><br></div><div><br></div><div>In the main application, I have a usercontrol which has an import on all the service implementing&nbsp;<span style="color: rgb43, 145, 175; font-family: C&#111;nsolas; font-size: 13px; line-height: 18px; ">IContextRequirementSelection</span></div><div><span style=": white; font-family: C&#111;nsolas; font-size: 13px; "><br></span></div><div><span style=": white; font-family: C&#111;nsolas; font-size: 13px; ">&#091;</span><span style="font-family: C&#111;nsolas; font-size: 13px; color: rgb43, 145, 175; ">ImportMany</span><span style=": white; font-family: C&#111;nsolas; font-size: 13px; ">(AllowRecomposition&nbsp;=&nbsp;</span><span style="font-family: C&#111;nsolas; font-size: 13px; color: blue; ">true</span><span style=": white; font-family: C&#111;nsolas; font-size: 13px; ">)&#093;&nbsp;</span></div><div><pre style="font-family: C&#111;nsolas; font-size: 13px; : white; -: initial initial; -repeat: initial initial; "><span style="color:blue;">public</span>&nbsp;<span style="color:#2b91af;">IEnumerable</span>&lt;<span style="color:#2b91af;">Lazy</span>&lt;<span style="color:#2b91af;">IContextRequirementSelection</span>,&nbsp;<span style="color:#2b91af;">IContextRequirementMetadata</span>&gt;&gt;&nbsp;ContextSelections;</pre><pre style="font-family: C&#111;nsolas; font-size: 13px; : white; -: initial initial; -repeat: initial initial; "><span style="font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; line-height: 16px; white-space: normal; ">Once the user login, the collection gets populated and when I access to the element with the metadata "Company", the instance is created.</span></pre><pre style="font-family: C&#111;nsolas; font-size: 13px; : white; -: initial initial; -repeat: initial initial; "></pre><pre style=": white; "><font face="Verdana, Arial, Helvetica, sans-serif"><span style="white-space: normal;">Now, an action in my application load another XAP which also need to use this shared service.</span></font></pre><pre style=": white; "><font face="Verdana, Arial, Helvetica, sans-serif"><span style="white-space: normal; ">I use the same syntaxe as the one above and MEF gives me a<b> NEW instance </b>of the service with the metadata "Company"</span></font></pre><pre style=": white; "><font face="Verdana, Arial, Helvetica, sans-serif"><span style="white-space: normal;"><br></span></font></pre><pre style=": white; "><font face="Verdana, Arial, Helvetica, sans-serif"><span style="white-space: normal;">After reading a little bit on this subject, the only possibility seems to be if a new MEF container is created by the application. &nbsp;</span></font></pre><pre style=": white; "><font face="Verdana, Arial, Helvetica, sans-serif"><span style="white-space: normal;">To try to confirm it,&nbsp;</span></font><span style="white-space: normal; font-family: Verdana, Arial, Helvetica, sans-serif; : white; ">I changed for the test purpose the references in my application to add a reference to the assembly hosting the exported service.</span></pre><pre style=": white; "><font face="Verdana, Arial, Helvetica, sans-serif"><span style="white-space: normal;">Then, when I run the application, both usercontrols share the same instance as expected !</span></font></pre><pre style=": white; "><span style="white-space: normal; font-family: Verdana, Arial, Helvetica, sans-serif; : white; "><br></span></pre><pre style=": white; "><span style=": white; font-family: Verdana, Arial, Helvetica, sans-serif; white-space: normal; ">Is this a problem in cocktail or devforce ?</span></pre><pre style=": white; "><font face="Verdana, Arial, Helvetica, sans-serif"><span style="white-space: normal;"><br></span></font></pre><pre style=": white; "><font face="Verdana, Arial, Helvetica, sans-serif"><span style="white-space: normal;">regards,</span></font></pre><pre style=": white; "><br></pre><pre style=": white; "><font face="Verdana, Arial, Helvetica, sans-serif"><span style="white-space: normal;"><br></span></font></pre></div>]]>
   </description>
   <pubDate>Wed, 12 Sep 2012 15:58:27 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=3625&amp;PID=14419#14419</guid>
  </item> 
 </channel>
</rss>