如何將CAB應用遷移到SCSF上

Found CSS is not very good here

幾個軟件工廠中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 Toolkit.

 

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" ?>
       <Modules>
              <!-- some modules -->
       </Modules>
</SolutionProfile>
You have to update it to look like this:
XML
  <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對本文的幫助!
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章