<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Mariano Converti &#187; SCSF</title>
	<atom:link href="http://blogs.southworks.net/mconverti/category/scsf/feed/" rel="self" type="application/rss+xml" />
	<link>http://blogs.southworks.net/mconverti</link>
	<description>Sharing some thoughts...</description>
	<lastBuildDate>Tue, 17 Jan 2012 19:06:49 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>How To: Pass parameters to Commands Handlers in Composite UI Application Block (CAB) / SCSF</title>
		<link>http://blogs.southworks.net/mconverti/2009/02/04/how-to-pass-parameters-to-commands-handlers-in-composite-ui-application-block-cab-scsf/</link>
		<comments>http://blogs.southworks.net/mconverti/2009/02/04/how-to-pass-parameters-to-commands-handlers-in-composite-ui-application-block-cab-scsf/#comments</comments>
		<pubDate>Wed, 04 Feb 2009 18:08:53 +0000</pubDate>
		<dc:creator>mconverti</dc:creator>
				<category><![CDATA[CAB]]></category>
		<category><![CDATA[SCSF]]></category>

		<guid isPermaLink="false">http://blogs.southworks.net/mconverti/?p=119</guid>
		<description><![CDATA[... <a href="http://blogs.southworks.net/mconverti/2009/02/04/how-to-pass-parameters-to-commands-handlers-in-composite-ui-application-block-cab-scsf/" class="more-link">read more<img src="http://blogs.southworks.net/mconverti/wp-content/themes/southworks/assets/img/arrow-blue.png" width="12" height="12" alt="" /></a>]]></description>
			<content:encoded><![CDATA[<p>This week there were some questions in the <a href="http://www.codeplex.com/smartclient/Thread/List.aspx">SCSF Codeplex Forum</a> asking for a way to pass custom parameters to a method marked as a Command Handler. As you may know, there is no out-of-the-box way to do it because they are raised internally by the Command class and, since you usually bind a command to a control event via the <strong>AddInvoker</strong> method, you cannot manage when the command is executed.</p>
<p>Additionally, the signature of a command handler is fixed and should always be like the following:</p>
<pre>[<span style="color: #2b91af">CommandHandler</span>(<span style="color: #2b91af">CommandNames</span>.MyCommand)]
<span style="color: blue">public void </span>OnMyCommandHandler(<span style="color: blue">object </span>sender, <span style="color: #2b91af">EventArgs </span>args)
{
    <span style="color: green">// The sender parameter is an instance of the Command class.
    </span><span style="color: #2b91af">Command </span>cmd = sender <span style="color: blue">as </span><span style="color: #2b91af">Command</span>;

    <span style="color: green">// The args parameter is empty.
    </span><span style="color: blue">bool </span>f = (args == <span style="color: #2b91af">EventArgs</span>.Empty);
} </pre>
<p><a href="http://11011.net/software/vspaste"></a></p>
<p>The instance of the Command class received in the <strong>sender</strong> parameter could be useful, for example, if you want to change the status of the command to <strong>Enabled</strong>, <strong>Disabled</strong> or <strong>Unavailable</strong>.</p>
<pre>cmd.Status = <span style="color: #2b91af">CommandStatus</span>.Disabled;</pre>
<p><a href="http://11011.net/software/vspaste"></a></p>
<p>But, <strong>what if you want to share the same command handler for different command invokers (like several menu items) and perform some operations based on which item was the invoker?</strong> You will somehow need to receive a parameter describing which was the item that raised the command.</p>
<h3>Workaround</h3>
<p>A possible workaround to <i>receive parameters</i> using a command could be by not adding your items as invokers of the command and instead execute the command programmatically. If you do this, you could use the <strong>State</strong> collection of the RootWorkItem to <em>pass parameters</em> to the command. </p>
<p>To implement this workaround follow these steps (the code use the ToolStripMenuItem control but could be used with other toolstrip controls): </p>
<ol>
<li>Add the parameter that you want to receive in the command handler to the <strong>Tag</strong> property of your menu item control: 
<pre><span style="color: #2b91af">ToolStripMenuItem </span>item = <span style="color: blue">new </span><span style="color: #2b91af">ToolStripMenuItem</span>() { Text = <span style="color: #a31515">"My Menu Item"</span>, <strong>Tag = <span style="color: #a31515">"My Tag"</span></strong>};</pre>
<p><a href="http://11011.net/software/vspaste"></a></p>
<li>Add a handler for the <strong>Click </strong>event to your menu item:
<pre>item.Click += <span style="color: blue">new </span><span style="color: #2b91af">EventHandler</span>(Item_Click);</pre>
<li>In the <b>Item_Click</b> method, add the Tag of your item to the <b>State</b> collection of the <strong>RootWorkItem</strong> and execute the command programmatically:
<pre>WorkItem.RootWorkItem.State[<span style="color: #a31515">"LastTag"</span>] = item.Tag;
WorkItem.Commands[<span style="color: #2b91af">CommandNames</span>.CommandWithParameters].Execute();</pre>
<li>In the command handler, retrieve the Tag from the State collection:
<pre><span style="color: blue">string </span>tag = WorkItem.RootWorkItem.State[<span style="color: #a31515">"LastTag"</span>] <span style="color: blue">as string</span>;</pre>
<p><a href="http://11011.net/software/vspaste"></a></li>
</ol>
<p>The following code shows a ModuleController class that demonstrates how the approach above could be implemented:</p>
<pre><span style="color: blue">public class </span><span style="color: #2b91af">ModuleController </span>: <span style="color: #2b91af">WorkItemController
</span>{
    <span style="color: blue">public override void </span>Run()
    {
        AddServices();
        ExtendMenu();
        AddViews();
    }

    <span style="color: blue">private void </span>ExtendMenu()
    {
        AddTaggedMenuItem(<span style="color: #a31515">"Menu Item 1"</span>, <span style="color: #a31515">"Tag 1"</span>, <span style="color: #2b91af">UIExtensionSiteNames</span>.ModulesMenu);
        AddTaggedMenuItem(<span style="color: #a31515">"Menu Item 2"</span>, <span style="color: #a31515">"Tag 2"</span>, <span style="color: #2b91af">UIExtensionSiteNames</span>.ModulesMenu);
        AddTaggedMenuItem(<span style="color: #a31515">"Menu Item 3"</span>, <span style="color: #a31515">"Tag 3"</span>, <span style="color: #2b91af">UIExtensionSiteNames</span>.ModulesMenu);
        AddTaggedMenuItem(<span style="color: #a31515">"Menu Item 4"</span>, <span style="color: #a31515">"Tag 4"</span>, <span style="color: #2b91af">UIExtensionSiteNames</span>.ModulesMenu);
    }

    <span style="color: blue">private void </span>AddTaggedMenuItem(<span style="color: blue">string </span>menuText, <span style="color: blue">string </span>menuTag, <span style="color: blue">string </span>extensionSiteName)
    {
        <span style="color: #2b91af">ToolStripMenuItem </span>menuItem = <span style="color: blue">new </span><span style="color: #2b91af">ToolStripMenuItem</span>() { Text = menuText, ToolTipText = menuText, Tag = menuTag };

        menuItem.Click += <span style="color: blue">new </span><span style="color: #2b91af">EventHandler</span>(MenuItem_Click);

        WorkItem.UIExtensionSites[extensionSiteName].Add(menuItem);
    }

    <span style="color: blue">private void </span>MenuItem_Click(<span style="color: blue">object </span>sender, <span style="color: #2b91af">EventArgs </span>e)
    {
        <span style="color: #2b91af">ToolStripMenuItem </span>item = sender <span style="color: blue">as </span><span style="color: #2b91af">ToolStripMenuItem</span>;

        <span style="color: blue">if </span>(item != <span style="color: blue">null</span>)
        {
            WorkItem.RootWorkItem.State[<span style="color: #a31515">"LastTag"</span>] = item.Tag;
            WorkItem.Commands[<span style="color: #2b91af">CommandNames</span>.CommandWithParameters].Execute();
        }
    }

    [<span style="color: #2b91af">CommandHandler</span>(<span style="color: #2b91af">CommandNames</span>.CommandWithParameters)]
    <span style="color: blue">public void </span>OnCommandWithParameters(<span style="color: blue">object </span>sender, <span style="color: #2b91af">EventArgs </span>args)
    {
        <span style="color: blue">string </span>tag = WorkItem.RootWorkItem.State[<span style="color: #a31515">"LastTag"</span>] <span style="color: blue">as string</span>;

        <span style="color: blue">if </span>(tag != <span style="color: blue">null</span>)
        {
            <span style="color: #2b91af">MessageBox</span>.Show(<span style="color: #a31515">"The tag received in the command handler is: " </span>+ tag, <span style="color: #a31515">"Tags"</span>);
        }
    }

    <span style="color: green">// ...
</span>}</pre>
<p>In this way, the <strong>State</strong> collection is used as a container for your custom command parameters.</p>
<p>&nbsp;</p>
<p>Enjoy.</p>
</p>
<div class="wlWriterSmartContent" id="8e6b10e2-b441-4deb-bf91-97dc72185b1c" style="padding-right: 0px;padding-left: 0px;padding-bottom: 0px;margin: 0px;padding-top: 0px">Technorati Tags: <a href="http://technorati.com/tags/CAB" rel="tag">CAB</a>,<a href="http://technorati.com/tags/SCSF" rel="tag">SCSF</a>,<a href="http://technorati.com/tags/composite%20UI%20Application%20Block" rel="tag">composite UI Application Block</a>,<a href="http://technorati.com/tags/smart%20Client%20Software%20Factory" rel="tag">smart Client Software Factory</a></div>
]]></content:encoded>
			<wfw:commentRss></wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>How To: Use the Ngen tool to improve the performance in CAB / SCSF applications</title>
		<link>http://blogs.southworks.net/mconverti/2009/01/06/how-to-use-the-ngen-tool-to-improve-the-performance-in-cab-scsf-applications/</link>
		<comments>http://blogs.southworks.net/mconverti/2009/01/06/how-to-use-the-ngen-tool-to-improve-the-performance-in-cab-scsf-applications/#comments</comments>
		<pubDate>Tue, 06 Jan 2009 13:15:36 +0000</pubDate>
		<dc:creator>mconverti</dc:creator>
				<category><![CDATA[CAB]]></category>
		<category><![CDATA[NGen]]></category>
		<category><![CDATA[SCSF]]></category>

		<guid isPermaLink="false">http://blogs.southworks.net/mconverti/?p=109</guid>
		<description><![CDATA[... <a href="http://blogs.southworks.net/mconverti/2009/01/06/how-to-use-the-ngen-tool-to-improve-the-performance-in-cab-scsf-applications/" class="more-link">read more<img src="http://blogs.southworks.net/mconverti/wp-content/themes/southworks/assets/img/arrow-blue.png" width="12" height="12" alt="" /></a>]]></description>
			<content:encoded><![CDATA[<p>There are some scenarios, like applications with a very big number of modules and views, that could present performance issues at startup due to the just-in-time (JIT) compilation process. In these cases it could be useful to precompile the assemblies using the <strong>Ngen</strong> tool.</p>
<p>The <a href="http://msdn.microsoft.com/en-us/library/6t9t5wcf(VS.80).aspx">Native Image Generator (Ngen.exe)</a> is a tool that improves the performance of managed applications by creating native images, which are files containing compiled processor-specific machine code. This allows the runtime to use native images instead of using the just-in-time (JIT) compiler to compile the original assembly code in runtime. One disadvantage of native images is that you cannot use the <a href="http://msdn.microsoft.com/en-us/library/system.reflection.assembly.loadfrom(VS.80).aspx">Assembly.LoadFrom</a> method to load them.</p>
<p>If you are a user of CAB / SCSF, you may be aware of the <a href="http://msdn.microsoft.com/en-us/library/cc540704.aspx">Module Loader Service</a>. This service allows you to load modules&#8217; assemblies at run time when the application starts. The default implementation of this service uses the <a href="http://msdn.microsoft.com/en-us/library/system.reflection.assembly.loadfrom(VS.80).aspx">Assembly.LoadFrom</a> method to load the assemblies enumerated by the <a href="http://msdn.microsoft.com/en-us/library/cc540702.aspx">Module Enumerator Service</a>. So, <strong>if you try to &#8220;Ngen a CAB based application&#8221;, the native images of all your modules are not going to be used (the modules will be JIT compiled like always)</strong>.</p>
<h3>Workaround: Change the Module Loader Service class to use Assembly.Load method</h3>
<p>This workaround enables the usage of the <a href="http://msdn.microsoft.com/en-us/library/ky3942xh.aspx">Assembly.Load</a> method instead of the <a href="http://msdn.microsoft.com/en-us/library/1009fa28.aspx">Assembly.LoadFrom</a> method in the Module Loader Service class. The only limitation is that the modules’ assemblies must be physically located in the application’s working directory. To apply the workaround follow these steps:</p>
<ol>
<li>If you have an SCSF solution, open the <strong>DependentModuleLoaderService.cs</strong> file located in the <strong>Services</strong> folder of the <strong>Infrastructure.Library</strong> project. If you are using CAB without SCSF, open the <strong>ModuleLoaderService.cs</strong> file located in the <strong>Services</strong> folder of the <strong>CompositeUI</strong> project.</li>
<li>Replace the implementation of the <strong>Load(WorkItem workItem, params Assembly[] assemblies)</strong> method for the following one:
<pre><span style="color: #0000ff">public void </span>Load(<span style="color: #2b91af">WorkItem </span>workItem, <span style="color: #0000ff">params </span><span style="color: #2b91af">Assembly</span>[] assemblies)
{
    <span style="color: #2b91af">Guard</span>.ArgumentNotNull(workItem, <span style="color: #a31515">"workItem"</span>);
    <span style="color: #2b91af">Guard</span>.ArgumentNotNull(assemblies, <span style="color: #a31515">"assemblies"</span>);

    <span style="color: #2b91af">List</span>&lt;<span style="color: #2b91af">IModuleInfo</span>&gt; modules = <span style="color: #0000ff">new </span><span style="color: #2b91af">List</span>&lt;<span style="color: #2b91af">IModuleInfo</span>&gt;();

    <span style="color: #0000ff">foreach </span>(<span style="color: #2b91af">Assembly </span>assembly <span style="color: #0000ff">in </span>assemblies)
    {
        <span style="color: #2b91af">ModuleInfo </span>mi = <span style="color: #0000ff">new </span><span style="color: #2b91af">ModuleInfo</span>(assembly);
        <span style="color: #008000">// Use Assembly's Full Name instead of the Assembly's File Name.
        </span><strong>mi.SetAssemblyFile(assembly.FullName);</strong>
        modules.Add(mi);
    }

    InnerLoad(workItem, modules.ToArray());
}</pre>
<p><a href="http://11011.net/software/vspaste"></a><a href="http://11011.net/software/vspaste"></a></li>
<li>Replace the implementation of the <strong>LoadAssembly(string assemblyFile)</strong> method for the following one:
<pre><span style="color: #0000ff">private </span><span style="color: #2b91af">Assembly </span>LoadAssembly(<span style="color: #0000ff">string </span>assemblyName)
{
    <span style="color: #2b91af">Guard</span>.ArgumentNotNullOrEmptyString(assemblyName, <span style="color: #a31515">"assemblyName"</span>);
    <span style="color: #2b91af">Assembly </span>assembly = <span style="color: #0000ff">null</span>;

    <span style="color: #0000ff">try
    </span>{
        <span style="color: #008000">// Use Assembly.Load instead of Assembly.LoadFrom
        </span><strong>assembly = <span style="color: #2b91af">Assembly</span>.Load(assemblyName);</strong>
    }
    <span style="color: #0000ff">catch </span>(<span style="color: #2b91af">Exception </span>ex)
    {
        <span style="color: #0000ff">throw new </span><span style="color: #2b91af">ModuleLoadException</span>(assemblyName, ex.Message, ex);
    }

    <span style="color: #0000ff">if </span>(traceSource != <span style="color: #0000ff">null</span>)
        traceSource.TraceInformation(Properties.<span style="color: #2b91af">Resources</span>.LogModuleAssemblyLoaded, assemblyName);

    <span style="color: #0000ff">return </span>assembly;
}</pre>
<p><a href="http://11011.net/software/vspaste"></a><a href="http://11011.net/software/vspaste"></a></li>
<li>Replace the implementation of the <strong>GuardLegalAssemblyFile(IModuleInfo modInfo)</strong> method for the following one:
<pre><span style="color: #0000ff">private void </span>GuardLegalAssemblyFile(<span style="color: #2b91af">IModuleInfo </span>modInfo)
{
    <span style="color: #2b91af">Guard</span>.ArgumentNotNull(modInfo, <span style="color: #a31515">"modInfo"</span>);
    <span style="color: #2b91af">Guard</span>.ArgumentNotNull(modInfo.AssemblyFile, <span style="color: #a31515">"modInfo.AssemblyFile"</span>);
}</pre>
<p><a href="http://11011.net/software/vspaste"></a></li>
<li>Open your <strong>ProfileCatalog.xml</strong> file.</li>
<li>Change the value of the <strong>AssemblyFile</strong> attribute of each of your <strong>ModuleInfo</strong> tags to the assembly’s <a href="http://msdn.microsoft.com/en-us/library/system.reflection.assembly.fullname.aspx">Full Name</a>:
<pre><span style="color: #0000ff">&lt;</span><span style="color: #a31515">ModuleInfo </span><strong><span style="color: #ff0000">AssemblyFile</span><span style="color: #0000ff">=</span>"<span style="color: #0000ff">Module1, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null</span>"</strong> <span style="color: #0000ff">/&gt;
&lt;</span><span style="color: #a31515">ModuleInfo </span><strong><span style="color: #ff0000">AssemblyFile</span><span style="color: #0000ff">=</span>"<span style="color: #0000ff">Module2, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null</span>"</strong> <span style="color: #0000ff">/&gt;</span></pre>
<p><a href="http://11011.net/software/vspaste"></a></li>
</ol>
<h3>Running Ngen on CAB based applications</h3>
<p>When you run Ngen.exe on an assembly, it also generates native images for the all its dependencies (dependencies are determined from references in the assembly manifest). The only scenario in which you need to <em>install</em> a dependency separately is when the application loads it using reflection, for example by calling the <strong>Assembly.Load</strong> method.</p>
<p>This is the case for CAB / SCSF applications, so you must run Ngen for the your application executable (<strong>exe</strong> file) and all its modules. To do this follow these steps:</p>
<ol>
<li>Open a <strong>Visual Studio Command Prompt</strong>.<br />
<table border="1" cellspacing="0" cellpadding="1" width="500">
<tbody>
<tr>
<td width="500" valign="top"><strong>Note</strong>: If you are running on Vista with the <strong>User Account Control</strong> (UAC) activated, you must open it with the option <strong>Run as administrator</strong>.</td>
</tr>
</tbody>
</table>
</li>
<li>Navigate to the directory where all your applications binaries are located and run the following command:
<pre>ngen install YourApplication.exe</pre>
<p><a href="http://11011.net/software/vspaste"></a></li>
<li>Run the same command for all of your business and foundational modules.
<pre>ngen install ModuleN.dll</pre>
</li>
</ol>
<h3>Results</h3>
<p>After applying the workaround on the <a href="http://msdn.microsoft.com/en-us/library/cc540808.aspx">BankTeller Quickstart</a> and running Ngen to its binaries, the <strong>JIT compilation</strong> time was eliminated. To profile the application I used the <a href="http://www.red-gate.com/products/ants_profiler">ANTS Profiler</a>.</p>
<ul>
<li>Before generation the native images, the application presented some peaks in the JIT compilation time.<br />
<a href="http://blogs.southworks.net/mconverti/files/2009/01/withoutngen-thumb1.png"><img src="http://blogs.southworks.net/mconverti/files/2009/01/withoutngen.png" border="0" alt="Before generating the native images" width="640" height="53" /></a></li>
<li>After generating the native images, the JIT compilation time was eliminated.<br />
<a href="http://blogs.southworks.net/mconverti/files/2009/01/withngen-thumb1.png"><img src="http://blogs.southworks.net/mconverti/files/2009/01/withngen.png" border="0" alt="After generating the native images" width="640" height="53" /></a></li>
</ul>
<table border="1" cellspacing="0" cellpadding="1" width="500">
<tbody>
<tr>
<td width="500" valign="top"><strong>Note</strong>: In order to perform profiling to native images, you must <em>install</em> them using the <strong><em>/Profile</em></strong> scenario as follows:</p>
<pre><strong>ngen install YourApplication.exe /Profile</strong></pre>
</td>
</tr>
</tbody>
</table>
<p> </p>
<p>Feedback is appreciated!</p>
<p>Mariano</p>
<div id="65d44cfa-268a-4487-a89c-b5f4f54b893a" class="wlWriterSmartContent" style="padding-right: 0px;padding-left: 0px;padding-bottom: 0px;margin: 0px;padding-top: 0px">Technorati Tags: <a rel="tag" href="http://technorati.com/tags/CAB">CAB</a>,<a rel="tag" href="http://technorati.com/tags/SCSF">SCSF</a>,<a rel="tag" href="http://technorati.com/tags/Ngen">Ngen</a></div>
<div class="wlWriterSmartContent" style="padding-right: 0px;padding-left: 0px;padding-bottom: 0px;margin: 0px;padding-top: 0px"><a href="http://www.dotnetkicks.com/kick/?url=http%3a%2f%2fblogs.southworks.net%2fmconverti%2f2009%2f01%2f06%2fhow-to-use-the-ngen-tool-to-improve-the-performance-in-cab-scsf-applications%2f"><img style="border: 0px" src="http://www.dotnetkicks.com/Services/Images/KickItImageGenerator.ashx?url=http%3a%2f%2fblogs.southworks.net%2fmconverti%2f2009%2f01%2f06%2fhow-to-use-the-ngen-tool-to-improve-the-performance-in-cab-scsf-applications%2" alt="kick it on DotNetKicks.com" /></a></div>
]]></content:encoded>
			<wfw:commentRss></wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Smart Client Software Factory (SCSF) GP source code with Installer that works on Visual Studio 2008 + SP1</title>
		<link>http://blogs.southworks.net/mconverti/2008/09/29/smart-client-software-factory-scsf-gp-source-code-with-installer-that-works-on-visual-studio-2008-sp1/</link>
		<comments>http://blogs.southworks.net/mconverti/2008/09/29/smart-client-software-factory-scsf-gp-source-code-with-installer-that-works-on-visual-studio-2008-sp1/#comments</comments>
		<pubDate>Mon, 29 Sep 2008 19:15:14 +0000</pubDate>
		<dc:creator>mconverti</dc:creator>
				<category><![CDATA[CAB]]></category>
		<category><![CDATA[SCSF]]></category>

		<guid isPermaLink="false">http://blogs.southworks.net/mconverti/?p=99</guid>
		<description><![CDATA[... <a href="http://blogs.southworks.net/mconverti/2008/09/29/smart-client-software-factory-scsf-gp-source-code-with-installer-that-works-on-visual-studio-2008-sp1/" class="more-link">read more<img src="http://blogs.southworks.net/mconverti/wp-content/themes/southworks/assets/img/arrow-blue.png" width="12" height="12" alt="" /></a>]]></description>
			<content:encoded><![CDATA[<p>A couple of months ago I <a href="http://blogs.southworks.net/mconverti/2008/07/02/scsf-april-2008-with-vs2008-sp1-known-issues/">announced</a> in my blog that the P&amp;P Sustained Engineering team had published an article in the <a href="http://www.codeplex.com/smartclient/Wiki/View.aspx?title=SCSF%20Knowledge%20Base">SCSF Knowledge Base</a> that describes the <a href="http://www.codeplex.com/smartclient/Wiki/View.aspx?title=Known%20Issues%3a%20SC-SF%20April%202008%20with%20Visual%20Studio%202008%20and%20SP1%20Beta" target="_blank">Known Issues and Fixes</a> for the <a href="http://www.microsoft.com/downloads/details.aspx?FamilyId=3BE112CC-B2C1-4215-9330-9C8CF9BCC6FA&amp;displaylang=en">SCSF &#8211; April 2008</a> release running with <a href="http://www.microsoft.com/downloads/details.aspx?FamilyId=FBEE1648-7106-44A7-9649-6D9F6D58056E&amp;displaylang=en">Microsoft Visual Studio 2008 Service Pack 1</a>.</p>
<p>The fixes for these issues included modifying the guidance package source code and register a custom one. So I decided to post the source code with the fixes including a setup project in order to create an installer for it.</p>
<p><strong>Download it from <a href="http://cid-9c64c688b3024d64.skydrive.live.com/self.aspx/Smart%20Client%20Software%20Factory/SmartClientFactoryPackage.zip">here</a>.<br />
</strong></p>
<table border="1" cellspacing="0" cellpadding="2" width="500">
<tbody>
<tr>
<td width="600" valign="top"><strong>Disclaimer</strong>: This is not an official Microsoft release. Use it at your own risk.</td>
</tr>
</tbody>
</table>
<h2>Registering the Guidance Package using the installer</h2>
<p>To register the guidance package using the custom installer performs the following steps:</p>
<ol>
<li>Open and build the <strong>GuidancePackage.sln</strong> solution to generate the installer.</li>
<li>Navigate to the <strong>SmartClientFactorySetup\Debug</strong> folder.</li>
<li>Close all instances of <strong>Visual Studio</strong>.</li>
<li>Run the <strong>SmartClientFactoryPackageSetup.msi</strong> installer.<br />
<table border="1" cellspacing="0" cellpadding="2" width="600">
<tbody>
<tr>
<td width="598" valign="top"><strong>Note</strong>: If you are running on Vista with the <strong>User Account Control</strong> (UAC) activated, you must run the installer with the option <strong>Run as administrator</strong>.</td>
</tr>
</tbody>
</table>
</li>
</ol>
<h2>Manually registering the Guidance Package</h2>
<p>To manually register the guidance package perform the following steps:</p>
<ol>
<li>Open the <strong>GuidancePackage.sln</strong> solution.<br />
<table border="1" cellspacing="0" cellpadding="2" width="600">
<tbody>
<tr>
<td width="598" valign="top"><strong>Note</strong>: If you are running on Vista with the <strong>User Account Control</strong> (UAC) activated, you must open Visual Studio with the option <strong>Run as administrator</strong>.</td>
</tr>
</tbody>
</table>
</li>
<li>On the <strong>Tools</strong> menu of Visual Studio, click <strong>Guidance Package Manager</strong>.</li>
<li>In the <strong>Guidance Package Manager</strong> dialog box, click <strong>Enable / Disable Packages</strong>.</li>
<li>In the <strong>Enable and Disable Packages</strong> dialog box, select the <strong>Guidance Package Development</strong> check box.</li>
<li>Click <strong>OK</strong>.<br />
<table border="1" cellspacing="0" cellpadding="2" width="600">
<tbody>
<tr>
<td width="598" valign="top">Enabling the <strong>Guidance Package Development</strong> allows you to register a guidance package.</td>
</tr>
</tbody>
</table>
</li>
<li>Close all other instances of <strong>Visual Studio</strong>.</li>
<li>Right-click the <strong>SmartClientFactoryPackage</strong> project, and then click <strong>Register Guidance Package</strong>.</li>
</ol>
<p>For more information you can check the following article:</p>
<ul>
<li><a href="http://msdn.microsoft.com/en-us/library/cc558915.aspx">Modifying the Guidance Package</a></li>
</ul>
<h2>Using the Fixed Guidance Package</h2>
<p>Once you have installed/registered the guidance package, you will be able to use the <strong>Smart Client Development for SP1</strong> package (see the image below).</p>
<p><img src="http://blogs.southworks.net/mconverti/files/2008/09/smartclientdevelopmentforsp1-thumb.png" border="0" alt="SmartClientDevelopmentForSP1" width="604" height="435" /></p>
<p>Enjoy.</p>
<div id="b8ffbdec-6ec8-4a8f-87cc-0576c3b24afb" class="wlWriterSmartContent" style="padding-right: 0px;padding-left: 0px;padding-bottom: 0px;margin: 0px;padding-top: 0px">Technorati Tags: <a rel="tag" href="http://technorati.com/tags/SCSF">SCSF</a>,<a rel="tag" href="http://technorati.com/tags/Smart%20Client%20Software%20Factory">Smart Client Software Factory</a>,<a rel="tag" href="http://technorati.com/tags/CAB">CAB</a>,<a rel="tag" href="http://technorati.com/tags/Composite%20UI%20Application%20Block">Composite UI Application Block</a></div>
]]></content:encoded>
			<wfw:commentRss></wfw:commentRss>
		<slash:comments>13</slash:comments>
		</item>
		<item>
		<title>Workaround for DeckWorkspace issue: The smartpart is not present in the workspace</title>
		<link>http://blogs.southworks.net/mconverti/2008/09/09/workaround-for-deckworkspace-issue-the-smartpart-is-not-present-in-the-workspace/</link>
		<comments>http://blogs.southworks.net/mconverti/2008/09/09/workaround-for-deckworkspace-issue-the-smartpart-is-not-present-in-the-workspace/#comments</comments>
		<pubDate>Tue, 09 Sep 2008 19:00:05 +0000</pubDate>
		<dc:creator>mconverti</dc:creator>
				<category><![CDATA[CAB]]></category>
		<category><![CDATA[SCSF]]></category>

		<guid isPermaLink="false">http://blogs.southworks.net/mconverti/?p=95</guid>
		<description><![CDATA[... <a href="http://blogs.southworks.net/mconverti/2008/09/09/workaround-for-deckworkspace-issue-the-smartpart-is-not-present-in-the-workspace/" class="more-link">read more<img src="http://blogs.southworks.net/mconverti/wp-content/themes/southworks/assets/img/arrow-blue.png" width="12" height="12" alt="" /></a>]]></description>
			<content:encoded><![CDATA[<p>There are several questions in the <a href="http://www.codeplex.com/smartclient/Thread/List.aspx">SCSF forums</a> asking about this excepction: <strong>The smartpart is not present in the workspace</strong>, when using the <strong>DeckWorkspace</strong>.</p>
<h3>Symptom</h3>
<p>When you show several views in the same <strong>DeckWorkspace</strong> and then close the application or terminate the parent <strong>WorkItem</strong>, you get the following exception:</p>
<p><img src="http://blogs.southworks.net/mconverti/files/2008/09/exception-thumb.png" border="0" alt="Exception" width="504" height="267" /></p>
<h3>Cause</h3>
<p>Every time a <strong>Smartpart</strong> is closed in a <strong>DeckWorkspace</strong> it is removed from its <strong>Controls</strong> collection. Then the <strong>ActivateTopmost</strong> method is called to show the previously shown <strong>Smartpart</strong>. That method takes the first element in the <strong>Controls</strong> collection of the <strong>DeckWorkspace</strong> and activates it (<strong>this.Controls[0]</strong>).</p>
<p>When the <strong>Shell</strong> is being closed (by closing the application), the <strong>DeckWorkspace</strong> is disposed and starts to dispose all of its child elements. Therefore, because the <strong>DeckWorkspace</strong> is being disposed, the <strong>Controls</strong> collection cannot be modified.</p>
<p>Consequently, when the <strong>Smarparts</strong> in the <strong>DeckWorkspace</strong> begin to get closed, they cannot be removed from the <strong>Controls</strong> collection (because it is being disposed). The <strong>ActivateTopmost</strong> method then receives a <strong>Smartpart</strong> that is no longer present in the DeckWorkspace and tries to activate it. This causes the &#8220;<strong>The SmartPart is not present in workspace&#8221;</strong> exception.</p>
<h3>Workaround</h3>
<p>Modify the <strong>Deckworkspace</strong> source code (you will need to have the <a href="http://www.microsoft.com/downloads/details.aspx?FamilyId=5C42C35D-DA1C-40B9-892E-11AB13AAFD9E&amp;displaylang=en">SCSF source code</a> installed) to avoid activating the previous <strong>Smartpart </strong>when the workspace is being disposed.</p>
<p>You can perform the following steps to get this done:</p>
<ol>
<li>Open the <strong>CompositeUI-CS.sln</strong> solution.</li>
<li>Right-click in the <strong>DeckWorkspace.cs</strong> file located in the <strong>Workspaces</strong> folder in the <strong>CompositeUI.WinForms</strong> project and select the <strong>View Code</strong> option.</li>
<li>Replace the <strong>OnClose</strong> method for the following one:
<pre><span style="color: #0000ff">protected virtual void </span>OnClose(<span style="color: #2b91af">Control </span>smartPart)
{
    <span style="color: #0000ff">this</span>.Controls.Remove(smartPart);

    smartPart.Disposed -= ControlDisposed;

<strong>    <span style="color: #0000ff">if </span>(!Disposing)
    {
        ActivateTopmost();
    }</strong>
}</pre>
<p><a href="http://11011.net/software/vspaste"></a></li>
<li>Build the solution.</li>
<li>Copy the recompiled CAB assemblies to the <strong>Lib</strong> folder of your SCSF solution.</li>
</ol>
<div id="761f4d47-a742-4ff7-bf41-73b8835b42cf" class="wlWriterSmartContent" style="padding-right: 0px;padding-left: 0px;padding-bottom: 0px;margin: 0px;padding-top: 0px">Technorati Tags: <a rel="tag" href="http://technorati.com/tags/CAB">CAB</a>,<a rel="tag" href="http://technorati.com/tags/SCSF">SCSF</a></div>
]]></content:encoded>
			<wfw:commentRss></wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>WPF Quickstart (shipped with SCSF) regenerated using Composite WPF (Prism)</title>
		<link>http://blogs.southworks.net/mconverti/2008/09/07/wpf-quickstart-shipped-with-scsf-regenerated-using-composite-wpf-prism/</link>
		<comments>http://blogs.southworks.net/mconverti/2008/09/07/wpf-quickstart-shipped-with-scsf-regenerated-using-composite-wpf-prism/#comments</comments>
		<pubDate>Sun, 07 Sep 2008 21:12:42 +0000</pubDate>
		<dc:creator>mconverti</dc:creator>
				<category><![CDATA[Composite WPF]]></category>
		<category><![CDATA[CompositeWPFContrib]]></category>
		<category><![CDATA[SCSF]]></category>

		<guid isPermaLink="false">http://blogs.southworks.net/mconverti/?p=84</guid>
		<description><![CDATA[... <a href="http://blogs.southworks.net/mconverti/2008/09/07/wpf-quickstart-shipped-with-scsf-regenerated-using-composite-wpf-prism/" class="more-link">read more<img src="http://blogs.southworks.net/mconverti/wp-content/themes/southworks/assets/img/arrow-blue.png" width="12" height="12" alt="" /></a>]]></description>
			<content:encoded><![CDATA[<p>We published in the <a href="http://www.codeplex.com/compositewpfcontrib" target="_blank">CompositeWPFContrib</a> web site a new sample application. This application is the <a href="http://msdn.microsoft.com/en-us/library/cc540814.aspx" target="_blank">WPF Quickstart</a> (shipped with the <a href="http://www.microsoft.com/downloads/details.aspx?FamilyId=5C42C35D-DA1C-40B9-892E-11AB13AAFD9E&amp;displaylang=en" target="_blank">SCSF source code</a>) regenerated using the <a href="http://msdn.microsoft.com/en-us/library/cc707819.aspx" target="_blank">Composite Application Guidance for WPF</a>. We used this sample application while drafting the <a href="http://www.codeplex.com/CompositeWPF/Release/ProjectReleases.aspx?ReleaseId=16941" target="_blank">Composite Application Guidance for CAB Developers</a> document.</p>
<p>You can find this sample in the last <strong>Change Set</strong> of the <a href="http://www.codeplex.com/CompositeWPFContrib/SourceControl/ListDownloadableCommits.aspx" target="_blank">CompositeWPFContrib source code</a> or download it from <a href="http://www.codeplex.com/CompositeWPFContrib/SourceControl/DownloadSourceCode.aspx?changeSetId=15595" target="_blank">here</a>.     <br /><img height="414" alt="DifferentComponents" src="http://blogs.southworks.net/mconverti/files/2008/09/differentcomponents-thumb2.png" width="609" border="0" /></p>
<p>This new sample also includes documentation about how the regeneration was performed. This document is available in the <a href="http://www.codeplex.com/CompositeWPFContrib/Wiki/View.aspx?title=Documentation" target="_blank">Documentation</a> section of the <a href="http://www.codeplex.com/compositewpfcontrib">CompositeWPFContrib</a> web site:</p>
<ul>
<li><a href="http://www.codeplex.com/CompositeWPFContrib/Wiki/View.aspx?title=WPFQuickstartRegeneratedWithCAL" target="_blank">Regenerating the WPF/SC-SF Quickstart with the Composite Application Library</a> </li>
</ul>
<p><img height="237" alt="Document" src="http://blogs.southworks.net/mconverti/files/2008/09/document-thumb.png" width="609" border="0" /></p>
<h3>Related Resources</h3>
<p>If you are interesting in migration scenarios you may find useful the following links:</p>
<ul>
<li><a href="http://www.codeplex.com/CompositeWPF/Release/ProjectReleases.aspx?ReleaseId=16941" target="_blank">Composite Application Guidance for CAB Developers</a>: Document that helps you to map CAB concepts to CAL concepts. You may want to look at this documentation if you are considering a new WPF project and are familiar with CAB concepts, or are moving a CAB application to the Composite Application Library. </li>
<li><a href="http://www.codeplex.com/CompositeWPF/Wiki/View.aspx?title=Migration%20from%20CAB" target="_blank">Migration from CAB</a>: Section in the <a href="http://www.codeplex.com/CompositeWPF/Wiki/View.aspx?title=Knowledge%20Base" target="_blank">CompositeWPF Knowledge Base</a> that includes articles/questions about migration scenarios. </li>
</ul>
<p>&#160;</p>
<div class="wlWriterSmartContent" id="de1833f9-9fb4-4481-94c6-704761cd8065" style="padding-right: 0px;padding-left: 0px;padding-bottom: 0px;margin: 0px;padding-top: 0px">Technorati Tags: <a href="http://technorati.com/tags/Composite%20WPF" rel="tag">Composite WPF</a>,<a href="http://technorati.com/tags/CompositeWPFContrib" rel="tag">CompositeWPFContrib</a>,<a href="http://technorati.com/tags/SCSF" rel="tag">SCSF</a>,<a href="http://technorati.com/tags/Prism" rel="tag">Prism</a></div>
]]></content:encoded>
			<wfw:commentRss></wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>How-to: Use the Disconnected Service Agent (DSA) with CompositeWPF (Prism)</title>
		<link>http://blogs.southworks.net/mconverti/2008/08/11/composite-wpf-with-dsa-sample/</link>
		<comments>http://blogs.southworks.net/mconverti/2008/08/11/composite-wpf-with-dsa-sample/#comments</comments>
		<pubDate>Mon, 11 Aug 2008 19:07:00 +0000</pubDate>
		<dc:creator>mconverti</dc:creator>
				<category><![CDATA[Composite WPF]]></category>
		<category><![CDATA[Disconnected Service Agent]]></category>
		<category><![CDATA[SCSF]]></category>

		<guid isPermaLink="false">http://blogs.southworks.net/mconverti/?p=79</guid>
		<description><![CDATA[... <a href="http://blogs.southworks.net/mconverti/2008/08/11/composite-wpf-with-dsa-sample/" class="more-link">read more<img src="http://blogs.southworks.net/mconverti/wp-content/themes/southworks/assets/img/arrow-blue.png" width="12" height="12" alt="" /></a>]]></description>
			<content:encoded><![CDATA[<p>A popular demand in Codeplex forums the past weeks has been related to working under temporarily connected scenarios. The <a href="http://msdn.microsoft.com/en-us/library/cc540752.aspx">Disconnected Service Agent Application Block</a> that has been shipped with the SCSF since the May 2007 version was specially designed for this type of scenarios. <a href="http://blogs.southworks.net/dschenkelman" target="_blank">Damian Schenkelman</a> wrote a <a href="http://blogs.southworks.net/dschenkelman/2008/08/04/dsa-application-block-overview/">blog post </a>overviewing the DSA to answer some of these questions.</p>
<p>Now that the <a href="http://www.microsoft.com/downloads/details.aspx?FamilyId=6DD3D0C1-D5B4-453B-B827-98E162E1BD8D&amp;displaylang=en">Composite Application Guidance for WPF</a> has been released, the issue became whether it was possible to use the DSA with Composite WPF. Therefore we decided to spend some time migrating the <a href="http://msdn.microsoft.com/en-us/library/cc540813.aspx" target="_blank">Disconnected Service Agent QuickStart</a> from SCSF to its equal in Composite Application Library.</p>
<p><img alt="" src="http://blogs.southworks.net/mconverti/files/2008/08/compositewpfwithdsa2.png" /></p>
</p>
<p>You can get the sample by downloading the <a href="http://www.codeplex.com/CompositeWPFContrib/SourceControl/ListDownloadableCommits.aspx">latest change set</a> of the <a href="http://www.codeplex.com/CompositeWPFContrib">CompositeWPF Contrib</a> source control.</p>
<h3>Using DSA in a Composite WPF application</h3>
<p>All the <strong>Offline Blocks</strong> (<strong>Disconnected Service Agent</strong>, <strong>Endpoint Catalog</strong> and <strong>Connection Monitor</strong>) shipped with <a href="http://www.microsoft.com/downloads/details.aspx?familyid=2b6a10f9-8410-4f13-ad53-05a202fbdb63&amp;displaylang=en" target="_blank">SCSF &#8211; May 2007</a> and higher versions do not have dependencies on CAB/SCSF.</p>
<p>To be able to use those blocks in a Composite WPF application you can do the following:</p>
<ol>
<li>Add the following configuration to the <strong>App.config</strong> file to configure the connection monitor and select the data storage that will be consumed by the DSA:
<pre><span style="color: #0000ff">&lt;</span><span style="color: #a31515">configuration</span><span style="color: #0000ff">&gt;
  &lt;</span><span style="color: #a31515">configSections</span><span style="color: #0000ff">&gt;
    &lt;</span><span style="color: #a31515">section </span><span style="color: #ff0000">name</span><span style="color: #0000ff">=</span>&quot;<span style="color: #0000ff">ConnectionMonitor</span>&quot;
             <span style="color: #ff0000">type</span><span style="color: #0000ff">=</span>&quot;<span style="color: #0000ff">Microsoft.Practices.SmartClient.ConnectionMonitor.Configuration.ConnectionSettingsSection, Microsoft.Practices.SmartClient.ConnectionMonitor</span>&quot; <span style="color: #0000ff">/&gt;
    &lt;</span><span style="color: #a31515">section </span><span style="color: #ff0000">name</span><span style="color: #0000ff">=</span>&quot;<span style="color: #0000ff">dataConfiguration</span>&quot;
             <span style="color: #ff0000">type</span><span style="color: #0000ff">=</span>&quot;<span style="color: #0000ff">Microsoft.Practices.EnterpriseLibrary.Data.Configuration.DatabaseSettings, Microsoft.Practices.EnterpriseLibrary.Data</span>&quot; <span style="color: #0000ff">/&gt;
  &lt;/</span><span style="color: #a31515">configSections</span><span style="color: #0000ff">&gt;
  &lt;</span><span style="color: #a31515">connectionStrings</span><span style="color: #0000ff">&gt;
    &lt;</span><span style="color: #a31515">add </span><span style="color: #ff0000">name</span><span style="color: #0000ff">=</span>&quot;<span style="color: #0000ff">QueueDatabase</span>&quot; <span style="color: #ff0000">connectionString</span><span style="color: #0000ff">=</span>&quot;<span style="color: #0000ff">YourConnectionString</span>&quot; <span style="color: #ff0000">providerName</span><span style="color: #0000ff">=</span>&quot;<span style="color: #0000ff">YourProvider</span>&quot; <span style="color: #0000ff">/&gt;
  &lt;/</span><span style="color: #a31515">connectionStrings</span><span style="color: #0000ff">&gt;
  &lt;</span><span style="color: #a31515">ConnectionMonitor</span><span style="color: #0000ff">&gt;
    &lt;</span><span style="color: #a31515">Networks</span><span style="color: #0000ff">&gt;
      &lt;!-- </span><span style="color: #008000">To check for internet connectivity</span><span style="color: #0000ff">--&gt;
      &lt;</span><span style="color: #a31515">add </span><span style="color: #ff0000">Name</span><span style="color: #0000ff">=</span>&quot;<span style="color: #0000ff">Internet</span>&quot; <span style="color: #ff0000">Address</span><span style="color: #0000ff">=</span>&quot;<span style="color: #0000ff">http://www.google.com</span>&quot; <span style="color: #0000ff">/&gt;
    &lt;/</span><span style="color: #a31515">Networks</span><span style="color: #0000ff">&gt;
  &lt;/</span><span style="color: #a31515">ConnectionMonitor</span><span style="color: #0000ff">&gt;
  &lt;</span><span style="color: #a31515">dataConfiguration </span><span style="color: #ff0000">defaultDatabase</span><span style="color: #0000ff">=</span>&quot;<span style="color: #0000ff">QueueDatabase</span>&quot;<span style="color: #0000ff">&gt;
    &lt;</span><span style="color: #a31515">providerMappings</span><span style="color: #0000ff">&gt;
      &lt;</span><span style="color: #a31515">add </span><span style="color: #ff0000">databaseType</span><span style="color: #0000ff">=</span>&quot;<span style="color: #0000ff">Microsoft.Practices.SmartClient.EnterpriseLibrary.SmartClientDatabase, Microsoft.Practices.SmartClient.EnterpriseLibrary</span>&quot;
           <span style="color: #ff0000">name</span><span style="color: #0000ff">=</span>&quot;<span style="color: #0000ff">System.Data.SqlServerCe</span>&quot; <span style="color: #0000ff">/&gt;
    &lt;/</span><span style="color: #a31515">providerMappings</span><span style="color: #0000ff">&gt;
  &lt;/</span><span style="color: #a31515">dataConfiguration</span><span style="color: #0000ff">&gt;</span><span style="color: #0000ff">
&lt;/</span><span style="color: #a31515">configuration</span><span style="color: #0000ff">&gt;</span></pre>
<p><a href="http://11011.net/software/vspaste"></a><a href="http://11011.net/software/vspaste"></a><a href="http://11011.net/software/vspaste"></a><a href="http://11011.net/software/vspaste"></a></p>
</li>
<li>Set up the Request Manager by overriding the <strong>ConfigureContainer</strong> method of your application&#8217;s <strong>Bootstrapper</strong> class.
<pre><span style="color: #0000ff">protected override void </span>ConfigureContainer()
{
    <span style="color: #008000">// Set up request manager.
    </span><span style="color: #2b91af">RequestManager </span>requestManager = <span style="color: #2b91af">DatabaseRequestManagerIntializer</span>.Initialize();
    requestManager.StartAutomaticDispatch();

    <span style="color: #008000">// Add the request queue to the Container. This queue will be used by service agents to enqueue requests.
    </span>Container.RegisterInstance&lt;<span style="color: #2b91af">IRequestQueue</span>&gt;(requestManager.RequestQueue, <span style="color: #0000ff">new </span><span style="color: #2b91af">ContainerControlledLifetimeManager</span>());

    <span style="color: #008000">// Add the connection monitor to the Container. It will be used to determine connectivity status and provide    // feedback to the user accordingly.
    </span>Container.RegisterInstance&lt;<span style="color: #2b91af">IConnectionMonitor</span>&gt;(requestManager.ConnectionMonitor, <span style="color: #0000ff">new </span><span style="color: #2b91af">ContainerControlledLifetimeManager</span>());

    <span style="color: #0000ff">base</span>.ConfigureContainer();
}</pre>
<p><a href="http://11011.net/software/vspaste"></a></p>
</li>
<li>Create an <strong>Agent </strong>service class that uses the <strong>IRequestQueue</strong> to define the offline behavior of your web service (in SCSF this is performed by the <a href="http://msdn.microsoft.com/en-us/library/cc540833.aspx" target="_blank">Create a Disconnected Service Agent</a> recipe). </li>
<li>Register an instance of your <strong>Agent</strong> class into your container. You can do this in your <strong>Module</strong> class.
<pre><span style="color: #0000ff">public void </span>Initialize()
{
    RegisterTypesAndServices();

    <span style="color: #008000">// Add your module views...
</span>}

<span style="color: #0000ff">private void </span>RegisterTypesAndServices()
{
    Container.RegisterType&lt;<span style="color: #2b91af">Agent</span>&gt;(<span style="color: #0000ff">new </span><span style="color: #2b91af">ContainerControlledLifetimeManager</span>());
}</pre>
</li>
</ol>
<p><a href="http://11011.net/software/vspaste"></a></p>
<p>Now you are able to inject your service agent in your classes.</p>
<p>Enjoy.</p>
<div class="wlWriterSmartContent" id="1c7a17b7-f4d9-4681-9ceb-bbe9ef9281ec" style="padding-right: 0px;padding-left: 0px;padding-bottom: 0px;margin: 0px;padding-top: 0px">Technorati Tags: <a href="http://technorati.com/tags/CompositeWPF" rel="tag">CompositeWPF</a>,<a href="http://technorati.com/tags/Disconnected%20Service%20Agent" rel="tag">Disconnected Service Agent</a>,<a href="http://technorati.com/tags/SCSF" rel="tag">SCSF</a></div>
]]></content:encoded>
			<wfw:commentRss></wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>How To: Get the active view across multiple workspaces in a SCSF application</title>
		<link>http://blogs.southworks.net/mconverti/2008/08/04/how-to-get-the-active-view-across-multiple-workspaces-in-a-scsf-application/</link>
		<comments>http://blogs.southworks.net/mconverti/2008/08/04/how-to-get-the-active-view-across-multiple-workspaces-in-a-scsf-application/#comments</comments>
		<pubDate>Mon, 04 Aug 2008 14:09:59 +0000</pubDate>
		<dc:creator>mconverti</dc:creator>
				<category><![CDATA[CAB]]></category>
		<category><![CDATA[SCSF]]></category>

		<guid isPermaLink="false">http://blogs.southworks.net/mconverti/?p=73</guid>
		<description><![CDATA[... <a href="http://blogs.southworks.net/mconverti/2008/08/04/how-to-get-the-active-view-across-multiple-workspaces-in-a-scsf-application/" class="more-link">read more<img src="http://blogs.southworks.net/mconverti/wp-content/themes/southworks/assets/img/arrow-blue.png" width="12" height="12" alt="" /></a>]]></description>
			<content:encoded><![CDATA[<p>Last week I saw a <a href="http://www.codeplex.com/smartclient/Thread/View.aspx?ThreadId=32692">question</a> in the <a href="http://www.codeplex.com/smartclient/Thread/List.aspx" target="_blank">SCSF forum</a> about getting the active view in an application with several types of workspaces. In his post <a href="http://www.chrisholmesonline.com/2007/05/11/cab-solving-the-active-view-problem/">CAB: Solving The Active View Problem</a>, Chris Holmes tackles the scenario within the context of a single workspace. I found a way to apply another solution that gets the Active View by monitoring all workspaces. I created the <strong>ActiveViewMonitorService</strong> service that is in charge of doing this.</p>
<p>I made a sample application that shows how this service works. <a href="http://blogs.southworks.net/mconverti/files/2008/08/activeviewmonitorservicesample.zip">Download from here</a>.</p>
<p><a href="http://blogs.southworks.net/mconverti/files/2008/08/servicesample.png" target="_blank"><img height="290" src="http://blogs.southworks.net/mconverti/files/2008/08/servicesample.png" width="520" border="0" /></a></p>
<p>Change the application&#8217;s active view by clicking in the <strong>TextBox </strong>of each view. Then click in the <strong>Active View</strong> button in the main menu bar to verify the active view&#8217;s name.</p>
<h3>Implementation Details</h3>
<p>The <strong>ActiveViewMonitorService</strong> service monitors the <strong>SmartPartActivated</strong> and <strong>Enter</strong> events for each workspace in the application. The <strong>SmartPartActivated</strong> allows to know when the user is changing the active view in the context of the same workspace and the <strong>Enter </strong>event allows to know when the user is changing to a view in another workspace. The following is the service implementation:</p>
<pre><span style="color: blue">public interface </span><span style="color: #2b91af">IActiveViewMonitorService
</span>{
    <span style="color: blue">void </span>AddWorkspaceToMonitor(<span style="color: #2b91af">IWorkspace </span>workspace);
    <span style="color: blue">object </span>ActiveView { <span style="color: blue">get</span>; }
}

<span style="color: blue">public class </span><span style="color: #2b91af">ActiveViewMonitorService </span>: <span style="color: #2b91af">IActiveViewMonitorService
</span>{
    <span style="color: blue">#region </span>IActiveViewMonitorService Members

    <span style="color: blue">public void </span>AddWorkspaceToMonitor(<span style="color: #2b91af">IWorkspace </span>workspace)
    {
        workspace.SmartPartActivated += <span style="color: blue">new </span><span style="color: #2b91af">EventHandler</span>&lt;<span style="color: #2b91af">WorkspaceEventArgs</span>&gt;(OnSmartPartActivated);
        ActiveView = workspace.ActiveSmartPart;

        <span style="color: #2b91af">Control </span>wk = workspace <span style="color: blue">as </span><span style="color: #2b91af">Control</span>;
        <span style="color: blue">if </span>(wk != <span style="color: blue">null</span>)
        {
            wk.Enter += <span style="color: blue">new </span><span style="color: #2b91af">EventHandler</span>(OnEnter);
        }
    }

    <span style="color: blue">public object </span>ActiveView { <span style="color: blue">get</span>; <span style="color: blue">private set</span>; }

    <span style="color: blue">#endregion

    private void </span>OnSmartPartActivated(<span style="color: blue">object </span>sender, <span style="color: #2b91af">WorkspaceEventArgs </span>e)
    {
        ActiveView = e.SmartPart;
    }

    <span style="color: blue">private void </span>OnEnter(<span style="color: blue">object </span>sender, <span style="color: #2b91af">EventArgs </span>e)
    {
        <span style="color: #2b91af">IWorkspace </span>wk = sender <span style="color: blue">as </span><span style="color: #2b91af">IWorkspace</span>;

        <span style="color: blue">if </span>(wk != <span style="color: blue">null</span>)
        {
            ActiveView = wk.ActiveSmartPart;
        }
    }
}</pre>
<p><a href="http://11011.net/software/vspaste"></a></p>
<h4>Steps</h4>
<ol>
<li>Register it as a service in the RootWorkItem. </li>
<li>Add the workspaces you want to monitor using the <b>AddWorkspaceToMonitor</b> method (you can do this by adding an event handler to the <strong>Initialized </strong>event of the RootWorkItem in the <strong>ShellApplication</strong> class).
<pre><span style="color: green">// ShellApplication class
</span><span style="color: blue">protected override void </span>AfterShellCreated()
{
    RootWorkItem.Initialized += <span style="color: blue">new </span><span style="color: #2b91af">EventHandler</span>(RootWorkItem_Initialized);
}

<span style="color: blue">private void </span>RootWorkItem_Initialized(<span style="color: blue">object </span>sender, <span style="color: #2b91af">EventArgs </span>args)
{
    <span style="color: #2b91af">IActiveViewMonitorService </span>activeViewMonitorService = RootWorkItem.Services.Get&lt;<span style="color: #2b91af">IActiveViewMonitorService</span>&gt;();

    <span style="color: blue">foreach </span>(<span style="color: #2b91af">KeyValuePair</span>&lt;<span style="color: blue">string</span>, <span style="color: #2b91af">IWorkspace</span>&gt; key <span style="color: blue">in </span>RootWorkItem.Workspaces)
    {
        activeViewMonitorService.AddWorkspaceToMonitor(key.Value);
    }
}</pre>
<p><a href="http://11011.net/software/vspaste"></a></p>
</li>
<li>Get the active view using the <strong>ActiveView </strong>property of the service. </li>
</ol>
<table border="1">
<tbody>
<tr>
<td><strong>Note</strong>: The ActiveViewMonitorService service accepts Workspaces that inherit from the Control class.</td>
</tr>
</tbody>
</table>
<p>Enjoy</p>
<div class="wlWriterSmartContent" id="afeaa902-2dfd-41e2-ac11-42cd71657298" style="padding-right: 0px;padding-left: 0px;padding-bottom: 0px;margin: 0px;padding-top: 0px">Technorati Tags: <a href="http://technorati.com/tags/CAB" rel="tag">CAB</a>,<a href="http://technorati.com/tags/SCSF" rel="tag">SCSF</a></div>
]]></content:encoded>
			<wfw:commentRss></wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Memory Leak Fix for DeckWorkspace in CAB Extensions for WPF</title>
		<link>http://blogs.southworks.net/mconverti/2008/07/31/memory-leak-fix-for-deckworkspace-in-cab-extensions-for-wpf/</link>
		<comments>http://blogs.southworks.net/mconverti/2008/07/31/memory-leak-fix-for-deckworkspace-in-cab-extensions-for-wpf/#comments</comments>
		<pubDate>Thu, 31 Jul 2008 17:30:10 +0000</pubDate>
		<dc:creator>mconverti</dc:creator>
				<category><![CDATA[CAB]]></category>
		<category><![CDATA[SCSF]]></category>

		<guid isPermaLink="false">http://blogs.southworks.net/mconverti/?p=64</guid>
		<description><![CDATA[... <a href="http://blogs.southworks.net/mconverti/2008/07/31/memory-leak-fix-for-deckworkspace-in-cab-extensions-for-wpf/" class="more-link">read more<img src="http://blogs.southworks.net/mconverti/wp-content/themes/southworks/assets/img/arrow-blue.png" width="12" height="12" alt="" /></a>]]></description>
			<content:encoded><![CDATA[<p>The P&amp;P Sustained Engineering Team has found a fix for the <strong>DeckWorkspace memory leak issue</strong> of the Composite UI Application Block Extensions for WPF.</p>
<h3>Content</h3>
<ul>
<li><a href="#_Symptom">Symptom</a> </li>
<li><a href="#_Cause">Cause of issue</a> </li>
<li><a href="#_Fix">Fix</a> </li>
<li><a href="#_Download">Download</a> </li>
</ul>
<h3><a name="_Symptom"></a>Symptom</h3>
<p>When you use a <strong>DeckWorkspace</strong> workspace to show a <strong>WPF View</strong>, the view will remain in memory even if you call its <strong>Dispose</strong> method from the presenter. This causes an increase in the memory usage.</p>
<h3><a name="_Cause"></a>Cause of issue</h3>
<p><strong><span style="text-decoration: underline">Summary</span></strong>: Some objects (like instances of <strong>LayoutEventArgs</strong> class) still reference to the View after it is disposed not allowing it to be swept from memory.</p>
<p><strong></strong></p>
<p><strong><span style="text-decoration: underline">Full description</span></strong>: Using the <a href="http://www.red-gate.com/products/ants_profiler">ANTS profiler</a> tool, we found out that there are some references to the <strong>WPF View</strong> that do not allow the View to be released from memory after it is shown in a <strong>DeckWorkspace</strong> workspace. The following figure shows the <strong>View2</strong> still in memory even after it had been closed in our application. Should have been swept but the references shown in the bottom left do not allow that.</p>
<p><a href="http://blogs.southworks.net/mconverti/files/2008/08/ants-thumb3.png" target="_blank"><img height="297" alt="ANTS profiler" src="http://blogs.southworks.net/mconverti/files/2008/08/ants3.png" width="550" border="0" /></a></p>
</p>
<p>If you look at the <b>Control</b> class (<b>DeckWorkspace</b> inherits this class) using Reflector, you can see that there is a <b>cachedLayoutEventArgs</b> field that sometimes holds a reference to <b>LayoutEventArgs</b>, which ultimately holds a reference the view in this scenario. Once you call <b>PerformLayout</b> on the control, this reference gets released.</p>
<h3><a name="_Fix"></a>Fix</h3>
<p><strong><span style="text-decoration: underline">Summary</span></strong>: Call the <strong>PerformLayout</strong> method when a View is being closed in the <strong>DeckWorkspace</strong>, which releases all remaining references to the View.<a></a></p>
<p><strong><span style="text-decoration: underline">Step by step</span></strong>: You will need to have installed the <em>SCSF source code</em> and perform the following steps to fix the issue:</p>
<ol>
<li>Open the <strong>CompositeUI-WPFExtensions.sln</strong> solution. </li>
<li>Right-click in the <strong>DeckWorkspace.cs</strong> file located in the <strong>Workspaces</strong> folder on the <strong>CompositeUI.WPF</strong> project and then select <strong>View Code</strong>. </li>
<li>Locate the <strong>Close</strong> method of the <strong>DeckWorkspace</strong> class and add the following bold line:
<pre><span style="color: #0000ff">public void </span>Close(<span style="color: #0000ff">object </span>smartPart)
{
    composer.Close(smartPart);

    <span style="color: #008000">// Add this line.
    </span><strong><span style="color: #0000ff">this</span>.PerformLayout();</strong>
}</pre>
<p><a href="http://11011.net/software/vspaste"></a><a href="http://11011.net/software/vspaste"></a></p>
</li>
<li>Locate the <strong>OnClose</strong> method of the <strong>DeckWorkspace</strong> class and add the following bold line:
<pre><span style="color: #0000ff">protected virtual void </span>OnClose(<span style="color: #2b91af">Control </span>smartPart)
{
    <span style="color: #0000ff">this</span>.Controls.Remove(smartPart);

    smartPart.Disposed -= ControlDisposed;

    ActivateTopmost();

    <span style="color: #008000">// Add this line
    </span><strong><span style="color: #0000ff">this</span>.PerformLayout();</strong>
}</pre>
<p><a href="http://11011.net/software/vspaste"></a></p>
</li>
</ol>
<h3><a name="_Download"></a>Download</h3>
<ul>
<li><a href="http://blogs.southworks.net/mconverti/files/2008/08/compositeuiwpfassemblies_fixed.zip" target="_blank">CompositeUIWPFAssemblies_fixed.zip</a>: Fixed binaries of the Composite UI Application Block Extensions for WPF (not signed). </li>
<li><a href="http://blogs.southworks.net/mconverti/files/2008/08/compositeuiwpfsources_fixed.zip" target="_blank">CompositeUIWPFSources_fixed.zip</a>: Fixed source code of the Composite UI Application Block Extensions for WPF. </li>
</ul>
<p>Enjoy.</p>
<div class="wlWriterSmartContent" id="01ec5d79-0bef-4ea7-9ec7-08097c34579f" style="padding-right: 0px;padding-left: 0px;padding-bottom: 0px;margin: 0px;padding-top: 0px">Technorati Tags: <a href="http://technorati.com/tags/SCSF" rel="tag">SCSF</a>,<a href="http://technorati.com/tags/CAB" rel="tag">CAB</a></div>
]]></content:encoded>
			<wfw:commentRss></wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>SCSF &#8211; April 2008 with VS2008 + SP1 Known Issues</title>
		<link>http://blogs.southworks.net/mconverti/2008/07/02/scsf-april-2008-with-vs2008-sp1-known-issues/</link>
		<comments>http://blogs.southworks.net/mconverti/2008/07/02/scsf-april-2008-with-vs2008-sp1-known-issues/#comments</comments>
		<pubDate>Thu, 03 Jul 2008 01:29:23 +0000</pubDate>
		<dc:creator>mconverti</dc:creator>
				<category><![CDATA[SCSF]]></category>
		<category><![CDATA[Add new tag]]></category>

		<guid isPermaLink="false">http://blogs.southworks.net/mconverti/?p=54</guid>
		<description><![CDATA[... <a href="http://blogs.southworks.net/mconverti/2008/07/02/scsf-april-2008-with-vs2008-sp1-known-issues/" class="more-link">read more<img src="http://blogs.southworks.net/mconverti/wp-content/themes/southworks/assets/img/arrow-blue.png" width="12" height="12" alt="" /></a>]]></description>
			<content:encoded><![CDATA[<p>If you try to run <a href="http://www.microsoft.com/downloads/details.aspx?FamilyId=3BE112CC-B2C1-4215-9330-9C8CF9BCC6FA&amp;displaylang=en">SCSF &#8211; April 2008</a> in Visual Studio 20008 with <a href="http://www.microsoft.com/downloads/details.aspx?FamilyId=CF99C752-1391-4BC3-BABC-86BC0B9E8E5A&amp;displaylang=en">Service Pack 1 Beta</a>, you will face the following issues:</p>
<ul>
<li><strong>Running</strong> new SC-SF solutions will <strong>throw a ModuleLoadException exception </strong>when trying to load one of your modules.</li>
<li>The <strong>Add View (with Presenter) </strong>and <strong>Add WPF-View (with Presenter)</strong> recipes are <strong>not displayed</strong> in a new Visual Basic solution.</li>
</ul>
<p>We&#8217;ve created an <a href="http://www.codeplex.com/smartclient/Wiki/View.aspx?title=Known%20Issues%3a%20SC-SF%20April%202008%20with%20Visual%20Studio%202008%20and%20SP1%20Beta">entry</a> in the <a href="http://www.codeplex.com/smartclient/Wiki/View.aspx?title=Known%20Issues%20%2f%20Fixes">Known Issues / Fixes</a> section of the <a href="http://www.codeplex.com/smartclient/Wiki/View.aspx?title=SCSF%20Knowledge%20Base">SC-SF Knowledge Base</a> where you can find the cause of these issues and the fixes we found. Any feedback is welcome.</p>
<p>Check the <a href="http://www.codeplex.com/smartclient/Wiki/View.aspx?title=Known%20Issues%3a%20SC-SF%20April%202008%20with%20Visual%20Studio%202008%20and%20SP1%20Beta">SCSF &#8211; April 2008 with VS2008 + SP1 Beta Known Issues</a> article.</p>
<p>Enjoy!</p>
]]></content:encoded>
			<wfw:commentRss></wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Smart Client Software Factory &#8211; April 2008 Release ya esta disponible</title>
		<link>http://blogs.southworks.net/mconverti/2008/04/27/smart-client-software-factory-april-2008-release-ya-esta-disponible-en-msdn/</link>
		<comments>http://blogs.southworks.net/mconverti/2008/04/27/smart-client-software-factory-april-2008-release-ya-esta-disponible-en-msdn/#comments</comments>
		<pubDate>Sun, 27 Apr 2008 01:00:00 +0000</pubDate>
		<dc:creator>mconverti</dc:creator>
				<category><![CDATA[SCSF]]></category>

		<guid isPermaLink="false">/blogs/mconverti/archive/2008/04/26/Smart-Client-Software-Factory-_2D00_-April-2008-Release-ya-esta-disponible-en-MSDN.aspx</guid>
		<description><![CDATA[... <a href="http://blogs.southworks.net/mconverti/2008/04/27/smart-client-software-factory-april-2008-release-ya-esta-disponible-en-msdn/" class="more-link">read more<img src="http://blogs.southworks.net/mconverti/wp-content/themes/southworks/assets/img/arrow-blue.png" width="12" height="12" alt="" /></a>]]></description>
			<content:encoded><![CDATA[<p>Finalmente despu&#233;s de publicar la versi&#243;n <strong>Alpha</strong>, la versi&#243;n <strong>Beta</strong> y la <strong>Release Candidate 1</strong> en <a href="http://www.codeplex.com/smartclient">Codeplex</a>, ayer se public&#243; la versi&#243;n release en MSDN.</p>
<p><a href="http://www.microsoft.com/downloads/details.aspx?FamilyId=3BE112CC-B2C1-4215-9330-9C8CF9BCC6FA&amp;displaylang=en"><img height="342" alt="Installer" src="http://blogs.southworks.net/mconverti/files/2008/06/installer.png" width="416" border="0" /></a> </p>
<h3>Lo nuevo en esta versi&#243;n</h3>
<ul>
<li>Incluye soporte para <a href="http://msdn2.microsoft.com/vs2008/default.aspx">Visual Studio 2008</a> y <a href="http://www.microsoft.com/downloads/details.aspx?FamilyID=333325FD-AE52-4E35-B531-508D977D32A6">.NET Framework 3.5</a> (no soporta Visual Studio 2005) </li>
<li>La Guidance Package puede correr side-by-side con la Guidance Package de <a href="http://www.microsoft.com/downloads/details.aspx?FamilyId=2B6A10F9-8410-4F13-AD53-05A202FBDB63&amp;displaylang=en">SCSF &#8211; May 2007</a> </li>
<li>Requiere <a href="http://msdn2.microsoft.com/en-us/teamsystem/aa718949.aspx">Guidance Automation Extensions &#8211; February 2008 release</a> </li>
<li>Soporte para <a href="http://msdn2.microsoft.com/en-us/library/aa480453.aspx">Enterprise Library 3.1 &#8211; May 2007</a> </li>
<li>Se fixearon algunos de los bugs reportados por la comunidad </li>
</ul>
<h3>Known Issues</h3>
<p>Publicamos un art&#237;culo en la <a href="http://www.codeplex.com/smartclient/Wiki/View.aspx?title=SCSF%20Knowledge%20Base">Knowledge Base de SCSF</a> con los Known Issues del presente release:</p>
<ul>
<li><a href="http://www.codeplex.com/smartclient/Wiki/View.aspx?title=Known%20Issues%20with%20the%20Smart%20Client%20Software%20Factory%20April%202008">Known Issues with the Smart Client Software Factory April 2008</a> </li>
</ul>
<h3>Habilitar soluciones creadas con SCSF &#8211; May 2007</h3>
<p>Para habilitar las soluciones creadas con Smart Client Software Factory &#8211; May 2007 en esta nueva versi&#243;n, seguir los pasos explicados en el siguiente art&#237;culo:</p>
<ul>
<li><a href="http://www.codeplex.com/smartclient/Wiki/View.aspx?title=How%20to%20enable%20a%20May%202007%20solution">How To Enable a May 2007 Solution</a> </li>
</ul>
<h3>Documentacion disponible On Line</h3>
<p>Toda lo documentaci&#243;n de Smart Client Software Factory &#8211; April 2008 fue publicada en <a href="http://msdn2.microsoft.com">MSDN</a>. Esto ayuda a lo usuarios a encontrar lo que necesitan m&#225;s r&#225;pidamente y tambi&#233;n a evaluar el contenido de la Factory antes de descargarla y/o instalarla.</p>
<p>Usted puede accederla desde <a href="http://msdn2.microsoft.com/en-us/library/cc540671.aspx">aqu&#237;</a>.</p>
<p><a href="http://msdn2.microsoft.com/en-us/library/cc540671.aspx"><img height="237" alt="MSDNDocumentation" src="http://blogs.southworks.net/mconverti/files/2008/06/msdndocumentation.png" width="373" border="0" /></a> </p>
<h3>Download disponibles</h3>
<ul>
<li><a href="http://www.microsoft.com/downloads/details.aspx?FamilyId=3BE112CC-B2C1-4215-9330-9C8CF9BCC6FA&amp;displaylang=en">Smart Client Software Factory &#8211; April 2008</a>:Instalador de la Factory </li>
<li><a href="http://www.microsoft.com/downloads/details.aspx?FamilyId=5C42C35D-DA1C-40B9-892E-11AB13AAFD9E&amp;displaylang=en">Smart Client Software Factory Source Code &#8211; April 2008</a>: Instalador del c&#243;digo fuente de la Factory </li>
<li><a href="http://www.codeplex.com/smartclient/Release/ProjectReleases.aspx?ReleaseId=5027">Smart Client Software Factory Documentation &#8211; April 2008</a>: Documentaci&#243;n en formato CHM </li>
</ul>
]]></content:encoded>
			<wfw:commentRss></wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
