如何将CAB应用迁移到SCSF上

几个软件工厂中Smart Client Software Factory开发较早,但先期产品规划做的不是特别完善,所以出现了一些相关问题,这几天不停有人问我,所以准备抽时间写下来给需要的人。因为历史原因,比较普遍的迁移问题主要有如下四个:
一.对SCSF 2007应用添加WPF支持,做一些WPF界面与Smart Client界面的交互
    之前我负责的一家国际软件企业要用到,所以联系p&p找人做了一些指导文档和快速入门,最终加进了Release的产品文档中,参见这篇文档
二.改装成一个纯WPF展现的SCSF
    这个比较好解决,使用WPFCAB即可,参见contrib
三.从2006的SCSF Release(内部版本号v1)迁移到2007年的SCSF Release(内部版本号v2)
    参见这篇文档
四.如何从早期的CAB应用直接迁移到SCSF上
    这个比较麻烦,重点说一下。
    将一个CAB应用迁移到SCSF上需要以以下步骤进行:
1.要做的准备
2.第一步:创建新的Smart Client解决方案
3.第二步:添加旧的CAB应用程序
4.第三步:删除Smart Client template Shell工程
5.第四步:升级旧的Shell
6.第五步:修改解决方案文件
7.第六步:编译运行

由于工作原因,写成了简单的英语,供参考:
 

Prerequisites

In order to complete the upgrade, you must have the following installed on your computer:

·         .NET Framework 3.0 (not necessary if you use Windows Vista).

·         Visual Studio .NET 2005 (Team Edition for Software Testers recommended).

·         Visual Studio 2005 extensions for .NET Framework 3.0 (WCF & WPF) (required to create a disconnected service agent for a WCF proxy and to use CAB-WPF Extensions which enable you to define WPF controls as SmartParts).

·         Guidance Automation Extensions February 2007 CTP.

·         Guidance Automation Toolkit.

·         Smart Client Software Factory - May 2007.

 

Task 1: Creating a new Smart Client solution

To upgrade your solution, you will create a new smart client solution using the Smart Client Solution template and then you will add your solution’s modules and Shell project to the new solution.

1.       In Visual Studio, point to New on the File menu, and then click Project.

Figure 1

The Smart Client Application solution templates.

2.       In the New Project dialog box, expand the Guidance Packages node. Click the Smart Client Development May 2007 project type.

3.       In the Templates window, select Smart Client Application (C#) or Smart Client Application (Visual Basic) (depending on the language you’ve coded the CAB application).

4.       Change the Name.

5.       (Optional) Change the location for the solution.

6.        Click OK.

Figure 2

The Create Solution recipe wizard.

7.       Enter the location of the Composite UI Application Block, Enterprise Library, and the offline application blocks assemblies.

8.       Enter the Root namespace for your application.

9.       Unselect the option Create a separate module to define the layout for the shell.

10.   (Optional) Select the Allow solution to host WPF SmartParts check box (if your solution contains or will contain WPF SmartParts).

11.   (Optional) Select the Show documentation after recipe completes check box.

12.   Click Finish.

Figure 3

The smart client solution structure.

 

Task 2: Adding the old CAB application

In this task you will add your CAB application to the new Smart Client solution and configure it according to the SCSF structure.

1.       Copy your old CAB application to the Source folder located inside the new Smart Client solution root folder.

2.       In Solution Explorer, right-click the Source solution folder, point to Add, and then click Existing Project.

3.       Browse the directory of the old CAB application and add one of the module projects (i.e.: your CAB Shell module project).

Figure 4

CAB Shell module project added.

4.       Repeat steps 2 and 3 until all of the modules have been added.

5.       Right-click your CAB Shell and select Set as StartUp Project.

6.       For each module, right-click the project and select Add Reference. In the Projects tab, select the Infrastructure.Interface and Infrastructure.Library projects and click OK.

7.       For each module, replace the Microsoft.Practices.* assemblies with the ones located in %RootSolutionFolder%\Lib. If you have references to the CompositeUI and CompositeUI.WinForms projects, replace those references to the assemblies located in % RootSolutionFolder %\Lib

Note: % RootSolutionFolder %\Lib is the directory of the root folder where you placed the new Smart Client solution.

8.       For each module, right-click the project and select Properties. In the Build tab, go to the Output section and edit the Output path to RootSolutionFolder%\bin\Debug.

Figure 5

Output path in the Output section located at Build tab in the Module properties. Note: you might not see a relative path until you close the properties window and open it again.

 

Task 3: Removing the Smart Client template Shell project

In this task you will remove the Smart Client Shell template project.

1.       In Solution Explorer, right-click the Infrastructure.Shell project and then click Remove.

Figure 6

Removing the SCSF Shell project.

2.       Delete the Source\Infrastructure\Shell folder located in within the root folder of the solution.

Figure 7

Deleting the SCSF Shell folder.

 

Task 4: Upgrading the old Shell

In this task you will upgrade the Shell of your CAB application in order to replace the Smart Client Shell project.

1.       In Solution Explorer, expand your Shell project, open the ProfileCatalog.xml file and update it to match the schema used in SCSF solutions. For example, if your profile catalog looks like this:

XML

<?xml version="1.0" encoding="utf-8" ?>

<SolutionProfile xmlns="http://schemas.microsoft.com/pag/cab-profile" >

       <Modules>

              <!-- some modules -->

       </Modules>

</SolutionProfile>

You have to update it to look like this:

XML

<SolutionProfile xmlns="http://schemas.microsoft.com/pag/cab-profile/2.0">

  <Section Name="Services">

    <Modules>

      <ModuleInfo AssemblyFile="Infrastructure.Module.dll" /> <!-- THIS IS REQUIRED FOR SC-SF SOLUTIONS -->

       <!-- PLACE INFRASTRUCTURE (FOUNDATIONAL) MODULES HERE -->

    </Modules>

  </Section>

  <Section Name="Apps">

    <Dependencies>

      <Dependency Name="Services" />

    </Dependencies>

    <Modules>

              <!-- PLACE BUSINESS MODULES HERE -->

    </Modules>

  </Section>

</SolutionProfile>

2.       Click Save and close the file.

3.       Now, right-click your ShellApplication.cs file and select View Code.

4.       Add the following statement:

Visual Basic

Imports %RootNamespace%.Infrastructure.Library;

C#

using %RootNamespace%.Infrastructure.Library;

Note:  %RootNamespace% must be replaced with the RootNamespace you specified when you created the Smart Client solution.

5.       Update the class signature to inherit from FormShellApplication<TWorkItem, TShell> instead of SmartClientApplication<TWorkItem, TShell>.

6.       Click Save.

 

Task 5: Modifying the solution file

In this task you will modify the yourSolution.sln file in order to finish setting the Shell of the CAB application as the Smart Client Shell.

1.       In the root folder of your solution, right-click the .sln file, select Open with and then select the NotePad.

2.       Locate the Project section for the Shell project.

Figure 8

ShellpProject section.

3.       Copy to the clipboard the GUID that appears after the project location (its format is “XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX”).

Figure 9

The GUID that appears after the project location.

4.       Locate the line GlobalSection(ExtensibilityGlobals) = postSolution.

5.       Replace the GUID specified in the ShellProjectGuid property with your Shell project’s GUID.

Figure 10

ShellProjectGuid.

6.       Save and close the file.

 

Task 6: Compile and Run…

In this task you will finish building and running your upgraded solution.

1.       Go back to Visual Studio. A message saying that the solution has been modified outside of the development environment will appear. Click Reload to reload the solution.

2.       Build and run the application.

至此,迁移成功!
大家如果在按这个步骤走的时候有什么问题可以留言在下面。
最后感谢Ignacio对本文的帮助!

posted on 2007-12-19 19:31  Ray Zhang  阅读(2882)  评论(9编辑  收藏  举报

导航