<?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 : Cocktail.ObjectManager MEF import error in dynamically loaded XAP</title>
  <link>http://www.ideablade.com/forum/</link>
  <description>This is an XML content feed of; DevForce Community Forum : Community Forum : Cocktail.ObjectManager MEF import error in dynamically loaded XAP</description>
  <pubDate>Tue, 12 May 2026 22:26:23 -700</pubDate>
  <lastBuildDate>Mon, 26 Mar 2012 11:46:25 -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=3358</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>Cocktail.ObjectManager MEF import error in dynamically loaded XAP :    Paul,I took a quick look...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=3358&amp;PID=13113#13113</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> 3358<br /><strong>Posted:</strong> 26-Mar-2012 at 11:46am<br /><br />Paul,<div>I took a quick look at your solution. You appear to be missing exports for your EntityManagerProviders. For example the following class has a dependency to <span>IEntityManagerProvider</span>&lt;<span>ModuleHrEmployeeEntities</span>&gt;, but I couldn't find a corresponding export anywhere in your solution.</div><div> </div><div><pre style="color: black; font-family: C&#111;nsolas;">    &#091;<span>Export</span>(<span style="color: blue;">typeof</span>(<span>IHrEmployeeRepository</span>)), <span>PartCreationPolicy</span>(<span>CreationPolicy</span>.NonShared)&#093;    <span style="color: blue;">public</span> <span style="color: blue;">class</span> <span>HrEmployeeRepository</span> : <span>UnitOfWork</span>, <span>IHrEmployeeRepository</span>    {        &#091;<span>ImportingConstructor</span>&#093;        <span style="color: blue;">public</span> HrEmployeeRepository(                     &#091;<span>Import</span>(RequiredCreationPolicy = <span>CreationPolicy</span>.NonShared)&#093;                         <span>IEntityManagerProvider</span>&lt;<span>ModuleHrEmployeeEntities</span>&gt; entityManagerProvider)<span style="color: green;">//,</span>                    <span style="color: green;">//&#091;Import(AllowDefault = true)&#093; </span>                        <span style="color: green;">//IPreLoader preLoader = null) </span>                    : <span style="color: blue;">base</span>(entityManagerProvider)        {        }    }</pre></div><div> </div><div>On a side note, you seem to be mixing up repository and unit of work. You call the above a repository. That's not a repository, that's a unit of work. If you use unit of work, repositories are contained in a unit of work. The point of a unit of work is in essence, so that you can bring together a bunch of repositories that do not know about each other and have them participate in the same workflow (unit of work).</div><div> </div><div> </div><span style="font-size:10px"><br /><br />Edited by mgood - 26-Mar-2012 at 11:59am</span>]]>
   </description>
   <pubDate>Mon, 26 Mar 2012 11:46:25 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=3358&amp;PID=13113#13113</guid>
  </item> 
  <item>
   <title>Cocktail.ObjectManager MEF import error in dynamically loaded XAP :   I&amp;#039;ll take a look. I meant...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=3358&amp;PID=13101#13101</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> 3358<br /><strong>Posted:</strong> 25-Mar-2012 at 9:32am<br /><br />I'll take a look. I meant the repositories should be NonShared, not the repository managers. Repository managers you only want one of each. ]]>
   </description>
   <pubDate>Sun, 25 Mar 2012 09:32:05 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=3358&amp;PID=13101#13101</guid>
  </item> 
  <item>
   <title>Cocktail.ObjectManager MEF import error in dynamically loaded XAP : Thanks for the early morning reply...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=3358&amp;PID=13100#13100</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=942" rel="nofollow">paul</a><br /><strong>Subject:</strong> 3358<br /><strong>Posted:</strong> 25-Mar-2012 at 7:20am<br /><br />&nbsp;Thanks for the early morning reply Marcel. I am exporting my IAppModule1Repository. All my AppModule1 UOW/Repository code is an exact copy of my shell's UOW/Repository code. The only difference is AppModule1 is a dynamically loaded XAP. My shell loads correctly with correct UOW/repository instances but the AppModule1 fails at MEF's ImportingConstructor on my App.Module1.ViewModels.HomeViewModel ctor.<div><pre style="font-family: C&#111;nsolas; font-size: 13px; -: initial; -attachment: initial; -origin: initial; -clip: initial; : rgb227, 213, 193; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#091;<span style="color: rgb48, 95, 182; ">ImportingConstructor</span>&#093;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: rgb64, 0, 128; ">public</span>&nbsp;HomeViewModel(<span style="color: rgb48, 95, 182; ">IAppModule1RepositoryManager</span><span style="color: rgb46, 83, 209; ">&lt;</span><span style="color: rgb48, 95, 182; ">IAppModule1Repository</span><span style="color: rgb46, 83, 209; ">&gt;</span>&nbsp;repositoryManager,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;                 <span style="color: rgb48, 95, 182; ">IToolbarManager</span>&nbsp;toolbar)</pre></div><div>Here my main shell's App.ViewModels.ShellViewModel (this does work)</div><div><pre style="font-family: C&#111;nsolas; font-size: 13px; -: initial; -attachment: initial; -origin: initial; -clip: initial; : rgb227, 213, 193; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#091;<span style="color: rgb48, 95, 182; ">ImportingConstructor</span>&#093;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: rgb64, 0, 128; ">public</span>&nbsp;ShellViewModel(<span style="color: rgb48, 95, 182; ">IToolbarManager</span>&nbsp;toolbar,&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;<span style="color: rgb48, 95, 182; ">IShellRepositoryManager</span><span style="color: rgb46, 83, 209; ">&lt;</span><span style="color: rgb48, 95, 182; ">IShellRepository</span><span style="color: rgb46, 83, 209; ">&gt;</span>&nbsp;repositoryManager,&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;<span style="color: rgb48, 95, 182; ">IAuthenticationService</span>&nbsp;authenticationService)</pre><div><br></div><div>I did have my repository manager (inherits from ObjectManager) parts marked as Shared but I changed them to NonShared with the same failure results. I will note the TempHire sample has it marked as Shared but i'll assume it doesn't matter since you only have one UOW manager in the sample.</div><div><br></div><div><br></div><div>Here are my two UOW/repository classes so far, one for the shell and the other for AppModule1</div><div><pre style="font-family: C&#111;nsolas; font-size: 13px; -: initial; -attachment: initial; -origin: initial; -clip: initial; : rgb227, 213, 193; ">&nbsp;&nbsp;&nbsp;&nbsp;&#091;<span style="color: rgb48, 95, 182; ">Export</span>(<span style="color: rgb64, 0, 128; ">typeof</span>(<span style="color: rgb48, 95, 182; ">IShellRepository</span>)),&nbsp;<span style="color: rgb48, 95, 182; ">PartCreationPolicy</span>(<span style="color: rgb43, 145, 175; ">CreationPolicy</span><span style="color: rgb46, 83, 209; ">.</span>NonShared)&#093;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: rgb64, 0, 128; ">public</span>&nbsp;<span style="color: rgb64, 0, 128; ">class</span>&nbsp;<span style="color: rgb48, 95, 182; ">ShellRepository</span>&nbsp;:&nbsp;<span style="color: rgb48, 95, 182; ">UnitOfWork</span>,&nbsp;<span style="color: rgb48, 95, 182; ">IShellRepository</span>&nbsp;&nbsp;&nbsp;&nbsp;{&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#091;<span style="color: rgb48, 95, 182; ">ImportingConstructor</span>&#093;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: rgb64, 0, 128; ">public</span>&nbsp;ShellRepository(&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#091;<span style="color: rgb48, 95, 182; ">Import</span>(RequiredCreationPolicy&nbsp;<span style="color: rgb46, 83, 209; ">=</span>&nbsp;<span style="color: rgb43, 145, 175; ">CreationPolicy</span><span style="color: rgb46, 83, 209; ">.</span>NonShared)&#093;&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;<span style="color: rgb48, 95, 182; ">IEntityManagerProvider</span><span style="color: rgb46, 83, 209; ">&lt;App</span><span style="color: rgb48, 95, 182; ">Entities</span><span style="color: rgb46, 83, 209; ">&gt;</span>&nbsp;entityManagerProvider)&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:&nbsp;<span style="color: rgb64, 0, 128; ">base</span>(entityManagerProvider)&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp;&nbsp;&nbsp;&nbsp;}</pre></div><div><pre style="font-family: C&#111;nsolas; font-size: 13px; -: initial; -attachment: initial; -origin: initial; -clip: initial; : rgb227, 213, 193; ">&nbsp;&nbsp;&nbsp;&nbsp;&#091;<span style="color: rgb48, 95, 182; ">Export</span>(<span style="color: rgb64, 0, 128; ">typeof</span>(<span style="color: rgb48, 95, 182; ">IShellRepositoryManager</span><span style="color: rgb46, 83, 209; ">&lt;</span><span style="color: rgb48, 95, 182; ">IShellRepository</span><span style="color: rgb46, 83, 209; ">&gt;</span>))&#093;&nbsp;&nbsp;&nbsp;&nbsp;&#091;<span style="color: rgb48, 95, 182; ">PartCreationPolicy</span>(<span style="color: rgb43, 145, 175; ">CreationPolicy</span><span style="color: rgb46, 83, 209; ">.</span>NonShared)&#093;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: rgb64, 0, 128; ">public</span>&nbsp;<span style="color: rgb64, 0, 128; ">class</span>&nbsp;<span style="color: rgb48, 95, 182; ">ShellRepositoryManager</span>&nbsp;:&nbsp;<span style="color: rgb48, 95, 182; ">ObjectManager</span><span style="color: rgb46, 83, 209; ">&lt;</span><span style="color: rgb48, 95, 182; ">Guid</span>,&nbsp;<span style="color: rgb48, 95, 182; ">IShellRepository</span><span style="color: rgb46, 83, 209; ">&gt;</span>,&nbsp;<span style="color: rgb48, 95, 182; ">IShellRepositoryManager</span><span style="color: rgb46, 83, 209; ">&lt;</span><span style="color: rgb48, 95, 182; ">IShellRepository</span><span style="color: rgb46, 83, 209; ">&gt;</span>&nbsp;&nbsp;&nbsp;&nbsp;{<span style="color: rgb64, 0, 128; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;#region</span>&nbsp;IShellRepositoryManager&lt;T&gt;&nbsp;Members &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: rgb64, 0, 128; ">public</span>&nbsp;<span style="color: rgb48, 95, 182; ">IShellRepository</span>&nbsp;Get(<span style="color: rgb48, 95, 182; ">Guid</span>&nbsp;key)&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: rgb64, 0, 128; ">return</span>&nbsp;GetObject(key);&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;} <span style="color: rgb64, 0, 128; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;#endregion</span> &nbsp;&nbsp;&nbsp;&nbsp;}</pre></div><div><br></div><div><br></div><div><pre style="font-family: C&#111;nsolas; font-size: 13px; -: initial; -attachment: initial; -origin: initial; -clip: initial; : rgb227, 213, 193; ">&nbsp;&nbsp;&nbsp;&nbsp;&#091;<span style="color: rgb48, 95, 182; ">Export</span>(<span style="color: rgb64, 0, 128; ">typeof</span>(<span style="color: rgb48, 95, 182; ">IAppModule1Repository</span>)),&nbsp;<span style="color: rgb48, 95, 182; ">PartCreationPolicy</span>(<span style="color: rgb43, 145, 175; ">CreationPolicy</span><span style="color: rgb46, 83, 209; ">.</span>NonShared)&#093;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: rgb64, 0, 128; ">public</span>&nbsp;<span style="color: rgb64, 0, 128; ">class</span>&nbsp;<span style="color: rgb48, 95, 182; ">AppModule1Repository</span>&nbsp;:&nbsp;<span style="color: rgb48, 95, 182; ">UnitOfWork</span>,&nbsp;<span style="color: rgb48, 95, 182; ">IAppModule1Repository</span>&nbsp;&nbsp;&nbsp;&nbsp;{&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#091;<span style="color: rgb48, 95, 182; ">ImportingConstructor</span>&#093;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: rgb64, 0, 128; ">public</span>&nbsp;AppModule1Repository(&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#091;<span style="color: rgb48, 95, 182; ">Import</span>(RequiredCreationPolicy&nbsp;<span style="color: rgb46, 83, 209; ">=</span>&nbsp;<span style="color: rgb43, 145, 175; ">CreationPolicy</span><span style="color: rgb46, 83, 209; ">.</span>NonShared)&#093;&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;<span style="color: rgb48, 95, 182; ">IEntityManagerProvider</span><span style="color: rgb46, 83, 209; ">&lt;</span><span style="color: rgb48, 95, 182; ">AppModule1Entities</span><span style="color: rgb46, 83, 209; ">&gt;</span>&nbsp;entityManagerProvider)&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:&nbsp;<span style="color: rgb64, 0, 128; ">base</span>(entityManagerProvider)&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp;&nbsp;&nbsp;&nbsp;}</pre></div><div><pre style="font-family: C&#111;nsolas; font-size: 13px; -: initial; -attachment: initial; -origin: initial; -clip: initial; : rgb227, 213, 193; ">&nbsp;&nbsp;&nbsp;&nbsp;&#091;<span style="color: rgb48, 95, 182; ">Export</span>(<span style="color: rgb64, 0, 128; ">typeof</span>(<span style="color: rgb48, 95, 182; ">IAppModule1RepositoryManager</span><span style="color: rgb46, 83, 209; ">&lt;</span><span style="color: rgb48, 95, 182; ">IAppModule1Repository</span><span style="color: rgb46, 83, 209; ">&gt;</span>))&#093;&nbsp;&nbsp;&nbsp;&nbsp;&#091;<span style="color: rgb48, 95, 182; ">PartCreationPolicy</span>(<span style="color: rgb43, 145, 175; ">CreationPolicy</span><span style="color: rgb46, 83, 209; ">.</span>NonShared)&#093;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: rgb64, 0, 128; ">public</span>&nbsp;<span style="color: rgb64, 0, 128; ">class</span>&nbsp;<span style="color: rgb48, 95, 182; ">AppModule1RepositoryManager</span>&nbsp;:&nbsp;<span style="color: rgb48, 95, 182; ">ObjectManager</span><span style="color: rgb46, 83, 209; ">&lt;</span><span style="color: rgb48, 95, 182; ">Guid</span>,&nbsp;<span style="color: rgb48, 95, 182; ">IAppModule1Repository</span><span style="color: rgb46, 83, 209; ">&gt;</span>,&nbsp;<span style="color: rgb48, 95, 182; ">IAppModule1RepositoryManager</span><span style="color: rgb46, 83, 209; ">&lt;</span><span style="color: rgb48, 95, 182; ">IAppModule1Repository</span><span style="color: rgb46, 83, 209; ">&gt;</span>&nbsp;&nbsp;&nbsp;&nbsp;{<span style="color: rgb64, 0, 128; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;#region</span>&nbsp;IAppModule1RepositoryManager&lt;T&gt;&nbsp;Members &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: rgb64, 0, 128; ">public</span>&nbsp;<span style="color: rgb48, 95, 182; ">IAppModule1Repository</span>&nbsp;Get(<span style="color: rgb48, 95, 182; ">Guid</span>&nbsp;key)&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: rgb64, 0, 128; ">return</span>&nbsp;GetObject(key);&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;} <span style="color: rgb64, 0, 128; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;#endregion</span> &nbsp;&nbsp;&nbsp;&nbsp;}</pre></div><div><br></div><div>Marcel, I am going to send you a private msg with the link to my prototype solution. Maybe you can see something I am missing.&nbsp;</div><div><br></div><div>-Paul</div><br ="Apple-interchange-newline"></div>]]>
   </description>
   <pubDate>Sun, 25 Mar 2012 07:20:00 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=3358&amp;PID=13100#13100</guid>
  </item> 
  <item>
   <title>Cocktail.ObjectManager MEF import error in dynamically loaded XAP :   Looks like you are missing...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=3358&amp;PID=13099#13099</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> 3358<br /><strong>Posted:</strong> 25-Mar-2012 at 2:45am<br /><br />Looks like you are missing an export for IAppModule1Repository. ObjectManager needs to create new instances of the type it is managing. For that it looks to MEF for an export of said type, in your case IAppModule1Repository. Also the CreationPolicy of the part must be Any or NonShared, because ObjectManager creates NonShared instances.]]>
   </description>
   <pubDate>Sun, 25 Mar 2012 02:45:15 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=3358&amp;PID=13099#13099</guid>
  </item> 
  <item>
   <title>Cocktail.ObjectManager MEF import error in dynamically loaded XAP :   I was able to get Visual Mefx...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=3358&amp;PID=13098#13098</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=942" rel="nofollow">paul</a><br /><strong>Subject:</strong> 3358<br /><strong>Posted:</strong> 24-Mar-2012 at 3:35pm<br /><br /><div>I was able to get Visual Mefx working under SL5 and captured this screenshot. This is coming from my App.Module1.Services.AppModule1RepositoryManager class. I am not sure why the ObjectManager would throw up an import error. Actually I am not even sure if this dump is valid. Mefx is a little flaky.&nbsp;</div><div><br></div><div><img src="uploads/942/MefImportError_&#079;bjectManager.PNG" height="301" width="1401" border="0" /><br></div>]]>
   </description>
   <pubDate>Sat, 24 Mar 2012 15:35:36 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=3358&amp;PID=13098#13098</guid>
  </item> 
  <item>
   <title>Cocktail.ObjectManager MEF import error in dynamically loaded XAP : I am trying to code a prototype...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=3358&amp;PID=13097#13097</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=942" rel="nofollow">paul</a><br /><strong>Subject:</strong> 3358<br /><strong>Posted:</strong> 24-Mar-2012 at 3:05pm<br /><br />I am trying to code a prototype project following Marcel's TempHire UOW example he sent me a few days ago but I am running up against a roadblock with my dynamically loaded XAP.<div><br></div><div>Currently I have a simple solution structure:</div><div><br></div><div>App.Core (main application shell project)</div><div>&nbsp; - App.Core.Services (my UOW/Repository project)</div><div>&nbsp; - App.Core.Model (my DF and EF entities)</div><div>App.Module1 (my dynamically loaded project)</div><div>&nbsp; - App.Module1.Services (my UOW/Repository project for Module1)</div><div>&nbsp; - App.Module1.Model (my DF and EF entities for Module1)</div><div><br></div><div>I am referencing a slightly newer version of Cocktail.SL.dll (v0.5) and a new Cocktail.Contrib.SL.dll I got from Marcel's sample. My app is SL5 as is my Cocktail.SL.dll but the Cocktail.Contrib.SL.dll is SL4. I don't have source to recompile the contrib library to SL5 but I assume it should reference fine in my SL5 app.</div><div><br></div><div>I am dynamically loading my Module1 XAP by calling Composition.AddXap, when it's completed I find its workspace and navigate to it.</div><div><pre style="font-family: C&#111;nsolas; font-size: 13px; -: initial; -attachment: initial; -origin: initial; -clip: initial; : rgb227, 213, 193; -: initial initial; -repeat: initial initial; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#091;<span style="color:#305fb6;">ImportMany</span>(AllowRecomposition&nbsp;<span style="color:#2e53d1;">=</span>&nbsp;<span style="color:#400080;">true</span>)&#093;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:#400080;">public</span>&nbsp;<span style="color:#305fb6;">ObservableCollection</span><span style="color:#2e53d1;">&lt;</span><span style="color:#305fb6;">Lazy</span><span style="color:#2e53d1;">&lt;</span><span style="color:#305fb6;">IWorkspace</span>,&nbsp;<span style="color:#305fb6;">IModuleNameMetadata</span><span style="color:#2e53d1;">&gt;&gt;</span>&nbsp;Workspaces&nbsp;{&nbsp;<span style="color:#400080;">get</span>;&nbsp;<span style="color:#400080;">set</span>;&nbsp;}</pre></div><div><pre style="font-family: C&#111;nsolas; font-size: 13px; -: initial; -attachment: initial; -origin: initial; -clip: initial; : rgb227, 213, 193; -: initial initial; -repeat: initial initial; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:#400080;">public</span>&nbsp;<span style="color:#305fb6;">IEnumerable</span><span style="color:#2e53d1;">&lt;</span><span style="color:#305fb6;">IResult</span><span style="color:#2e53d1;">&gt;</span>&nbsp;LoadModule(<span style="color:#400080;">string</span>&nbsp;name)&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:#400080;">yield</span>&nbsp;<span style="color:#400080;">return</span>&nbsp;<span style="color:#305fb6;">Composition</span><span style="color:#2e53d1;">.</span>AddXap(name&nbsp;<span style="color:#2e53d1;">+</span>&nbsp;<span style="color:#259241;">".xap"</span>); &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:#400080;">var</span>&nbsp;ws&nbsp;<span style="color:#2e53d1;">=</span>&nbsp;Workspaces&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;<span style="color:#2e53d1;">.</span>Where(w&nbsp;<span style="color:#2e53d1;">=&gt;</span>&nbsp;w<span style="color:#2e53d1;">.</span>Metadata<span style="color:#2e53d1;">.</span>Name<span style="color:#2e53d1;">.</span>Equals(name&nbsp;<span style="color:#2e53d1;">+</span>&nbsp;<span style="color:#259241;">".ViewModels.HomeViewModel"</span>))&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;<span style="color:#2e53d1;">.</span>Select(w&nbsp;<span style="color:#2e53d1;">=&gt;</span>&nbsp;w<span style="color:#2e53d1;">.</span>Value)&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;<span style="color:#2e53d1;">.</span>FirstOrDefault(); &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:#400080;">if</span>&nbsp;(ws&nbsp;<span style="color:#2e53d1;">!=</span>&nbsp;<span style="color:#400080;">null</span>)&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;NavigateTo(ws)<span style="color:#2e53d1;">.</span>ToSequentialResult()<span style="color:#2e53d1;">.</span>Execute();&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}</pre></div><div><pre style="font-family: C&#111;nsolas; font-size: 13px; -: initial; -attachment: initial; -origin: initial; -clip: initial; : rgb227, 213, 193; -: initial initial; -repeat: initial initial; ">&nbsp;&nbsp;&nbsp;&nbsp;&#091;<span style="color:#305fb6;">Export</span>(<span style="color:#400080;">typeof</span>(<span style="color:#305fb6;">IWorkspace</span>)),&nbsp;<span style="color:#305fb6;">ExportMetadata</span>(<span style="color:#259241;">"Name"</span>,&nbsp;<span style="color:#259241;">"App.Module1.ViewModels.HomeViewModel"</span>)&#093;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:#400080;">public</span>&nbsp;<span style="color:#400080;">class</span>&nbsp;<span style="color:#305fb6;">HomeViewModel</span>&nbsp;:&nbsp;<span style="color:#305fb6;">Conductor</span><span style="color:#2e53d1;">&lt;</span><span style="color:#305fb6;">IScreen</span><span style="color:#2e53d1;">&gt;</span>,&nbsp;<span style="color:#305fb6;">IDiscoverableViewModel</span>,&nbsp;<span style="color:#305fb6;">IHandle</span><span style="color:#2e53d1;">&lt;</span><span style="color:#305fb6;">EntityChangedMessage</span><span style="color:#2e53d1;">&gt;</span>,&nbsp;<span style="color:#305fb6;">IWorkspace</span></pre></div><div>From my main shell project I am able to import my UOW/Repository</div><div><pre style="font-family: C&#111;nsolas; font-size: 13px; -: initial; -attachment: initial; -origin: initial; -clip: initial; : rgb227, 213, 193; -: initial initial; -repeat: initial initial; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#091;<span style="color:#305fb6;">ImportingConstructor</span>&#093;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:#400080;">public</span>&nbsp;ShellViewModel(<span style="color:#305fb6;">IToolbarManager</span>&nbsp;toolbar,&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;<span style="color:#305fb6;">IShellRepositoryManager</span><span style="color:#2e53d1;">&lt;</span><span style="color:#305fb6;">IShellRepository</span><span style="color:#2e53d1;">&gt;</span>&nbsp;repositoryManager,&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;<span style="color:#305fb6;">IAuthenticationService</span>&nbsp;authenticationService)</pre></div><div>Where I get into trouble is trying to import my Module1 UOW/Repository from App.Module1.ViewModels.HomeViewModel ctor.</div><div><pre style="font-family: C&#111;nsolas; font-size: 13px; -: initial; -attachment: initial; -origin: initial; -clip: initial; : rgb227, 213, 193; -: initial initial; -repeat: initial initial; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#091;<span style="color:#305fb6;">ImportingConstructor</span>&#093;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:#400080;">public</span>&nbsp;HomeViewModel( <span style="color:#305fb6;">IAppModule1RepositoryManager</span><span style="color:#2e53d1;">&lt;</span><span style="color:#305fb6;">IAppModule1Repository</span><span style="color:#2e53d1;">&gt;</span>&nbsp;repositoryManager,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;                  <span style="color:#305fb6;">IErrorHandler</span>&nbsp;errorHandler,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;                  <span style="color:#305fb6;">IDialogManager</span>&nbsp;dialogManager,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;                  <span style="color:#305fb6;">IToolbarManager</span>&nbsp;toolbar)&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{</pre></div><div>This results in the following MEF error</div><div><br></div><div><div><i><font color="#990000">System.ComponentModel.Composition Warning: 1 : The ComposablePartDefinition 'App.Module1.ViewModels.HomeViewModel' has been rejected. The composition remains unchanged. The changes were rejected because of the following error(s): The composition produced a single composition error. The root cause is provided below. Review the CompositionException.Errors property for more detailed information.</font></i></div><div><i><font color="#990000"><br></font></i></div><div><i><font color="#990000">1) No valid exports were found that match the constraint '((exportDefinition.ContractName == "App.Module1.Services.IAppModule1RepositoryManager(App.Module1.Services.IAppModule1Repository)") AndAlso (exportDefinition.Metadata.ContainsKey("ExportTypeIdentity") AndAlso "App.Module1.Services.IAppModule1RepositoryManager(App.Module1.Services.IAppModule1Repository)".Equals(exportDefinition.Metadata.get_Item("ExportTypeIdentity"))))', invalid exports may have been rejected.</font></i></div></div><div><br></div><div>My problem seems to be centered around my AppModule1RepositoryManager class. I get the above error when I base it off of ObjectManager.</div><div><pre style="font-family: C&#111;nsolas; font-size: 13px; -: initial; -attachment: initial; -origin: initial; -clip: initial; : rgb227, 213, 193; -: initial initial; -repeat: initial initial; ">&nbsp;&nbsp;&nbsp;&nbsp;&#091;<span style="color:#305fb6;">Export</span>(<span style="color:#400080;">typeof</span>(<span style="color:#305fb6;">IAppModule1RepositoryManager</span><span style="color:#2e53d1;">&lt;</span><span style="color:#305fb6;">IAppModule1Repository</span><span style="color:#2e53d1;">&gt;</span>))&#093;&nbsp;&nbsp;&nbsp;&nbsp;&#091;<span style="color:#305fb6;">PartCreationPolicy</span>(<span style="color:#2b91af;">CreationPolicy</span><span style="color:#2e53d1;">.</span>Shared)&#093;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:#400080;">public</span>&nbsp;<span style="color:#400080;">class</span>&nbsp;<span style="color:#305fb6;">AppModule1RepositoryManager</span>&nbsp;:&nbsp;<span style="color:#305fb6;">ObjectManager</span><span style="color:#2e53d1;">&lt;</span><span style="color:#305fb6;">Guid</span>,&nbsp;<span style="color:#305fb6;">IAppModule1Repository</span><span style="color:#2e53d1;">&gt;</span>,&nbsp;<span style="color:#305fb6;">IAppModule1RepositoryManager</span><span style="color:#2e53d1;">&lt;</span><span style="color:#305fb6;">IAppModule1Repository</span><span style="color:#2e53d1;">&gt;</span></pre></div><div>If I get rid of the ObjectManager base, like so</div><div><pre style="font-family: C&#111;nsolas; font-size: 13px; -: initial; -attachment: initial; -origin: initial; -clip: initial; : rgb227, 213, 193; -: initial initial; -repeat: initial initial; ">&nbsp;&nbsp;&nbsp;&nbsp;&#091;<span style="color:#305fb6;">Export</span>(<span style="color:#400080;">typeof</span>(<span style="color:#305fb6;">IAppModule1RepositoryManager</span><span style="color:#2e53d1;">&lt;</span><span style="color:#305fb6;">IAppModule1Repository</span><span style="color:#2e53d1;">&gt;</span>))&#093;&nbsp;&nbsp;&nbsp;&nbsp;&#091;<span style="color:#305fb6;">PartCreationPolicy</span>(<span style="color:#2b91af;">CreationPolicy</span><span style="color:#2e53d1;">.</span>Shared)&#093;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:#400080;">public</span>&nbsp;<span style="color:#400080;">class</span>&nbsp;<span style="color:#305fb6;">AppModule1RepositoryManager</span>&nbsp;:&nbsp;<span style="color:#305fb6;">IAppModule1RepositoryManager</span><span style="color:#2e53d1;">&lt;</span><span style="color:#305fb6;">IAppModule1Repository</span><span style="color:#2e53d1;">&gt;</span></pre></div><div>My App.Module1 HomeViewModel ImportingConstructor works but the AppModule1RepositoryManager instance is basically empty without the ObjectManager.</div><div><br></div><div>I'm curious if I am missing something with the way I am dynamically loading my Module1 XAP that causes the ObjectManager to not import or is there a problem with having more than one imported ObjectManager?</div><div><br></div><div>Is there any sample code I could look at that touches on what I am trying to accomplish. Basically use Cocktail in a shell and dynamically loaded XAPs. Each XAP would be its own Caliburn workspace with many screens. Each screen would have its own UOW/Repository backed by each module's own EF/DevForce model.</div><div><br></div><div>Thanks... &nbsp;-Paul</div><div><br></div>]]>
   </description>
   <pubDate>Sat, 24 Mar 2012 15:05:19 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=3358&amp;PID=13097#13097</guid>
  </item> 
 </channel>
</rss>