How To: Use SC-SF with Enterprise Library 4

Prerequisites

The procedures described in this document assume that you have installed the Smart Client Software Factory April 2008 and Enterprise Library 4.

Summary of Steps

  1. Rebuilding the Block Assemblies
  2. Updating the Guidance Package
  3. Updating Existing Smart Client Solutions
  4. Updating the QuickStarts and Reference Implementation (optional)
Note: If you want to use Enterprise Library 4.0 on new projects, you only need to perform steps 1 and 2.

Rebuilding the Block Assemblies

The first step consists of rebuilding the Smart Client Software Factory blocks to use Enterprise Library 4.0. These steps are needed only if you are updating an existing Smart Client Software Factory solution that uses the Offline capabilities or if you are going to customize the Guidance Package to make it generate new solutions that use Enterprise Library 4.0.
  • 1. Extract the Smart Client Software Factory Source Code.
  • 2. Open the SmartClient.Offline solution located at the source code installation folder.
  • 3. Remove from the SmartClient.EnterpriseLibrary and SmartClient.EnterpriseLibrary.Tests projects the references to the following assemblies:
    • Microsoft.Practices.EnterpriseLibrary.Common
    • Microsoft.Practices.EnterpriseLibrary.Data
    • SmartClient.EnterpriseLibrary.Data.SqlCe
  • 4. Add, In the SmartClient.EnterpriseLibrary and SmartClient.EnterpriseLibrary.Tests projects, references to the following Enterprise Library assemblies (located at Enterprise Library assemblies located at %Enterprise Library 4 installation folder%\Bin):
    • Microsoft.Practices.EnterpriseLibrary.Common.dll
    • Microsoft.Practices.EnterpriseLibrary.Data.dll
    • Microsoft.Practices.EnterpriseLibrary.Data.SqlCe.dll
  • 5. In the SmartClient.EnterpriseLibrary project, open SmartClientDatabase.cs file and replace the following using statement:
using Microsoft.Practices.SmartClient.EnterpriseLibrary.Data.SqlCe; 
  • With this:
using Microsoft.Practices.EnterpriseLibrary.Data.SqlCe; 
  • 6. Build the solution.
Note: Since Enterprise Library 4 already includes a provider for Sql CE 3.5, SmartClient.EnterpriseLibrary project no longer needs to use the custom provider included in the SmartClient.EnterpriseLibrary.Data.SqlCe assembly. In the previous steps, the SmartClient.EnterpriseLibrary project was modified to work with the new provider supplied by Enterprise Library 4.

Updating the Guidance Package

The following steps describe how to customize the Guidance Package to make it generate solutions that use Enterprise Library 4.0.
Note: If you are running on Vista with the User Account Control (UAC) activated, you must open Visual Studio with the option Run as administrator.
  • 3. Open the App.config.template located under the folders located at Templates\Solutions\Projects\Shell.*.* (Shell.Basic.CS, Shell.Basic.VB, Shell.Extended.CS and Shell.Extended.VB) in the SmartClientFactoryPackage project.
  • 4. Find and replace on each App.config.template file the string “Version=3.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a” with “Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35”.
  • 5. Create a folder to store the new assemblies (e.g. at %SC-SF installation folder%\Lib with EntLib 4.0). In this folder, copy the Enterprise Library 4.0 assemblies and the Smart Client assemblies generated in Step 1. You should have the same assemblies you have at %SC-SF installation folder%\Lib but updated to use Enterprise Library 4.0.
  • 6. Open the file CreateSmartClientFactorySolutionCommon.xml file located at Recipes\Common folder of the SmartClientFactoryPackage project. You will change the path where the Create Solution recipe looks for the required assemblies by default.
  • 7. Find the SupportLibrariesPath argument and replace it with the following:
<Argument Name="SupportLibrariesPath" Required="true" Type="System.String">
  <ValueProvider Type="Evaluator"
          Expression="Paste here the path to the folder created at Step 5">
  </ValueProvider>
</Argument> 
  • 8. Save all.
  • 9. Register the custom Guidance Package. To do this, right click the SmartClientFactoryPackage project and select Register Guidance Package.
Note: If the Register Guidance Package doesn’t appear, you have to enable Guidance Package Development. To do this, go to the Tools menu, select Guidance Package Manager, click Enable / Disable packages, select Guidance Package Development, click OK, and Close.

Updating an Existing Smart Client Solution

The following steps describe how to make an existing Smart Client Software Factory solution consume Enterprise Library 4.0.
  • 1. If your solution uses the Microsoft.Practices.SmartClient.EnterpriseLibrary.dll assembly, follow the steps described in the Rebuilding the Block Assemblies section to update this assembly and perform the following sub-steps:
    1. Find the Microsoft.Practices.SmartClient.EnterpriseLibrary.dll generated assembly located at %Source code installation folder%\Blocks\Offline\Source\DataAccess.EnterpriseLibrary\bin\Debug.
    2. Copy the previous assembly and replace them in the Lib folder of your solution.
    3. Update the references of your projects to use the updated Microsoft.Practices.SmartClient.EnterpriseLibrary.dll assembly
    4. Remove the reference to Microsoft.Practices.SmartClient.EnterpriseLibrary.Data.SqlCe.dll (it was replaced with the one provided by Enterprise Library 4) and add a reference to Microsoft.Practices.EnterpriseLibrary.Data.SqlCe.dll assembly located at %Enterprise Library 4 installation folder%\Bin.
  • 2. Copy the Enterprise Library 4.0 assemblies (located at %Enterprise Library 4 installation folder%\Bin) and replace them in the Lib folder of your solution.
  • 3. Update the references to the Enterprise Library assemblies in all the projects in your solution using the new assemblies copied into the Lib folder.
  • 4. Open the App.config file and find and replace the string “Version=3.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a” with “Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35”.
  • 5. Save all.
Note: It is possible that you’ll get exceptions related to changes in the new version of the Enterprise Library. Use the Enterprise Library Changes Log to review the changes and update your code.

Updating the QuickStarts and Reference Implementation

If you want to update the QuickStarts and the Reference Implementation to use Enteprise Library 4.0, you can follow the steps described in the section Updating an Existing Smart Client Solution.

Last edited Nov 13, 2008 at 10:16 AM by mconverti, version 6

Comments

jitudavda Dec 6, 2008 at 8:26 AM 
To update guidance package fixing the above issue of "Assembly file was not found" while runing newly created solution, do the following steps.

1. Go to SmartClientFactoryPackage/Templates/Solutions/Projects/
2. Open file "ProfileCatalog.xml" from each folder with name "Shell.Basic.CS", "Shell."Basic.VB", "Shell.Extended.CS", "Shell.Extended.VB"
3. Add "$RootNamespace$." at the start of all the AssemblyFile name value. It shall look like following.
<ModuleInfo AssemblyFile="$RootNamespace$.Infrastructure.Module.dll" />

You are done, just re-register the guidance package.

jitudavda Dec 6, 2008 at 7:49 AM 
NightCrawler,

before running the project after created using the SCSF April 2008 solution template, we need to change following. (The solution name is not preceeded to the dll file names in ProfileCatalog.xml by the Guidance package)

Fix (every project): go to the file "ProfileCatalog.xml" in the Shell project and change the ModuleInfo Assembly Filenames to to
<YourSolutionsName>.Infrastructure.Module.dll
&
<YourSolutionsName>.Infrastructure.Layout.dll

After this, the error "Assembly file **** was not found" will not come.

bhehe1 Nov 25, 2008 at 2:10 PM 
As the person making the modifications to the SCSF Blocks/Guidance... testing by right-clicking & "register guidance" is fine. But how do I repackage this in a manner where I can hand it out to the development team and tell them to basically "run this EXE" - I really don't want them to have to have GAT installed just to register the package....

NightCrawler Nov 10, 2008 at 4:25 PM 
I follow the walkthrought and am getting an error when I try to run the app:

Assembly file C:\Projects\SmartClientDevelopmentSolution8\bin\Debug\Infrastructure.Module.dll was not found.

ibaumann Sep 10, 2008 at 12:28 PM 
Hi,

@latala43
We have updated the document to show the Expression attribute for the ValueProvider, and added a note saying that if you run Vista with UAC, you must run Visual Studio as administrator. If this doesn't solve your issue, please provide more information on it.

@mj1856
Thanks, the Expression attribute for the ValueProvider has been updated.

SCSF 2008 works with ObjectBuilder, so there's no need to replace the references for ObjectBuilder2.

Ignacio Baumann Fonay
http://blogs.southworks.net/ibaumann/

mj1856 Jul 19, 2008 at 11:03 PM 
Should I be considering removing references to ObjectBuilder and replacing them with ObjectBuilder2? What are the implications?

mj1856 Jul 19, 2008 at 10:26 PM 
In step 7 of the Guidance Package - the XML is missing the value for the Expression attribute. Please update! Thanks!

latala43 May 23, 2008 at 8:21 AM 
Steps 6 and 7 in the Updating the Guidance Package needs more explanation. I always fail to Register Guidance Package!!