<?xml version="1.0" encoding="utf-8"?>
<rss xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:pingback="http://madskills.com/public/xml/rss/module/pingback/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:dc="http://purl.org/dc/elements/1.1/" version="2.0">
  <channel>
    <title>Christian Bækdorf's .NET Blog</title>
    <link>http://www.baekdorf.dk/christian/</link>
    <description>.NET Stuff etc.</description>
    <language>en-us</language>
    <copyright>Christian Bækdorf</copyright>
    <lastBuildDate>Tue, 02 Dec 2008 21:00:17 GMT</lastBuildDate>
    <generator>newtelligence dasBlog 2.1.8102.813</generator>
    <managingEditor>christian@baekdorf.dk</managingEditor>
    <webMaster>christian@baekdorf.dk</webMaster>
    <item>
      <trackback:ping>http://www.baekdorf.dk/christian/Trackback.aspx?guid=35910122-71c6-474c-9200-05619fa7430b</trackback:ping>
      <pingback:server>http://www.baekdorf.dk/christian/pingback.aspx</pingback:server>
      <pingback:target>http://www.baekdorf.dk/christian/PermaLink,guid,35910122-71c6-474c-9200-05619fa7430b.aspx</pingback:target>
      <dc:creator>Christian B�kdorf (admin)</dc:creator>
      <wfw:comment>http://www.baekdorf.dk/christian/CommentView,guid,35910122-71c6-474c-9200-05619fa7430b.aspx</wfw:comment>
      <wfw:commentRss>http://www.baekdorf.dk/christian/SyndicationService.asmx/GetEntryCommentsRss?guid=35910122-71c6-474c-9200-05619fa7430b</wfw:commentRss>
      <slash:comments>77</slash:comments>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
This post is part of a <a href="http://www.baekdorf.dk/christian/2008/09/24/DSLToolsAndVisualStudio2008IsolatedShellTutorial.aspx">larger
tutorial on DSL Tools and Visual Studio 2008 Isolated Shell</a>, in this post I will
go through the steps to setup project for the Shell application and DSL.
</p>
        <p>
Previous step: <a href="http://www.baekdorf.dk/christian/2008/10/08/DSLAndVisualStudioShellTutorialCreatingACustomProjectType.aspx">Creating
a custom project type</a></p>
        <p>
          <strong>Creating a new setup project</strong>
        </p>
        <p>
We will start by adding a new setup project to our solution, so start by opening the
solution from the previous post, if not already open.
</p>
        <p>
          <u>1. New Project</u>
        </p>
        <p>
Create a new Setup Project named “MyDslApplication”, by right-clicking the solution
in the Solution Explorer and choosing Add New Project.
</p>
        <p>
In the Add New Project choose Setup Project as shown below:
</p>
        <p>
          <img src="http://www.baekdorf.dk/christian/content/binary/75_DSLVSShell_Setup_NewProject.png" border="0" />
        </p>
        <p>
The solution should now look as shown below:
</p>
        <p>
          <img src="http://www.baekdorf.dk/christian/content/binary/76_DSLVSShell_Setup_Solution1.png" border="0" />
        </p>
        <p>
          <u>2. Set project properties</u>
        </p>
        <p>
In the setup projects properties set Author and Manufacturer to “MyCompany” as shown
below.
</p>
        <p>
          <img src="http://www.baekdorf.dk/christian/content/binary/77_DSLVSShell_Setup_Properties.png" border="0" />
        </p>
        <p>
          <strong>Adding output files</strong>
        </p>
        <p>
Now we are going to add assemblies and other files to the setup project, so you should
now open the “File System” in the setup project. Right-click the setup project, MyDslApplication,
in the Solution Explorer and choose View -&gt; File System on the context menu.
</p>
        <p>
          <u>1. Shell output</u>
        </p>
        <p>
Add the Primary Output from the “MyDslShell” project (this will be the actual executable
MyDslShell.exe) to the Application Folder.
</p>
        <p>
Right-click the Application Folder, in the File System view, and choose and Add -&gt;
Project Output… from the context menu. Then select the “MyDslShell” project, Primary
Output and Active configuration as shown below.
</p>
        <p>
          <img src="http://www.baekdorf.dk/christian/content/binary/78_DSLVSShell_Setup_AddShellPrimary.png" border="0" />
        </p>
        <p>
The solution should now look as shown below.
</p>
        <p>
          <img src="http://www.baekdorf.dk/christian/content/binary/79_DSLVSShell_Setup_WithShellPrimary.png" border="0" />
        </p>
        <p>
          <u>2. Add Shell config, icon and splash screen image</u>
        </p>
        <p>
Add the following files from the folder “D:\project\DslToolsAndVsShell\Code\MyDSLApplication\MyDslShell\MyDslShell”
to the Application Folder:
</p>
        <p>
        </p>
        <ul>
          <li>
MyDslShell.exe.config 
</li>
          <li>
MyDslShell.ico 
</li>
          <li>
Splash.bmp 
</li>
          <li>
MyDslShell.prf</li>
        </ul>
        <p>
Right-click the Application Folder, in the File System view, and choose and Add -&gt;
File… from the context menu. Then select the files as shown below.
</p>
        <p>
          <img src="http://www.baekdorf.dk/christian/content/binary/80_DSLVSShell_Setup_AddShellConfigEtc.png" border="0" />
        </p>
        <p>
After this your solution should look as shown below.
</p>
        <p>
          <img src="http://www.baekdorf.dk/christian/content/binary/81_DSLVSShell_Setup_Solution2.png" border="0" />
        </p>
        <p>
          <u>3. Add PackagesToLoad and template folders</u>
        </p>
        <p>
Add the following folders under the Application Folder:
</p>
        <p>
        </p>
        <ul>
          <li>
ItemTemplates 
</li>
          <li>
ItemTemplatesCache 
</li>
          <li>
ProjectTemplates 
</li>
          <li>
ProjectTemplatesCache 
</li>
          <li>
Profiles 
</li>
          <li>
PackagesToLoad</li>
        </ul>
        <p>
And a folder named “1033” under the new “PackagesToLoad” folder.
</p>
        <p>
Right-click the Application Folder or a subfolder, in the File System view, and choose
and Add -&gt; Folder from the context menu to add a folder.
</p>
        <p>
          <img src="http://www.baekdorf.dk/christian/content/binary/82_DSLVSShell_Setup_NewFolders.png" border="0" />
        </p>
        <p>
Mark the “ItemTemplates”, “ItemTemplatesCache”, “ProjectTemplates” and “ProjectTemplatesCache”
folders with the AlwaysCreate option as shown below
</p>
        <p>
          <img src="http://www.baekdorf.dk/christian/content/binary/82a_DSLVSShell_Setup_NewFoldersAlwaysCreate.png" border="0" />
        </p>
        <p>
          <u>4. Add Shell UI output</u>
        </p>
        <p>
Add the Primary Output from MyDslShellUI to the “1033” folder.
</p>
        <p>
          <img src="http://www.baekdorf.dk/christian/content/binary/83_DSLVSShell_Setup_AddShellUIPrimary.png" border="0" />
        </p>
        <p>
After adding the Shell UI output the solution should look as shown below.
</p>
        <p>
          <img src="http://www.baekdorf.dk/christian/content/binary/84_DSLVSShell_Setup_WithShellUI.png" border="0" />
        </p>
        <p>
          <u>5. Add DSL package output</u>
        </p>
        <p>
Add the Primary Output from the “DslPackage” project to the “PackagesToLoad” folder
</p>
        <p>
          <img src="http://www.baekdorf.dk/christian/content/binary/85_DSLVSShell_Setup_AddDslPackagePrimary.png" border="0" />
        </p>
        <p>
After adding the DSL package output the solution should look as shown below. Note
that a lot of dependencies will be added, you can just ignore them for now.
</p>
        <p>
          <img src="http://www.baekdorf.dk/christian/content/binary/86_DSLVSShell_Setup_WithDslPackagePrimary.png" border="0" />
        </p>
        <p>
          <u>6. Add MyDslProject output</u>
        </p>
        <p>
Add the Primary Output from the “MyDslProject” project to the “PackagesToLoad” folder.
</p>
        <p>
          <img src="http://www.baekdorf.dk/christian/content/binary/87_DSLVSShell_Setup_AddProjectPrimary.png" border="0" />
        </p>
        <p>
After adding the DSL project output the solution should look as shown below.
</p>
        <p>
          <img src="http://www.baekdorf.dk/christian/content/binary/88_DSLVSShell_Setup_WithProjectPrimary.png" border="0" />
        </p>
        <p>
          <u>7. Exclude unwanted dependencies</u>
        </p>
        <p>
Most of the dependencies that were added when adding the DslPackage and MyDslProject
output need to be excluded. The only dependency you will want to keep is “MyCompany.MyDsl.Dsl.dll”.
</p>
        <p>
In the Solution Explorer select all the dependencies to excluded as shown below and
select exclude on the context menu.
</p>
        <p>
          <img src="http://www.baekdorf.dk/christian/content/binary/89_DSLVSShell_Setup_ExcludeDep1.png" border="0" />
        </p>
        <p>
The solution should now look as the solution shown below
</p>
        <p>
          <img src="http://www.baekdorf.dk/christian/content/binary/90_DSLVSShell_Setup_ExcludeDep2.png" border="0" />
        </p>
        <p>
          <u>8. Add pkgdef files</u>
        </p>
        <p>
Add the “MyDslShell.pkgdef “ and “MyDslShell.pkgundef” from the folder “D:\project\DslToolsAndVsShell\Code\MyDSLApplication\MyDslShell\MyDslShell”
to the “PackagesToLoad” folder
</p>
        <p>
          <img src="http://www.baekdorf.dk/christian/content/binary/91_DSLVSShell_Setup_AddDefShell.png" border="0" />
        </p>
        <p>
Your solution should now look as shown below.
</p>
        <p>
          <img src="http://www.baekdorf.dk/christian/content/binary/92_DSLVSShell_Setup_AfterDefShell.png" border="0" />
        </p>
        <p>
          <u>9. Add pkgdef for project and dsl packages</u>
        </p>
        <p>
Add the “MyCompany.MyDsl.DslPackage.pkgdef “ and “MyDslProject.pkgdef” from the folder
“D:\project\DslToolsAndVsShell\Code\MyDSLApplication\Debug\PackagesToLoad” to the
“PackagesToLoad” folder.
</p>
        <p>
          <em>Please note that the file is taken from the “Debug” (not the “Release” folder”),
this is not an optimal solution. The file should actually be taken from the active
configuration output folder, but I could not find an easy way of doing this, so for
now just use the Debug or Release folder as you like –it the same file.</em>
        </p>
        <p>
          <img src="http://www.baekdorf.dk/christian/content/binary/93_DSLVSShell_Setup_AddDefPrjDsll.png" border="0" />
        </p>
        <p>
Your solution should now look as shown below.
</p>
        <p>
          <img src="http://www.baekdorf.dk/christian/content/binary/94_DSLVSShell_Setup_WithDefPrjDsl.png" border="0" />
        </p>
        <p>
          <u>10. Add project template</u>
        </p>
        <p>
Add the project template file “MyDslProject.zip” from the “D:\project\DslToolsAndVsShell\Code\MyDSLApplication\Debug\ProjectTemplates”
folder to “ProjectTemplates”.
</p>
        <p>
          <img src="http://www.baekdorf.dk/christian/content/binary/95_DSLVSShell_Setup_AddProjectTemplate.png" border="0" />
        </p>
        <p>
Your solution should now look as shown below.
</p>
        <p>
          <img src="http://www.baekdorf.dk/christian/content/binary/96_DSLVSShell_Setup_WithProjectTemplate.png" border="0" />
        </p>
        <p>
          <u>11. Add profile file</u>
        </p>
        <p>
Add the Visual Studio settings file “General.vssettings” from the “D:\project\DslToolsAndVsShell\Code\MyDSLApplication\MyDslShell\MyDslShell”
folder to “Profiles”.
</p>
        <p>
          <img src="http://www.baekdorf.dk/christian/content/binary/97_DSLVSShell_Setup_AddProfile.png" border="0" />
        </p>
        <p>
Your solution should now look as shown below.
</p>
        <p>
          <img src="http://www.baekdorf.dk/christian/content/binary/98_DSLVSShell_Setup_WithProfile.png" border="0" />
        </p>
        <p>
          <u>12. Adding the DSL schema</u>
        </p>
        <p>
You need to add the XML schema for your DSL, otherwise you will get a warning when
running the application. This has to be placed in “C:\Program Files\Microsoft Visual
Studio 9.0\Xml\Schemas”, even when we use the isolated shell.
</p>
        <p>
Add the “Program Files” folder to your solution as shown below, by right-clicking
the “File System on Target Machine” and choose Add Special Folder -&gt; Program Files
Folder
</p>
        <p>
          <img src="http://www.baekdorf.dk/christian/content/binary/99a_DSLVSShell_Setup_AddSchema.png" border="0" />
        </p>
        <p>
Under the Program Files folder add a folder named “Microsoft Visual Studio 9.0”, under
this folder add a folder named “Xml” and under this folder add a folder named “Schemas”.
</p>
        <p>
Add the file “MyDslSchema.xsd” from “D:\project\DslToolsAndVsShell\Code\MyDSLApplication\MyDsl\Dsl\GeneratedCode”
to the newly created “Schemas” folder.
</p>
        <p>
          <img src="http://www.baekdorf.dk/christian/content/binary/99_DSLVSShell_Setup_AddSchema.png" border="0" />
        </p>
        <p>
Your solution should now look as shown below.
</p>
        <p>
          <img src="http://www.baekdorf.dk/christian/content/binary/100_DSLVSShell_Setup_WithSchema.png" border="0" />
        </p>
        <p>
          <u>13. Adding a start menu folder</u>
        </p>
        <p>
Under “User’s Programs Menu” add a new folder named “MyCompany” and within that folder
create a new folder named “MyDsl”.
</p>
        <p>
          <img src="http://www.baekdorf.dk/christian/content/binary/101_DSLVSShell_Setup_StartMenuFolder.png" border="0" />
        </p>
        <p>
          <u>14. Add a start menu shortcut</u>
        </p>
        <p>
In the “MyDsl” folder, under the start menu, create a new shortcut pointing to the
Shell executable.
</p>
        <p>
          <img src="http://www.baekdorf.dk/christian/content/binary/102_DSLVSShell_Setup_CreateShortcut.png" border="0" />
        </p>
        <p>
And choose the primary output from the "MyDslShell" project
</p>
        <p>
          <img src="http://www.baekdorf.dk/christian/content/binary/103_DSLVSShell_Setup_ChooseTarget.png" border="0" />
        </p>
        <p>
Name the shortcut “MyDslShell” as shown below
</p>
        <p>
          <img src="http://www.baekdorf.dk/christian/content/binary/104_DSLVSShell_Setup_NameIcon.png" border="0" />
        </p>
        <p>
Choose the icon, “MyDslShell.ico”, in the Application Folder
</p>
        <p>
          <img src="http://www.baekdorf.dk/christian/content/binary/105_DSLVSShell_Setup_ChooseIcon.png" border="0" />
        </p>
        <p>
          <strong>Adding a launch conditions</strong>
        </p>
        <p>
Add a launch condition to ensure that Visual Studio 2008 isolated shell is installed
before installing our application
</p>
        <p>
          <u>1. Add registry search</u>
        </p>
        <p>
Fill in the following values:
</p>
        <p>
          <table border="1">
            <tbody>
              <tr>
                <td>
                  <font size="2">Name:</font>
                </td>
                <td>
                  <font size="2">Search for Visual Studio Registration</font>
                </td>
              </tr>
              <tr>
                <td>
                  <font size="2">Property:</font>
                </td>
                <td>
                  <font size="2">VSINSTALLDIR</font>
                </td>
              </tr>
              <tr>
                <td>
                  <font size="2">RegKey:</font>
                </td>
                <td>
                  <font size="2">Software\Microsoft\VisualStudio\9.0</font>
                </td>
              </tr>
              <tr>
                <td>
                  <font size="2">Root:</font>
                </td>
                <td>
                  <font size="2">vsdrrHKLM</font>
                </td>
              </tr>
              <tr>
                <td>
                  <font size="2">Value:</font>
                </td>
                <td>
                  <font size="2">InstallDir</font>
                </td>
              </tr>
            </tbody>
          </table>
        </p>
        <p>
Your solution should look as shown below.
</p>
        <p>
          <img src="http://www.baekdorf.dk/christian/content/binary/120_DSLVSShell_Setup_LaunchCond1.png" border="0" />
        </p>
        <p>
          <u>2. Add launch condition</u>
        </p>
        <p>
Fill in the following values:
</p>
        <p>
          <table border="1">
            <tbody>
              <tr>
                <td>
                  <font size="2">Name:</font>
                </td>
                <td>
                  <font size="2">CheckForVS</font>
                </td>
              </tr>
              <tr>
                <td>
                  <font size="2">Condition:</font>
                </td>
                <td>
                  <font size="2">VSINSTALLDIR&lt;&gt;""</font>
                </td>
              </tr>
              <tr>
                <td>
                  <font size="2">Install URL:</font>
                </td>
                <td>
                  <font size="2">http://www.microsoft.com/DOWNLOADS/details.aspx?FamilyID=021b3bee-b2ad-42a8-854a-c5eaef69e927&amp;displaylang=en</font>
                </td>
              </tr>
              <tr>
                <td>
                  <font size="2">Message:</font>
                </td>
                <td>
                  <font size="2">Install VS Shell Isolated SP1</font>
                </td>
              </tr>
            </tbody>
          </table>
        </p>
        <p>
Your solution should look as shown below.
</p>
        <p>
          <img src="http://www.baekdorf.dk/christian/content/binary/121_DSLVSShell_Setup_LaunchCond2.png" border="0" />
        </p>
        <p>
          <strong>Adding custom actions</strong>
        </p>
        <p>
During installation and uninstallation it is necessary to execute the shell application
with some options to register and unregister its components. This is done by adding
two custom actions to the installation.
</p>
        <p>
          <u>1. Add setup custom action</u>
        </p>
        <p>
Right-click the Install node and choose Add custom action…. In the Select Item in
Project dialog choose the primary output from “MyDslShell” in the Application Folder.
</p>
        <p>
          <img src="http://www.baekdorf.dk/christian/content/binary/130_DSLVSShell_Setup_AddCustomActionTarget.png" border="0" />
        </p>
        <p>
After adding the action specify “/setup” as arguments in the properties window.
</p>
        <p>
          <img src="http://www.baekdorf.dk/christian/content/binary/131_DSLVSShell_Setup_AddCustomArgSetup.png" border="0" />
        </p>
        <p>
          <u>2. Add remove custom action</u>
        </p>
        <p>
Right-click the Uninstall node and choose Add custom action…. In the Select Item in
Project dialog choose the primary output from “MyDslShell” in the Application Folder
</p>
        <p>
After adding the action specify “/remove” as arguments in the properties window.
</p>
        <p>
          <img src="http://www.baekdorf.dk/christian/content/binary/132_DSLVSShell_Setup_AddCustomArgRemove.png" border="0" />
        </p>
        <p>
          <strong>Build and Test</strong>
        </p>
        <p>
Finally you are ready to test the entire solution, so just build and try out the installationv
</p>
        <p>
          <u>1. Rebuild the setup project “MyDslApplication”</u>
        </p>
        <p>
          <img src="http://www.baekdorf.dk/christian/content/binary/206_DSLVSShell_Setup_Rebuild.png" border="0" />
        </p>
        <p>
          <u>2. Install the application</u>
        </p>
        <p>
Run the “setup.exe” from the folder “D:\project\DslToolsAndVsShell\Code\MyDSLApplication\MyDslApplication\Debug”
</p>
        <p>
          <img src="http://www.baekdorf.dk/christian/content/binary/207_DSLVSShell_Setup_Setup1.png" border="0" />
        </p>
        <p>
Just press next and install the application using its default settings
</p>
        <p>
          <u>3. Run the application</u>
        </p>
        <p>
Start the application from the Windows Start menu
</p>
        <p>
          <img src="http://www.baekdorf.dk/christian/content/binary/208_DSLVSShell_Setup_Setup2.png" border="0" />
        </p>
        <p>
You should now see your application
</p>
        <p>
          <img src="http://www.baekdorf.dk/christian/content/binary/209_DSLVSShell_Setup_Run1.png" border="0" />
        </p>
        <p>
Now try to open the New Project dialog and should hopefully show your Dsl project
as shown below
</p>
        <p>
          <img src="http://www.baekdorf.dk/christian/content/binary/210_DSLVSShell_Setup_NewProject.png" border="0" />
        </p>
        <p>
Create a new project and try out your application
</p>
        <p>
          <img src="http://www.baekdorf.dk/christian/content/binary/211_DSLVSShell_Setup_Run2.png" border="0" />
        </p>
        <p>
          <strong>Summary</strong>
        </p>
        <p>
This is the end of this tutorial, you have a running DSL application that can be redistributes,
but there are still some things to do:
</p>
        <p>
Download: <a href="http://www.baekdorf.dk/christian/content/binary/DslToolsAndVsShell-06.zip" target="_blank">DslToolsAndVsShell-06.zip
(12 MB)</a></p>
        <p>
What next?
</p>
        <p>
        </p>
        <ul>
          <li>
Make a new splash screen image 
</li>
          <li>
Remove menu items not relevant to your application 
</li>
          <li>
And other details like adding an About box 
</li>
        </ul>
        <img width="0" height="0" src="http://www.baekdorf.dk/christian/aggbug.ashx?id=35910122-71c6-474c-9200-05619fa7430b" />
      </body>
      <title>DSL and Visual Studio Shell tutorial: Creating a setup package</title>
      <guid isPermaLink="false">http://www.baekdorf.dk/christian/PermaLink,guid,35910122-71c6-474c-9200-05619fa7430b.aspx</guid>
      <link>http://www.baekdorf.dk/christian/2008/12/02/DSLAndVisualStudioShellTutorialCreatingASetupPackage.aspx</link>
      <pubDate>Tue, 02 Dec 2008 21:00:17 GMT</pubDate>
      <description>&lt;p&gt;
This post is part of a &lt;a href="http://www.baekdorf.dk/christian/2008/09/24/DSLToolsAndVisualStudio2008IsolatedShellTutorial.aspx"&gt;larger
tutorial on DSL Tools and Visual Studio 2008 Isolated Shell&lt;/a&gt;, in this post I will
go through the steps to setup project for the Shell application and DSL.
&lt;/p&gt;
&lt;p&gt;
Previous step: &lt;a href="http://www.baekdorf.dk/christian/2008/10/08/DSLAndVisualStudioShellTutorialCreatingACustomProjectType.aspx"&gt;Creating
a custom project type&lt;/a&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;strong&gt;Creating a new setup project&lt;/strong&gt;
&lt;/p&gt;
&lt;p&gt;
We will start by adding a new setup project to our solution, so start by opening the
solution from the previous post, if not already open.
&lt;/p&gt;
&lt;p&gt;
&lt;u&gt;1. New Project&lt;/u&gt;
&lt;/p&gt;
&lt;p&gt;
Create a new Setup Project named “MyDslApplication”, by right-clicking the solution
in the Solution Explorer and choosing Add New Project.
&lt;/p&gt;
&lt;p&gt;
In the Add New Project choose Setup Project as shown below:
&lt;/p&gt;
&lt;p&gt;
&lt;img src="http://www.baekdorf.dk/christian/content/binary/75_DSLVSShell_Setup_NewProject.png" border=0&gt;
&lt;/p&gt;
&lt;p&gt;
The solution should now look as shown below:
&lt;/p&gt;
&lt;p&gt;
&lt;img src="http://www.baekdorf.dk/christian/content/binary/76_DSLVSShell_Setup_Solution1.png" border=0&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;u&gt;2. Set project properties&lt;/u&gt;
&lt;/p&gt;
&lt;p&gt;
In the setup projects properties set Author and Manufacturer to “MyCompany” as shown
below.
&lt;/p&gt;
&lt;p&gt;
&lt;img src="http://www.baekdorf.dk/christian/content/binary/77_DSLVSShell_Setup_Properties.png" border=0&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;strong&gt;Adding output files&lt;/strong&gt;
&lt;/p&gt;
&lt;p&gt;
Now we are going to add assemblies and other files to the setup project, so you should
now open the “File System” in the setup project. Right-click the setup project, MyDslApplication,
in the Solution Explorer and choose View -&amp;gt; File System on the context menu.
&lt;/p&gt;
&lt;p&gt;
&lt;u&gt;1. Shell output&lt;/u&gt;
&lt;/p&gt;
&lt;p&gt;
Add the Primary Output from the “MyDslShell” project (this will be the actual executable
MyDslShell.exe) to the Application Folder.
&lt;/p&gt;
&lt;p&gt;
Right-click the Application Folder, in the File System view, and choose and Add -&amp;gt;
Project Output… from the context menu. Then select the “MyDslShell” project, Primary
Output and Active configuration as shown below.
&lt;/p&gt;
&lt;p&gt;
&lt;img src="http://www.baekdorf.dk/christian/content/binary/78_DSLVSShell_Setup_AddShellPrimary.png" border=0&gt;
&lt;/p&gt;
&lt;p&gt;
The solution should now look as shown below.
&lt;/p&gt;
&lt;p&gt;
&lt;img src="http://www.baekdorf.dk/christian/content/binary/79_DSLVSShell_Setup_WithShellPrimary.png" border=0&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;u&gt;2. Add Shell config, icon and splash screen image&lt;/u&gt;
&lt;/p&gt;
&lt;p&gt;
Add the following files from the folder “D:\project\DslToolsAndVsShell\Code\MyDSLApplication\MyDslShell\MyDslShell”
to the Application Folder:
&lt;/p&gt;
&lt;p&gt;
&lt;ul&gt;
&lt;li&gt;
MyDslShell.exe.config 
&lt;li&gt;
MyDslShell.ico 
&lt;li&gt;
Splash.bmp 
&lt;li&gt;
MyDslShell.prf&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;
Right-click the Application Folder, in the File System view, and choose and Add -&amp;gt;
File… from the context menu. Then select the files as shown below.
&lt;/p&gt;
&lt;p&gt;
&lt;img src="http://www.baekdorf.dk/christian/content/binary/80_DSLVSShell_Setup_AddShellConfigEtc.png" border=0&gt;
&lt;/p&gt;
&lt;p&gt;
After this your solution should look as shown below.
&lt;/p&gt;
&lt;p&gt;
&lt;img src="http://www.baekdorf.dk/christian/content/binary/81_DSLVSShell_Setup_Solution2.png" border=0&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;u&gt;3. Add PackagesToLoad and template folders&lt;/u&gt;
&lt;/p&gt;
&lt;p&gt;
Add the following folders under the Application Folder:
&lt;/p&gt;
&lt;p&gt;
&lt;ul&gt;
&lt;li&gt;
ItemTemplates 
&lt;li&gt;
ItemTemplatesCache 
&lt;li&gt;
ProjectTemplates 
&lt;li&gt;
ProjectTemplatesCache 
&lt;li&gt;
Profiles 
&lt;li&gt;
PackagesToLoad&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;
And a folder named “1033” under the new “PackagesToLoad” folder.
&lt;/p&gt;
&lt;p&gt;
Right-click the Application Folder or a subfolder, in the File System view, and choose
and Add -&amp;gt; Folder from the context menu to add a folder.
&lt;/p&gt;
&lt;p&gt;
&lt;img src="http://www.baekdorf.dk/christian/content/binary/82_DSLVSShell_Setup_NewFolders.png" border=0&gt;
&lt;/p&gt;
&lt;p&gt;
Mark the “ItemTemplates”, “ItemTemplatesCache”, “ProjectTemplates” and “ProjectTemplatesCache”
folders with the AlwaysCreate option as shown below
&lt;/p&gt;
&lt;p&gt;
&lt;img src="http://www.baekdorf.dk/christian/content/binary/82a_DSLVSShell_Setup_NewFoldersAlwaysCreate.png" border=0&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;u&gt;4. Add Shell UI output&lt;/u&gt;
&lt;/p&gt;
&lt;p&gt;
Add the Primary Output from MyDslShellUI to the “1033” folder.
&lt;/p&gt;
&lt;p&gt;
&lt;img src="http://www.baekdorf.dk/christian/content/binary/83_DSLVSShell_Setup_AddShellUIPrimary.png" border=0&gt;
&lt;/p&gt;
&lt;p&gt;
After adding the Shell UI output the solution should look as shown below.
&lt;/p&gt;
&lt;p&gt;
&lt;img src="http://www.baekdorf.dk/christian/content/binary/84_DSLVSShell_Setup_WithShellUI.png" border=0&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;u&gt;5. Add DSL package output&lt;/u&gt;
&lt;/p&gt;
&lt;p&gt;
Add the Primary Output from the “DslPackage” project to the “PackagesToLoad” folder
&lt;/p&gt;
&lt;p&gt;
&lt;img src="http://www.baekdorf.dk/christian/content/binary/85_DSLVSShell_Setup_AddDslPackagePrimary.png" border=0&gt;
&lt;/p&gt;
&lt;p&gt;
After adding the DSL package output the solution should look as shown below. Note
that a lot of dependencies will be added, you can just ignore them for now.
&lt;/p&gt;
&lt;p&gt;
&lt;img src="http://www.baekdorf.dk/christian/content/binary/86_DSLVSShell_Setup_WithDslPackagePrimary.png" border=0&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;u&gt;6. Add MyDslProject output&lt;/u&gt;
&lt;/p&gt;
&lt;p&gt;
Add the Primary Output from the “MyDslProject” project to the “PackagesToLoad” folder.
&lt;/p&gt;
&lt;p&gt;
&lt;img src="http://www.baekdorf.dk/christian/content/binary/87_DSLVSShell_Setup_AddProjectPrimary.png" border=0&gt;
&lt;/p&gt;
&lt;p&gt;
After adding the DSL project output the solution should look as shown below.
&lt;/p&gt;
&lt;p&gt;
&lt;img src="http://www.baekdorf.dk/christian/content/binary/88_DSLVSShell_Setup_WithProjectPrimary.png" border=0&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;u&gt;7. Exclude unwanted dependencies&lt;/u&gt;
&lt;/p&gt;
&lt;p&gt;
Most of the dependencies that were added when adding the DslPackage and MyDslProject
output need to be excluded. The only dependency you will want to keep is “MyCompany.MyDsl.Dsl.dll”.
&lt;/p&gt;
&lt;p&gt;
In the Solution Explorer select all the dependencies to excluded as shown below and
select exclude on the context menu.
&lt;/p&gt;
&lt;p&gt;
&lt;img src="http://www.baekdorf.dk/christian/content/binary/89_DSLVSShell_Setup_ExcludeDep1.png" border=0&gt;
&lt;/p&gt;
&lt;p&gt;
The solution should now look as the solution shown below
&lt;/p&gt;
&lt;p&gt;
&lt;img src="http://www.baekdorf.dk/christian/content/binary/90_DSLVSShell_Setup_ExcludeDep2.png" border=0&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;u&gt;8. Add pkgdef files&lt;/u&gt;
&lt;/p&gt;
&lt;p&gt;
Add the “MyDslShell.pkgdef “ and “MyDslShell.pkgundef” from the folder “D:\project\DslToolsAndVsShell\Code\MyDSLApplication\MyDslShell\MyDslShell”
to the “PackagesToLoad” folder
&lt;/p&gt;
&lt;p&gt;
&lt;img src="http://www.baekdorf.dk/christian/content/binary/91_DSLVSShell_Setup_AddDefShell.png" border=0&gt;
&lt;/p&gt;
&lt;p&gt;
Your solution should now look as shown below.
&lt;/p&gt;
&lt;p&gt;
&lt;img src="http://www.baekdorf.dk/christian/content/binary/92_DSLVSShell_Setup_AfterDefShell.png" border=0&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;u&gt;9. Add pkgdef for project and dsl packages&lt;/u&gt;
&lt;/p&gt;
&lt;p&gt;
Add the “MyCompany.MyDsl.DslPackage.pkgdef “ and “MyDslProject.pkgdef” from the folder
“D:\project\DslToolsAndVsShell\Code\MyDSLApplication\Debug\PackagesToLoad” to the
“PackagesToLoad” folder.
&lt;/p&gt;
&lt;p&gt;
&lt;em&gt;Please note that the file is taken from the “Debug” (not the “Release” folder”),
this is not an optimal solution. The file should actually be taken from the active
configuration output folder, but I could not find an easy way of doing this, so for
now just use the Debug or Release folder as you like –it the same file.&lt;/em&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;img src="http://www.baekdorf.dk/christian/content/binary/93_DSLVSShell_Setup_AddDefPrjDsll.png" border=0&gt;
&lt;/p&gt;
&lt;p&gt;
Your solution should now look as shown below.
&lt;/p&gt;
&lt;p&gt;
&lt;img src="http://www.baekdorf.dk/christian/content/binary/94_DSLVSShell_Setup_WithDefPrjDsl.png" border=0&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;u&gt;10. Add project template&lt;/u&gt;
&lt;/p&gt;
&lt;p&gt;
Add the project template file “MyDslProject.zip” from the “D:\project\DslToolsAndVsShell\Code\MyDSLApplication\Debug\ProjectTemplates”
folder to “ProjectTemplates”.
&lt;/p&gt;
&lt;p&gt;
&lt;img src="http://www.baekdorf.dk/christian/content/binary/95_DSLVSShell_Setup_AddProjectTemplate.png" border=0&gt;
&lt;/p&gt;
&lt;p&gt;
Your solution should now look as shown below.
&lt;/p&gt;
&lt;p&gt;
&lt;img src="http://www.baekdorf.dk/christian/content/binary/96_DSLVSShell_Setup_WithProjectTemplate.png" border=0&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;u&gt;11. Add profile file&lt;/u&gt;
&lt;/p&gt;
&lt;p&gt;
Add the Visual Studio settings file “General.vssettings” from the “D:\project\DslToolsAndVsShell\Code\MyDSLApplication\MyDslShell\MyDslShell”
folder to “Profiles”.
&lt;/p&gt;
&lt;p&gt;
&lt;img src="http://www.baekdorf.dk/christian/content/binary/97_DSLVSShell_Setup_AddProfile.png" border=0&gt;
&lt;/p&gt;
&lt;p&gt;
Your solution should now look as shown below.
&lt;/p&gt;
&lt;p&gt;
&lt;img src="http://www.baekdorf.dk/christian/content/binary/98_DSLVSShell_Setup_WithProfile.png" border=0&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;u&gt;12. Adding the DSL schema&lt;/u&gt;
&lt;/p&gt;
&lt;p&gt;
You need to add the XML schema for your DSL, otherwise you will get a warning when
running the application. This has to be placed in “C:\Program Files\Microsoft Visual
Studio 9.0\Xml\Schemas”, even when we use the isolated shell.
&lt;/p&gt;
&lt;p&gt;
Add the “Program Files” folder to your solution as shown below, by right-clicking
the “File System on Target Machine” and choose Add Special Folder -&amp;gt; Program Files
Folder
&lt;/p&gt;
&lt;p&gt;
&lt;img src="http://www.baekdorf.dk/christian/content/binary/99a_DSLVSShell_Setup_AddSchema.png" border=0&gt;
&lt;/p&gt;
&lt;p&gt;
Under the Program Files folder add a folder named “Microsoft Visual Studio 9.0”, under
this folder add a folder named “Xml” and under this folder add a folder named “Schemas”.
&lt;/p&gt;
&lt;p&gt;
Add the file “MyDslSchema.xsd” from “D:\project\DslToolsAndVsShell\Code\MyDSLApplication\MyDsl\Dsl\GeneratedCode”
to the newly created “Schemas” folder.
&lt;/p&gt;
&lt;p&gt;
&lt;img src="http://www.baekdorf.dk/christian/content/binary/99_DSLVSShell_Setup_AddSchema.png" border=0&gt;
&lt;/p&gt;
&lt;p&gt;
Your solution should now look as shown below.
&lt;/p&gt;
&lt;p&gt;
&lt;img src="http://www.baekdorf.dk/christian/content/binary/100_DSLVSShell_Setup_WithSchema.png" border=0&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;u&gt;13. Adding a start menu folder&lt;/u&gt;
&lt;/p&gt;
&lt;p&gt;
Under “User’s Programs Menu” add a new folder named “MyCompany” and within that folder
create a new folder named “MyDsl”.
&lt;/p&gt;
&lt;p&gt;
&lt;img src="http://www.baekdorf.dk/christian/content/binary/101_DSLVSShell_Setup_StartMenuFolder.png" border=0&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;u&gt;14. Add a start menu shortcut&lt;/u&gt;
&lt;/p&gt;
&lt;p&gt;
In the “MyDsl” folder, under the start menu, create a new shortcut pointing to the
Shell executable.
&lt;/p&gt;
&lt;p&gt;
&lt;img src="http://www.baekdorf.dk/christian/content/binary/102_DSLVSShell_Setup_CreateShortcut.png" border=0&gt;
&lt;/p&gt;
&lt;p&gt;
And choose the primary output from the "MyDslShell" project
&lt;/p&gt;
&lt;p&gt;
&lt;img src="http://www.baekdorf.dk/christian/content/binary/103_DSLVSShell_Setup_ChooseTarget.png" border=0&gt;
&lt;/p&gt;
&lt;p&gt;
Name the shortcut “MyDslShell” as shown below
&lt;/p&gt;
&lt;p&gt;
&lt;img src="http://www.baekdorf.dk/christian/content/binary/104_DSLVSShell_Setup_NameIcon.png" border=0&gt;
&lt;/p&gt;
&lt;p&gt;
Choose the icon, “MyDslShell.ico”, in the Application Folder
&lt;/p&gt;
&lt;p&gt;
&lt;img src="http://www.baekdorf.dk/christian/content/binary/105_DSLVSShell_Setup_ChooseIcon.png" border=0&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;strong&gt;Adding a launch conditions&lt;/strong&gt;
&lt;/p&gt;
&lt;p&gt;
Add a launch condition to ensure that Visual Studio 2008 isolated shell is installed
before installing our application
&lt;/p&gt;
&lt;p&gt;
&lt;u&gt;1. Add registry search&lt;/u&gt;
&lt;/p&gt;
&lt;p&gt;
Fill in the following values:
&lt;/p&gt;
&lt;p&gt;
&lt;table border=1&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;font size=2&gt;Name:&lt;/font&gt;&lt;/td&gt;
&lt;td&gt;
&lt;font size=2&gt;Search for Visual Studio Registration&lt;/font&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;font size=2&gt;Property:&lt;/font&gt;&lt;/td&gt;
&lt;td&gt;
&lt;font size=2&gt;VSINSTALLDIR&lt;/font&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;font size=2&gt;RegKey:&lt;/font&gt;&lt;/td&gt;
&lt;td&gt;
&lt;font size=2&gt;Software\Microsoft\VisualStudio\9.0&lt;/font&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;font size=2&gt;Root:&lt;/font&gt;&lt;/td&gt;
&lt;td&gt;
&lt;font size=2&gt;vsdrrHKLM&lt;/font&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;font size=2&gt;Value:&lt;/font&gt;&lt;/td&gt;
&lt;td&gt;
&lt;font size=2&gt;InstallDir&lt;/font&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;/p&gt;
&lt;p&gt;
Your solution should look as shown below.
&lt;/p&gt;
&lt;p&gt;
&lt;img src="http://www.baekdorf.dk/christian/content/binary/120_DSLVSShell_Setup_LaunchCond1.png" border=0&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;u&gt;2. Add launch condition&lt;/u&gt;
&lt;/p&gt;
&lt;p&gt;
Fill in the following values:
&lt;/p&gt;
&lt;p&gt;
&lt;table border=1&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;font size=2&gt;Name:&lt;/font&gt;&lt;/td&gt;
&lt;td&gt;
&lt;font size=2&gt;CheckForVS&lt;/font&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;font size=2&gt;Condition:&lt;/font&gt;&lt;/td&gt;
&lt;td&gt;
&lt;font size=2&gt;VSINSTALLDIR&amp;lt;&amp;gt;""&lt;/font&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;font size=2&gt;Install URL:&lt;/font&gt;&lt;/td&gt;
&lt;td&gt;
&lt;font size=2&gt;http://www.microsoft.com/DOWNLOADS/details.aspx?FamilyID=021b3bee-b2ad-42a8-854a-c5eaef69e927&amp;amp;displaylang=en&lt;/font&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;font size=2&gt;Message:&lt;/font&gt;&lt;/td&gt;
&lt;td&gt;
&lt;font size=2&gt;Install VS Shell Isolated SP1&lt;/font&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;/p&gt;
&lt;p&gt;
Your solution should look as shown below.
&lt;/p&gt;
&lt;p&gt;
&lt;img src="http://www.baekdorf.dk/christian/content/binary/121_DSLVSShell_Setup_LaunchCond2.png" border=0&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;strong&gt;Adding custom actions&lt;/strong&gt;
&lt;/p&gt;
&lt;p&gt;
During installation and uninstallation it is necessary to execute the shell application
with some options to register and unregister its components. This is done by adding
two custom actions to the installation.
&lt;/p&gt;
&lt;p&gt;
&lt;u&gt;1. Add setup custom action&lt;/u&gt;
&lt;/p&gt;
&lt;p&gt;
Right-click the Install node and choose Add custom action…. In the Select Item in
Project dialog choose the primary output from “MyDslShell” in the Application Folder.
&lt;/p&gt;
&lt;p&gt;
&lt;img src="http://www.baekdorf.dk/christian/content/binary/130_DSLVSShell_Setup_AddCustomActionTarget.png" border=0&gt;
&lt;/p&gt;
&lt;p&gt;
After adding the action specify “/setup” as arguments in the properties window.
&lt;/p&gt;
&lt;p&gt;
&lt;img src="http://www.baekdorf.dk/christian/content/binary/131_DSLVSShell_Setup_AddCustomArgSetup.png" border=0&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;u&gt;2. Add remove custom action&lt;/u&gt;
&lt;/p&gt;
&lt;p&gt;
Right-click the Uninstall node and choose Add custom action…. In the Select Item in
Project dialog choose the primary output from “MyDslShell” in the Application Folder
&lt;/p&gt;
&lt;p&gt;
After adding the action specify “/remove” as arguments in the properties window.
&lt;/p&gt;
&lt;p&gt;
&lt;img src="http://www.baekdorf.dk/christian/content/binary/132_DSLVSShell_Setup_AddCustomArgRemove.png" border=0&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;strong&gt;Build and Test&lt;/strong&gt;
&lt;/p&gt;
&lt;p&gt;
Finally you are ready to test the entire solution, so just build and try out the installationv
&lt;/p&gt;
&lt;p&gt;
&lt;u&gt;1. Rebuild the setup project “MyDslApplication”&lt;/u&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;img src="http://www.baekdorf.dk/christian/content/binary/206_DSLVSShell_Setup_Rebuild.png" border=0&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;u&gt;2. Install the application&lt;/u&gt;
&lt;/p&gt;
&lt;p&gt;
Run the “setup.exe” from the folder “D:\project\DslToolsAndVsShell\Code\MyDSLApplication\MyDslApplication\Debug”
&lt;/p&gt;
&lt;p&gt;
&lt;img src="http://www.baekdorf.dk/christian/content/binary/207_DSLVSShell_Setup_Setup1.png" border=0&gt;
&lt;/p&gt;
&lt;p&gt;
Just press next and install the application using its default settings
&lt;/p&gt;
&lt;p&gt;
&lt;u&gt;3. Run the application&lt;/u&gt;
&lt;/p&gt;
&lt;p&gt;
Start the application from the Windows Start menu
&lt;/p&gt;
&lt;p&gt;
&lt;img src="http://www.baekdorf.dk/christian/content/binary/208_DSLVSShell_Setup_Setup2.png" border=0&gt;
&lt;/p&gt;
&lt;p&gt;
You should now see your application
&lt;/p&gt;
&lt;p&gt;
&lt;img src="http://www.baekdorf.dk/christian/content/binary/209_DSLVSShell_Setup_Run1.png" border=0&gt;
&lt;/p&gt;
&lt;p&gt;
Now try to open the New Project dialog and should hopefully show your Dsl project
as shown below
&lt;/p&gt;
&lt;p&gt;
&lt;img src="http://www.baekdorf.dk/christian/content/binary/210_DSLVSShell_Setup_NewProject.png" border=0&gt;
&lt;/p&gt;
&lt;p&gt;
Create a new project and try out your application
&lt;/p&gt;
&lt;p&gt;
&lt;img src="http://www.baekdorf.dk/christian/content/binary/211_DSLVSShell_Setup_Run2.png" border=0&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;strong&gt;Summary&lt;/strong&gt;
&lt;/p&gt;
&lt;p&gt;
This is the end of this tutorial, you have a running DSL application that can be redistributes,
but there are still some things to do:
&lt;/p&gt;
&lt;p&gt;
Download: &lt;a href="http://www.baekdorf.dk/christian/content/binary/DslToolsAndVsShell-06.zip" target=_blank&gt;DslToolsAndVsShell-06.zip
(12 MB)&lt;/a&gt;
&lt;/p&gt;
&lt;p&gt;
What next?
&lt;/p&gt;
&lt;p&gt;
&lt;ul&gt;
&lt;li&gt;
Make a new splash screen image 
&lt;li&gt;
Remove menu items not relevant to your application 
&lt;li&gt;
And other details like adding an About box 
&lt;/li&gt;
&lt;/ul&gt;
&lt;img width="0" height="0" src="http://www.baekdorf.dk/christian/aggbug.ashx?id=35910122-71c6-474c-9200-05619fa7430b" /&gt;</description>
      <comments>http://www.baekdorf.dk/christian/CommentView,guid,35910122-71c6-474c-9200-05619fa7430b.aspx</comments>
    </item>
    <item>
      <trackback:ping>http://www.baekdorf.dk/christian/Trackback.aspx?guid=726b5c35-6660-43aa-a25b-d105f9ccf50e</trackback:ping>
      <pingback:server>http://www.baekdorf.dk/christian/pingback.aspx</pingback:server>
      <pingback:target>http://www.baekdorf.dk/christian/PermaLink,guid,726b5c35-6660-43aa-a25b-d105f9ccf50e.aspx</pingback:target>
      <dc:creator>Christian B�kdorf (admin)</dc:creator>
      <wfw:comment>http://www.baekdorf.dk/christian/CommentView,guid,726b5c35-6660-43aa-a25b-d105f9ccf50e.aspx</wfw:comment>
      <wfw:commentRss>http://www.baekdorf.dk/christian/SyndicationService.asmx/GetEntryCommentsRss?guid=726b5c35-6660-43aa-a25b-d105f9ccf50e</wfw:commentRss>
      <slash:comments>143</slash:comments>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
This post is part of a <a href="http://www.baekdorf.dk/christian/2008/09/24/DSLToolsAndVisualStudio2008IsolatedShellTutorial.aspx">larger
tutorial on DSL Tools and Visual Studio 2008 Isolated Shell</a>, in this post I will
go through the steps to add a custom project type to the Shell application. 
</p>
        <p>
Previous step: <a href="http://www.baekdorf.dk/christian/2008/10/01/DSLAndVisualStudioShellTutorialAddingTheDSLToTheShell.aspx">Adding
the DSL to the Shell</a></p>
        <p>
          <strong>Creating a new Visual Studio Integration Package</strong>
        </p>
        <p>
A custom project types is implemented as a Visual Studio Integration Package, so the
first step is to add a new integration package to the Shell solution.
</p>
        <p>
          <u>1. New project</u>
        </p>
        <p>
Choose Add New Project and select the Visual Studio Integration Package project template.
</p>
        <p>
Name the project “MyDslProject” and accept the default location.
</p>
        <p>
          <img src="http://www.baekdorf.dk/christian/content/binary/45_DSLVSShell_Project_NewProject.png" border="0" />
        </p>
        <p>
          <u>2. Welcome page</u>
        </p>
        <p>
Just click next
</p>
        <p>
          <img src="http://www.baekdorf.dk/christian/content/binary/46_DSLVSShell_Project_Wizard0.png" border="0" />
        </p>
        <p>
          <u>3. Choose programming language and strong name key</u>
        </p>
        <p>
Choose C# as programming language and just create a new strong name key.
</p>
        <p>
          <img src="http://www.baekdorf.dk/christian/content/binary/47_DSLVSShell_Project_Wizard1.png" border="0" />
        </p>
        <p>
          <u>4. Company name and package name</u>
        </p>
        <p>
Specify company name and package name as shown below
</p>
        <p>
          <img src="http://www.baekdorf.dk/christian/content/binary/48_DSLVSShell_Project_Wizard2.png" border="0" />
        </p>
        <p>
          <u>5. Testing project</u>
        </p>
        <p>
Deselect both Integration Test Project and Unit Test Project.
</p>
        <p>
Press Finish to create the project
</p>
        <p>
          <img src="http://www.baekdorf.dk/christian/content/binary/49_DSLVSShell_Project_Wizard3.png" border="0" />
        </p>
        <p>
          <u>6. Resulting solution</u>
        </p>
        <p>
The solution should now look as shown below.
</p>
        <p>
          <img src="http://www.baekdorf.dk/christian/content/binary/51_DSLVSShell_Project_JustAdded.png" border="0" />
        </p>
        <p>
          <u>7. Shell Dependencies</u>
        </p>
        <p>
Now set the shell dependencies for the “MyDslShell” project, so the project will depend
on “MyDslProject”. Right-click “MyDslShell” project and choose “Shell Dependencies…”.
</p>
        <p>
          <img src="http://www.baekdorf.dk/christian/content/binary/52_DSLVSShell_Project_ShellDependencies.png" border="0" />
        </p>
        <p>
          <strong>Adding a Package Load Key (PLK)</strong>
        </p>
        <p>
The “MyDslProject” is a Visual Studio integration package, so we need to add a Package
Load Key (PLK) to the project.
</p>
        <p>
          <u>1. Gathering necessary information for obtaining a PLK </u>
        </p>
        <p>
To obtain a PLK you will need the following information:
</p>
        <ul>
          <li>
Company name 
</li>
          <li>
Package name 
</li>
          <li>
Package Guid 
</li>
          <li>
Package version</li>
        </ul>
        <p>
The first part of the information can be found in “MyDslProjectPackage.cs” file, as
shown below
</p>
        <p>
          <img src="http://www.baekdorf.dk/christian/content/binary/53_DSLVSShell_Project_PlkInfo1.png" border="0" />
        </p>
        <p>
The package Guid can be found in “Guids.cs”
</p>
        <p>
          <img src="http://www.baekdorf.dk/christian/content/binary/54_DSLVSShell_Project_PlkInfo2.png" border="0" />
        </p>
        <p>
          <u>2. Obtaining a Package Load Key (PLK)</u>
        </p>
        <p>
You can obtain a Package Load Key (PLK) from MSDN: <a href="http://msdn.microsoft.com/en-us/vsx/cc655795.aspx" target="_blank">Generate
Load Keys</a></p>
        <p>
Enter the information about your package; choose “Standard” as Min. Product Edition
and “Visual Studio 2008” as min. VS Version. Finally press “Generate PLK”.
</p>
        <p>
          <img src="http://www.baekdorf.dk/christian/content/binary/55_DSLVSShell_Project_PlkGenerate.png" border="0" />
        </p>
        <p>
          <u>3. Adding the Package Load Key (PLK) to MyDslProject</u>
        </p>
        <p>
We have to add the PLK to the “MyDslProject” projects resource file “VSPackage.resx”.
Insert in in the entry with “1” as name without any newlines.
</p>
        <p>
          <img src="http://www.baekdorf.dk/christian/content/binary/56_DSLVSShell_Project_PlkAdd.png" border="0" />
        </p>
        <p>
          <strong>Integrating Managed Package Framework for Projects</strong>
        </p>
        <p>
Next we have to integrate the Managed Package Framework for Projects into the “MyDslProject”
project. This we will do be manually editing the “MyDslProject.csproj” in it’s XML
form. If you have <a href="http://code.msdn.microsoft.com/PowerCommands" target="_blank">Power
Commands for Visual Studio 2008</a> installed you can right-click the project and
choose Edit Project File.
</p>
        <p>
          <u>1. Editing the project file</u>
        </p>
        <p>
First you will have to add the line shown below:
</p>
        <p>
          <!--
{\rtf1\ansi\ansicpg\lang1024\noproof65001\uc1 \deff0{\fonttbl{\f0\fnil\fcharset0\fprq1 Courier New;}}{\colortbl;??\red0\green0\blue255;\red255\green255\blue255;\red163\green21\blue21;\red0\green0\blue0;}??\fs20 \cf1     &lt;\cf3 ProjectBasePath\cf1 &gt;\cf0 ..\\..\\MPFProj\\9.0\\Src\\CSharp\cf1 &lt;/\cf3 ProjectBasePath\cf1 &gt;\par ??}
-->
        </p>
        <div style="FONT-SIZE: 9pt; BACKGROUND: white; COLOR: black; FONT-FAMILY: Courier New">
          <p style="MARGIN: 0px">
            <span style="COLOR: blue">    &lt;</span>
            <span style="COLOR: #a31515">ProjectBasePath</span>
            <span style="COLOR: blue">&gt;</span>..\..\MPFProj\9.0\Src\CSharp<span style="COLOR: blue">&lt;/</span><span style="COLOR: #a31515">ProjectBasePath</span><span style="COLOR: blue">&gt;</span></p>
        </div>
        <p>
          <img src="http://www.baekdorf.dk/christian/content/binary/57_DSLVSShell_Project_ChangeProj1.png" border="0" />
        </p>
        <p>
Then add the line below as shown below:
</p>
        <p>
          <!--
{\rtf1\ansi\ansicpg\lang1024\noproof65001\uc1 \deff0{\fonttbl{\f0\fnil\fcharset0\fprq1 Courier New;}}{\colortbl;??\red0\green0\blue255;\red255\green255\blue255;\red163\green21\blue21;\red255\green0\blue0;\red0\green0\blue0;}??\fs20 \cf1   &lt;\cf3 Import\cf1  \cf4 Project\cf1 =\cf0 "\cf1 $(ProjectBasePath)\\ProjectBase.Files\cf0 "\cf1  /&gt;}
-->
        </p>
        <div style="FONT-SIZE: 9pt; BACKGROUND: white; COLOR: black; FONT-FAMILY: Courier New">
          <p style="MARGIN: 0px">
            <span style="COLOR: blue">  &lt;</span>
            <span style="COLOR: #a31515">Import</span>
            <span style="COLOR: blue">
            </span>
            <span style="COLOR: red">Project</span>
            <span style="COLOR: blue">=</span>"<span style="COLOR: blue">$(ProjectBasePath)\ProjectBase.Files</span>"<span style="COLOR: blue"> /&gt;</span></p>
        </div>
        <p>
        </p>
        <p>
          <img src="http://www.baekdorf.dk/christian/content/binary/58_DSLVSShell_Project_ChangeProj2.png" border="0" />
        </p>
        <p>
          <u>2. Reload the project in Visual Studio</u>
        </p>
        <p>
When reloading the project, you will get a warning as show below. Just choose Load
project normally.
</p>
        <p>
          <img src="http://www.baekdorf.dk/christian/content/binary/59_DSLVSShell_Project_SecurityWarning.png" border="0" />
        </p>
        <p>
          <u>3. Adding required reference</u>
        </p>
        <p>
The Managed Package Framework for Projects uses some extra assemblies, which we need
to reference before the project can compile.
</p>
        <p>
Add a reference to EnvDTE, as show below.
</p>
        <p>
          <img src="http://www.baekdorf.dk/christian/content/binary/60_DSLVSShell_Project_AddRef1.png" border="0" />
        </p>
        <p>
Add a reference to Microsoft.VisualStudio.Designer.Interfaces, as show below.
</p>
        <p>
          <img src="http://www.baekdorf.dk/christian/content/binary/61_DSLVSShell_Project_AddRef2.png" border="0" />
        </p>
        <p>
The “MyDslProject” should now be able to compile.
</p>
        <p>
          <strong>Implementing the custom project type</strong>
        </p>
        <p>
Now we are ready to implement the new custom project type for the DSL project.
</p>
        <p>
          <u>1. Defining a project type Guid</u>
        </p>
        <p>
First we have to define a Guid for our new project type, just generate a new Guid.
</p>
        <p>
Add the new project type Guid to the “Guids.cs” file as show below:
</p>
        <p>
          <!--
{\rtf1\ansi\ansicpg\lang1024\noproof65001\uc1 \deff0{\fonttbl{\f0\fnil\fcharset0\fprq1 Courier New;}}{\colortbl;??\red0\green0\blue0;\red255\green255\blue255;\red0\green0\blue255;\red163\green21\blue21;\red43\green145\blue175;}??\fs20     \cf3 public\cf0  \cf3 const\cf0  \cf3 string\cf0  guidMyDslProjectFactoryString =\par ??        \cf4 "1584A98D-D032-4709-9AC0-C3F2A8C93857"\cf0 ;\par ??    \cf3 public\cf0  \cf3 static\cf0  \cf3 readonly\cf0  \cf5 Guid\cf0  guidMyDslProjectFactory =\par ??        \cf3 new\cf0  \cf5 Guid\cf0 (guidMyDslProjectFactoryString);\par ??}
-->
        </p>
        <div style="FONT-SIZE: 9pt; BACKGROUND: white; COLOR: black; FONT-FAMILY: Courier New">
          <p style="MARGIN: 0px">
    <span style="COLOR: blue">public</span><span style="COLOR: blue">const</span><span style="COLOR: blue">string</span> guidMyDslProjectFactoryString
=
</p>
          <p style="MARGIN: 0px">
        <span style="COLOR: #a31515">"1584A98D-D032-4709-9AC0-C3F2A8C93857"</span>;
</p>
          <p style="MARGIN: 0px">
    <span style="COLOR: blue">public</span><span style="COLOR: blue">static</span><span style="COLOR: blue">readonly</span><span style="COLOR: #2b91af">Guid</span> guidMyDslProjectFactory
=
</p>
          <p style="MARGIN: 0px">
        <span style="COLOR: blue">new</span><span style="COLOR: #2b91af">Guid</span>(guidMyDslProjectFactoryString);
</p>
        </div>
        <p>
          <img src="http://www.baekdorf.dk/christian/content/binary/63_DSLVSShell_Project_PrjGuid.png" border="0" />
        </p>
        <p>
          <u>2. Adding factory and node classes</u>
        </p>
        <p>
To implement a custom project we need a factory class for instantiating new projects
and project node class.
</p>
        <p>
Add two C# classes to the “MyDslProjectFactory” and “MyDslProjectNode.cs” to the “MyDslProject”
project. Your solution should then look as shown below.
</p>
        <p>
          <img src="http://www.baekdorf.dk/christian/content/binary/62_DSLVSShell_Project_NewClassFiles.png" border="0" />
        </p>
        <p>
          <u>3. Implement the “MyDslProjectNode” class</u>
        </p>
        <p>
Implement a simple project node as shown below:
</p>
        <p>
          <!--
{\rtf1\ansi\ansicpg\lang1024\noproof65001\uc1 \deff0{\fonttbl{\f0\fnil\fcharset0\fprq1 Courier New;}}{\colortbl;??\red0\green0\blue0;\red255\green255\blue255;\red43\green145\blue175;\red163\green21\blue21;\red0\green0\blue255;}??\fs20     [\cf3 Guid\cf0 (\cf4 "8D681873-2A8D-442b-82CE-ED96C69D02D7"\cf0 )]\par ??    \cf5 public\cf0  \cf5 class\cf0  \cf3 MyDslProjectNode\cf0  : \cf3 ProjectNode\par ??\cf0     \{\par ??        \cf5 internal\cf0  \cf5 const\cf0  \cf5 string\cf0  ProjectTypeName = \cf4 "MyDslProject"\cf0 ;\par ??        \cf5 private\cf0  \cf3 MyDslProjectPackage\cf0  m_Package;\par ??\par ??        \cf5 public\cf0  MyDslProjectNode(\cf3 MyDslProjectPackage\cf0  package)\par ??        \{\par ??            m_Package = package;\par ??        \}\par ??\par ??        \cf5 public\cf0  \cf5 override\cf0  \cf5 string\cf0  ProjectType\par ??        \{\par ??            \cf5 get\cf0  \{ \cf5 return\cf0  ProjectTypeName; \}\par ??        \}\par ??\par ??        \cf5 public\cf0  \cf5 override\cf0  \cf3 Guid\cf0  ProjectGuid\par ??        \{\par ??            \cf5 get\cf0  \{ \cf5 return\cf0  \cf5 typeof\cf0 (\cf3 MyDslProjectFactory\cf0 ).GUID; \}\par ??        \}\par ??    \}\par ??}
-->
        </p>
        <div style="FONT-SIZE: 9pt; BACKGROUND: white; COLOR: black; FONT-FAMILY: Courier New">
          <p style="MARGIN: 0px">
    [<span style="COLOR: #2b91af">Guid</span>(<span style="COLOR: #a31515">"8D681873-2A8D-442b-82CE-ED96C69D02D7"</span>)]
</p>
          <p style="MARGIN: 0px">
    <span style="COLOR: blue">public</span><span style="COLOR: blue">class</span><span style="COLOR: #2b91af">MyDslProjectNode</span> : <span style="COLOR: #2b91af">ProjectNode</span></p>
          <p style="MARGIN: 0px">
    {
</p>
          <p style="MARGIN: 0px">
        <span style="COLOR: blue">internal</span><span style="COLOR: blue">const</span><span style="COLOR: blue">string</span> ProjectTypeName
= <span style="COLOR: #a31515">"MyDslProject"</span>;
</p>
          <p style="MARGIN: 0px">
        <span style="COLOR: blue">private</span><span style="COLOR: #2b91af">MyDslProjectPackage</span> m_Package;
</p>
          <p style="MARGIN: 0px">
 
</p>
          <p style="MARGIN: 0px">
        <span style="COLOR: blue">public</span> MyDslProjectNode(<span style="COLOR: #2b91af">MyDslProjectPackage</span> package)
</p>
          <p style="MARGIN: 0px">
        {
</p>
          <p style="MARGIN: 0px">
            m_Package = package;
</p>
          <p style="MARGIN: 0px">
        }
</p>
          <p style="MARGIN: 0px">
 
</p>
          <p style="MARGIN: 0px">
        <span style="COLOR: blue">public</span><span style="COLOR: blue">override</span><span style="COLOR: blue">string</span> ProjectType
</p>
          <p style="MARGIN: 0px">
        {
</p>
          <p style="MARGIN: 0px">
            <span style="COLOR: blue">get</span> { <span style="COLOR: blue">return</span> ProjectTypeName;
}
</p>
          <p style="MARGIN: 0px">
        }
</p>
          <p style="MARGIN: 0px">
 
</p>
          <p style="MARGIN: 0px">
        <span style="COLOR: blue">public</span><span style="COLOR: blue">override</span><span style="COLOR: #2b91af">Guid</span> ProjectGuid
</p>
          <p style="MARGIN: 0px">
        {
</p>
          <p style="MARGIN: 0px">
            <span style="COLOR: blue">get</span> { <span style="COLOR: blue">return</span><span style="COLOR: blue">typeof</span>(<span style="COLOR: #2b91af">MyDslProjectFactory</span>).GUID;
}
</p>
          <p style="MARGIN: 0px">
        }
</p>
          <p style="MARGIN: 0px">
    }
</p>
        </div>
        <p>
        </p>
        <p>
The project node needs a Guid, just generate a new Guid not used in any other place.
</p>
        <p>
          <u>4. Implement the “MyDslProjectFactory” class</u>
        </p>
        <p>
Implement a simple project factory as shown below:
</p>
        <p>
          <!--
{\rtf1\ansi\ansicpg\lang1024\noproof65001\uc1 \deff0{\fonttbl{\f0\fnil\fcharset0\fprq1 Courier New;}}{\colortbl;??\red0\green0\blue255;\red255\green255\blue255;\red0\green0\blue0;\red43\green145\blue175;}??\fs20 \cf1 using\cf0  System;\par ??\cf1 using\cf0  System.Runtime.InteropServices;\par ??\cf1 using\cf0  Microsoft.VisualStudio.Project;\par ??\cf1 using\cf0  \cf4 IOleServiceProvider\cf0  = Microsoft.VisualStudio.OLE.Interop.\cf4 IServiceProvider\cf0 ;\par ??\par ??\cf1 namespace\cf0  MyCompany.MyDslProject\par ??\{\par ??    [\cf4 Guid\cf0 (\cf4 GuidList\cf0 .guidMyDslProjectFactoryString)]\par ??    \cf1 public\cf0  \cf1 class\cf0  \cf4 MyDslProjectFactory\cf0  : \cf4 ProjectFactory\par ??\cf0     \{\par ??        \cf1 private\cf0  \cf4 MyDslProjectPackage\cf0  m_Package;\par ??\par ??        \cf1 public\cf0  MyDslProjectFactory(\cf4 MyDslProjectPackage\cf0  package)\par ??            : \cf1 base\cf0 (package)\par ??        \{\par ??            m_Package = package;\par ??        \}\par ??\par ??        \cf1 protected\cf0  \cf1 override\cf0  \cf4 ProjectNode\cf0  CreateProject()\par ??        \{\par ??            \cf4 MyDslProjectNode\cf0  project = \cf1 new\cf0  \cf4 MyDslProjectNode\cf0 (\cf1 this\cf0 .m_Package);\par ??            \cf4 IServiceProvider\cf0  serviceProvider = (\cf4 IServiceProvider\cf0 )\cf1 this\cf0 .m_Package;\par ??            \cf4 IOleServiceProvider\cf0  oleServiceProvider =\par ??                (\cf4 IOleServiceProvider\cf0 )serviceProvider.GetService(\cf1 typeof\cf0 (\cf4 IOleServiceProvider\cf0 ));\par ??            project.SetSite(oleServiceProvider);\par ??            \cf1 return\cf0  project;\par ??        \}\par ??    \}\par ??\}\par ??}
-->
        </p>
        <div style="FONT-SIZE: 9pt; BACKGROUND: white; COLOR: black; FONT-FAMILY: Courier New">
          <p style="MARGIN: 0px">
            <span style="COLOR: blue">using</span> System;
</p>
          <p style="MARGIN: 0px">
            <span style="COLOR: blue">using</span> System.Runtime.InteropServices;
</p>
          <p style="MARGIN: 0px">
            <span style="COLOR: blue">using</span> Microsoft.VisualStudio.Project;
</p>
          <p style="MARGIN: 0px">
            <span style="COLOR: blue">using</span>
            <span style="COLOR: #2b91af">IOleServiceProvider</span> =
Microsoft.VisualStudio.OLE.Interop.<span style="COLOR: #2b91af">IServiceProvider</span>;
</p>
          <p style="MARGIN: 0px">
 
</p>
          <p style="MARGIN: 0px">
            <span style="COLOR: blue">namespace</span> MyCompany.MyDslProject
</p>
          <p style="MARGIN: 0px">
{
</p>
          <p style="MARGIN: 0px">
    [<span style="COLOR: #2b91af">Guid</span>(<span style="COLOR: #2b91af">GuidList</span>.guidMyDslProjectFactoryString)]
</p>
          <p style="MARGIN: 0px">
    <span style="COLOR: blue">public</span><span style="COLOR: blue">class</span><span style="COLOR: #2b91af">MyDslProjectFactory</span> : <span style="COLOR: #2b91af">ProjectFactory</span></p>
          <p style="MARGIN: 0px">
    {
</p>
          <p style="MARGIN: 0px">
        <span style="COLOR: blue">private</span><span style="COLOR: #2b91af">MyDslProjectPackage</span> m_Package;
</p>
          <p style="MARGIN: 0px">
 
</p>
          <p style="MARGIN: 0px">
        <span style="COLOR: blue">public</span> MyDslProjectFactory(<span style="COLOR: #2b91af">MyDslProjectPackage</span> package)
</p>
          <p style="MARGIN: 0px">
            : <span style="COLOR: blue">base</span>(package)
</p>
          <p style="MARGIN: 0px">
        {
</p>
          <p style="MARGIN: 0px">
            m_Package = package;
</p>
          <p style="MARGIN: 0px">
        }
</p>
          <p style="MARGIN: 0px">
 
</p>
          <p style="MARGIN: 0px">
        <span style="COLOR: blue">protected</span><span style="COLOR: blue">override</span><span style="COLOR: #2b91af">ProjectNode</span> CreateProject()
</p>
          <p style="MARGIN: 0px">
        {
</p>
          <p style="MARGIN: 0px">
            <span style="COLOR: #2b91af">MyDslProjectNode</span> project
= <span style="COLOR: blue">new</span><span style="COLOR: #2b91af">MyDslProjectNode</span>(<span style="COLOR: blue">this</span>.m_Package);
</p>
          <p style="MARGIN: 0px">
            <span style="COLOR: #2b91af">IServiceProvider</span> serviceProvider
= (<span style="COLOR: #2b91af">IServiceProvider</span>)<span style="COLOR: blue">this</span>.m_Package;
</p>
          <p style="MARGIN: 0px">
            <span style="COLOR: #2b91af">IOleServiceProvider</span> oleServiceProvider
=
</p>
          <p style="MARGIN: 0px">
                (<span style="COLOR: #2b91af">IOleServiceProvider</span>)serviceProvider.GetService(<span style="COLOR: blue">typeof</span>(<span style="COLOR: #2b91af">IOleServiceProvider</span>));
</p>
          <p style="MARGIN: 0px">
            project.SetSite(oleServiceProvider);
</p>
          <p style="MARGIN: 0px">
            <span style="COLOR: blue">return</span> project;
</p>
          <p style="MARGIN: 0px">
        }
</p>
          <p style="MARGIN: 0px">
    }
</p>
          <p style="MARGIN: 0px">
}
</p>
        </div>
        <p>
        </p>
        <p>
          <u>5. Change package base class</u>
        </p>
        <p>
Change the base class in “MyDslProjectPackage” class, so that it inherits from ProjectPackage,
as show below:
</p>
        <p>
          <!--
{\rtf1\ansi\ansicpg\lang1024\noproof65001\uc1 \deff0{\fonttbl{\f0\fnil\fcharset0\fprq1 Courier New;}}{\colortbl;??\red0\green0\blue0;\red255\green255\blue255;\red0\green0\blue255;\red43\green145\blue175;\red128\green128\blue128;\red0\green128\blue0;}??\fs20     \cf3 public\cf0  \cf3 sealed\cf0  \cf3 class\cf0  \cf4 MyDslProjectPackage\cf0  : \cf4 ProjectPackage\par ??\cf0     \{\par ??        \cf5 ///\cf6  ...\par ??\cf0     \}\par ??}
-->
        </p>
        <div style="FONT-SIZE: 9pt; BACKGROUND: white; COLOR: black; FONT-FAMILY: Courier New">
          <p style="MARGIN: 0px">
    <span style="COLOR: blue">public</span><span style="COLOR: blue">sealed</span><span style="COLOR: blue">class</span><span style="COLOR: #2b91af">MyDslProjectPackage</span> : <span style="COLOR: #2b91af">ProjectPackage</span></p>
          <p style="MARGIN: 0px">
    {
</p>
          <p style="MARGIN: 0px">
        <span style="COLOR: gray">///</span><span style="COLOR: green"> ...</span></p>
          <p style="MARGIN: 0px">
    }
</p>
        </div>
        <p>
        </p>
        <p>
          <u>6. Register project type</u>
        </p>
        <p>
The project factory must be registered in the Initialize method in the MyDslProjectPackage
class. Add a call to RegisterProjectFactory as shown below:
</p>
        <p>
          <!--
{\rtf1\ansi\ansicpg\lang1024\noproof65001\uc1 \deff0{\fonttbl{\f0\fnil\fcharset0\fprq1 Courier New;}}{\colortbl;??\red0\green0\blue0;\red255\green255\blue255;\red0\green0\blue255;\red43\green145\blue175;\red163\green21\blue21;}??\fs20     \cf3 public\cf0  \cf3 sealed\cf0  \cf3 class\cf0  \cf4 MyDslProjectPackage\cf0  : \cf4 ProjectPackage\par ??\cf0     \{\par ??        \cf3 protected\cf0  \cf3 override\cf0  \cf3 void\cf0  Initialize()\par ??        \{\par ??            \cf4 Trace\cf0 .WriteLine (\cf3 string\cf0 .Format(\cf4 CultureInfo\cf0 .CurrentCulture,\par ??                \cf5 "Entering Initialize() of: \{0\}"\cf0 , \cf3 this\cf0 .ToString()));\par ??            \cf3 base\cf0 .Initialize();\par ??            \cf3 this\cf0 .RegisterProjectFactory(\cf3 new\cf0  \cf4 MyDslProjectFactory\cf0 (\cf3 this\cf0 ));\par ??        \}\par ??    \}\par ??}
-->
        </p>
        <div style="FONT-SIZE: 9pt; BACKGROUND: white; COLOR: black; FONT-FAMILY: Courier New">
          <p style="MARGIN: 0px">
    <span style="COLOR: blue">public</span><span style="COLOR: blue">sealed</span><span style="COLOR: blue">class</span><span style="COLOR: #2b91af">MyDslProjectPackage</span> : <span style="COLOR: #2b91af">ProjectPackage</span></p>
          <p style="MARGIN: 0px">
    {
</p>
          <p style="MARGIN: 0px">
        <span style="COLOR: blue">protected</span><span style="COLOR: blue">override</span><span style="COLOR: blue">void</span> Initialize()
</p>
          <p style="MARGIN: 0px">
        {
</p>
          <p style="MARGIN: 0px">
            <span style="COLOR: #2b91af">Trace</span>.WriteLine
(<span style="COLOR: blue">string</span>.Format(<span style="COLOR: #2b91af">CultureInfo</span>.CurrentCulture,
</p>
          <p style="MARGIN: 0px">
                <span style="COLOR: #a31515">"Entering
Initialize() of: {0}"</span>, <span style="COLOR: blue">this</span>.ToString()));
</p>
          <p style="MARGIN: 0px">
            <span style="COLOR: blue">base</span>.Initialize();
</p>
          <p style="MARGIN: 0px">
            <strong>            <span style="COLOR: blue">this</span>.RegisterProjectFactory(<span style="COLOR: blue">new</span><span style="COLOR: #2b91af">MyDslProjectFactory</span>(<span style="COLOR: blue">this</span>));</strong>
          </p>
          <p style="MARGIN: 0px">
        }
</p>
          <p style="MARGIN: 0px">
    }
</p>
        </div>
        <p>
        </p>
        <p>
          <u>7. Adding ProvideProjectFactory attribute</u>
        </p>
        <p>
A package implementing a project type must be attributed with the “ProvideProjectFactory”
attribute. Add a “ProvideProjectFactory” attribute to the “MyDslProjectPackage” class
as show below:
</p>
        <p>
          <!--
{\rtf1\ansi\ansicpg\lang1024\noproof65001\uc1 \deff0{\fonttbl{\f0\fnil\fcharset0\fprq1 Courier New;}}{\colortbl;??\red0\green0\blue0;\red255\green255\blue255;\red43\green145\blue175;\red0\green0\blue255;\red163\green21\blue21;}??\fs20     [\cf3 ProvideProjectFactory\cf0 (\cf4 typeof\cf0 (\cf3 MyDslProjectFactory\cf0 ),\par ??        \cf5 "MyDsl Project"\cf0 ,\par ??        \cf5 "MyDsl Project Files (*.mydslproj);*.mydslproj"\cf0 , \par ??        \cf5 "mydslproj"\cf0 , \cf5 "mydslproj"\cf0 ,\par ??        \cf5 @"\\\\null"\cf0 ,\par ??        LanguageVsTemplate = \cf5 "MyDslProject"\cf0 ,\par ??        NewProjectRequireNewFolderVsTemplate = \cf4 true\cf0 )]\par ??    \cf4 public\cf0  \cf4 sealed\cf0  \cf4 class\cf0  \cf3 MyDslProjectPackage\cf0  : \cf3 ProjectPackage\par ??\cf0     \{\par ??    \}\par ??}
-->
        </p>
        <div style="FONT-SIZE: 9pt; BACKGROUND: white; COLOR: black; FONT-FAMILY: Courier New">
          <p style="MARGIN: 0px">
            <strong>    [<span style="COLOR: #2b91af">ProvideProjectFactory</span>(<span style="COLOR: blue">typeof</span>(<span style="COLOR: #2b91af">MyDslProjectFactory</span>),</strong>
          </p>
          <p style="MARGIN: 0px">
            <strong>        <span style="COLOR: #a31515">"MyDsl
Project"</span>,</strong>
          </p>
          <p style="MARGIN: 0px">
            <strong>        <span style="COLOR: #a31515">"MyDsl
Project Files (*.mydslproj);*.mydslproj"</span>, </strong>
          </p>
          <p style="MARGIN: 0px">
            <strong>        <span style="COLOR: #a31515">"mydslproj"</span>, <span style="COLOR: #a31515">"mydslproj"</span>,</strong>
          </p>
          <p style="MARGIN: 0px">
            <strong>        <span style="COLOR: #a31515">@"\\null"</span>,</strong>
          </p>
          <p style="MARGIN: 0px">
            <strong>        LanguageVsTemplate = <span style="COLOR: #a31515">"MyDslProject"</span>,</strong>
          </p>
          <p style="MARGIN: 0px">
            <strong>        NewProjectRequireNewFolderVsTemplate
= <span style="COLOR: blue">true</span>)]</strong>
          </p>
          <p style="MARGIN: 0px">
    <span style="COLOR: blue">public</span><span style="COLOR: blue">sealed</span><span style="COLOR: blue">class</span><span style="COLOR: #2b91af">MyDslProjectPackage</span> : <span style="COLOR: #2b91af">ProjectPackage</span></p>
          <p style="MARGIN: 0px">
    {
</p>
          <p style="MARGIN: 0px">
    }
</p>
        </div>
        <p>
        </p>
        <p>
          <strong>Adding a project template</strong>
        </p>
        <p>
Finally we have to create a new project template for our custom project type.
</p>
        <p>
          <u>1. Add template folder</u>
        </p>
        <p>
First we have to add a template folder in the “MyDslProject”. Add a folder named “Templates”,
a subfolder named “Projects” and finally a subfolder “MyDslProject”, as show below.
</p>
        <p>
          <img src="http://www.baekdorf.dk/christian/content/binary/64_DSLVSShell_Project_TemplateFolders.png" border="0" />
        </p>
        <p>
          <u>2. Add a DSL item file</u>
        </p>
        <p>
Add an empty text file named “MyDsl1.mydsl1” to the “MyDslProject” folder, as shown
below.
</p>
        <p>
          <img src="http://www.baekdorf.dk/christian/content/binary/65_DSLVSShell_Project_TemplateFile1.png" border="0" />
        </p>
        <p>
          <u>3. Add a project icon</u>
        </p>
        <p>
Add an icon file named “MyDslProject.ico” to the “MyDslProject” folder, as shown below.
</p>
        <p>
          <img src="http://www.baekdorf.dk/christian/content/binary/66_DSLVSShell_Project_TemplateFile2.png" border="0" />
        </p>
        <p>
          <u>4. Add a project file</u>
        </p>
        <p>
Add a project file named “MyDslProject.mydslproj” to the “MyDslProject” folder, with
the content shown below:
</p>
        <p>
          <!--
{\rtf1\ansi\ansicpg\lang1024\noproof65001\uc1 \deff0{\fonttbl{\f0\fnil\fcharset0\fprq1 Courier New;}}{\colortbl;??\red0\green0\blue255;\red255\green255\blue255;\red163\green21\blue21;\red255\green0\blue0;\red0\green0\blue0;}??\fs20 \cf1 &lt;\cf3 Project\cf1  \cf4 InitialTargets\cf1 =\cf0 ""\cf1  \cf4 DefaultTargets\cf1 =\cf0 "\cf1 Build\cf0 "\cf1  \cf4 xmlns\cf1 =\cf0 "\cf1 http://schemas.microsoft.com/developer/msbuild/2003\cf0 "\cf1 &gt;\par ??  &lt;\cf3 PropertyGroup\cf1 &gt;\par ??    &lt;\cf3 SchemaVersion\cf1 &gt;\cf0 2.0\cf1 &lt;/\cf3 SchemaVersion\cf1 &gt;\par ??    &lt;\cf3 ProjectGuid\cf1 &gt;\cf0 \{1584A98D-D032-4709-9AC0-C3F2A8C93857\}\cf1 &lt;/\cf3 ProjectGuid\cf1 &gt;\par ??    &lt;\cf3 OutputPath\cf1 &gt;\cf0 bin\\Debug\\\cf1 &lt;/\cf3 OutputPath\cf1 &gt;\par ??  &lt;/\cf3 PropertyGroup\cf1 &gt;\par ??  &lt;\cf3 ItemGroup\cf1 &gt;\par ??    &lt;\cf3 Content\cf1  \cf4 Include\cf1 =\cf0 "\cf1 MyDsl1.mydsl1\cf0 "\cf1 &gt;\par ??      &lt;\cf3 SubType\cf1 &gt;\cf0 Content\cf1 &lt;/\cf3 SubType\cf1 &gt;\par ??    &lt;/\cf3 Content\cf1 &gt;\par ??  &lt;/\cf3 ItemGroup\cf1 &gt;\par ??  &lt;\cf3 Import\cf1  \cf4 Project\cf1 =\cf0 "\cf1 $(MSBuildToolsPath)\\Microsoft.CSharp.targets\cf0 "\cf1  /&gt;\par ??&lt;/\cf3 Project\cf1 &gt;\par ??}
-->
        </p>
        <div style="FONT-SIZE: 9pt; BACKGROUND: white; COLOR: black; FONT-FAMILY: Courier New">
          <p style="MARGIN: 0px">
            <span style="COLOR: blue">&lt;</span>
            <span style="COLOR: #a31515">Project</span>
            <span style="COLOR: blue">
            </span>
            <span style="COLOR: red">InitialTargets</span>
            <span style="COLOR: blue">=</span>""<span style="COLOR: blue"></span><span style="COLOR: red">DefaultTargets</span><span style="COLOR: blue">=</span>"<span style="COLOR: blue">Build</span>"<span style="COLOR: blue"></span><span style="COLOR: red">xmlns</span><span style="COLOR: blue">=</span>"<span style="COLOR: blue">http://schemas.microsoft.com/developer/msbuild/2003</span>"<span style="COLOR: blue">&gt;</span></p>
          <p style="MARGIN: 0px">
            <span style="COLOR: blue">  &lt;</span>
            <span style="COLOR: #a31515">PropertyGroup</span>
            <span style="COLOR: blue">&gt;</span>
          </p>
          <p style="MARGIN: 0px">
            <span style="COLOR: blue">    &lt;</span>
            <span style="COLOR: #a31515">SchemaVersion</span>
            <span style="COLOR: blue">&gt;</span>2.0<span style="COLOR: blue">&lt;/</span><span style="COLOR: #a31515">SchemaVersion</span><span style="COLOR: blue">&gt;</span></p>
          <p style="MARGIN: 0px">
            <span style="COLOR: blue">    &lt;</span>
            <span style="COLOR: #a31515">ProjectGuid</span>
            <span style="COLOR: blue">&gt;</span>{1584A98D-D032-4709-9AC0-C3F2A8C93857}<span style="COLOR: blue">&lt;/</span><span style="COLOR: #a31515">ProjectGuid</span><span style="COLOR: blue">&gt;</span></p>
          <p style="MARGIN: 0px">
            <span style="COLOR: blue">    &lt;</span>
            <span style="COLOR: #a31515">OutputPath</span>
            <span style="COLOR: blue">&gt;</span>bin\Debug\<span style="COLOR: blue">&lt;/</span><span style="COLOR: #a31515">OutputPath</span><span style="COLOR: blue">&gt;</span></p>
          <p style="MARGIN: 0px">
            <span style="COLOR: blue">  &lt;/</span>
            <span style="COLOR: #a31515">PropertyGroup</span>
            <span style="COLOR: blue">&gt;</span>
          </p>
          <p style="MARGIN: 0px">
            <span style="COLOR: blue">  &lt;</span>
            <span style="COLOR: #a31515">ItemGroup</span>
            <span style="COLOR: blue">&gt;</span>
          </p>
          <p style="MARGIN: 0px">
            <span style="COLOR: blue">    &lt;</span>
            <span style="COLOR: #a31515">Content</span>
            <span style="COLOR: blue">
            </span>
            <span style="COLOR: red">Include</span>
            <span style="COLOR: blue">=</span>"<span style="COLOR: blue">MyDsl1.mydsl1</span>"<span style="COLOR: blue">&gt;</span></p>
          <p style="MARGIN: 0px">
            <span style="COLOR: blue">      &lt;</span>
            <span style="COLOR: #a31515">SubType</span>
            <span style="COLOR: blue">&gt;</span>Content<span style="COLOR: blue">&lt;/</span><span style="COLOR: #a31515">SubType</span><span style="COLOR: blue">&gt;</span></p>
          <p style="MARGIN: 0px">
            <span style="COLOR: blue">    &lt;/</span>
            <span style="COLOR: #a31515">Content</span>
            <span style="COLOR: blue">&gt;</span>
          </p>
          <p style="MARGIN: 0px">
            <span style="COLOR: blue">  &lt;/</span>
            <span style="COLOR: #a31515">ItemGroup</span>
            <span style="COLOR: blue">&gt;</span>
          </p>
          <p style="MARGIN: 0px">
            <span style="COLOR: blue">  &lt;</span>
            <span style="COLOR: #a31515">Import</span>
            <span style="COLOR: blue">
            </span>
            <span style="COLOR: red">Project</span>
            <span style="COLOR: blue">=</span>"<span style="COLOR: blue">$(MSBuildToolsPath)\Microsoft.CSharp.targets</span>"<span style="COLOR: blue"> /&gt;</span></p>
          <p style="MARGIN: 0px">
            <span style="COLOR: blue">&lt;/</span>
            <span style="COLOR: #a31515">Project</span>
            <span style="COLOR: blue">&gt;</span>
          </p>
        </div>
        <p>
        </p>
        <p>
          <img src="http://www.baekdorf.dk/christian/content/binary/67_DSLVSShell_Project_TemplateFile31.png" border="0" />
        </p>
        <p>
          <u>5. Add a vstemplate file</u>
        </p>
        <p>
Add a project file named “MyDslProject.vstemplate” to the “MyDslProject” folder, with
the content shown below:
</p>
        <p>
          <!--
{\rtf1\ansi\ansicpg\lang1024\noproof65001\uc1 \deff0{\fonttbl{\f0\fnil\fcharset0\fprq1 Courier New;}}{\colortbl;??\red0\green0\blue255;\red255\green255\blue255;\red163\green21\blue21;\red255\green0\blue0;\red0\green0\blue0;}??\fs20 \cf1 &lt;\cf3 VSTemplate\cf1  \cf4 Version\cf1 =\cf0 "\cf1 2.0.0\cf0 "\cf1  \cf4 Type\cf1 =\cf0 "\cf1 Project\cf0 "\par ??\cf1     \cf4 xmlns\cf1 =\cf0 "\cf1 http://schemas.microsoft.com/developer/vstemplate/2005\cf0 "\cf1 &gt;\par ??  &lt;\cf3 TemplateData\cf1 &gt;\par ??    &lt;\cf3 Name\cf1 &gt;\cf0 MyDsl Project\cf1 &lt;/\cf3 Name\cf1 &gt;\par ??    &lt;\cf3 Description\cf1 &gt;\cf0 Create a new MyDsl project\cf1 &lt;/\cf3 Description\cf1 &gt;\par ??    &lt;\cf3 ProjectType\cf1 &gt;\cf0 MyDslProject\cf1 &lt;/\cf3 ProjectType\cf1 &gt;\par ??    &lt;\cf3 SortOrder\cf1 &gt;\cf0 1000\cf1 &lt;/\cf3 SortOrder\cf1 &gt;\par ??    &lt;\cf3 CreateNewFolder\cf1 &gt;\cf0 true\cf1 &lt;/\cf3 CreateNewFolder\cf1 &gt;\par ??    &lt;\cf3 DefaultName\cf1 &gt;\cf0 MyDslProject\cf1 &lt;/\cf3 DefaultName\cf1 &gt;\par ??    &lt;\cf3 ProvideDefaultName\cf1 &gt;\cf0 true\cf1 &lt;/\cf3 ProvideDefaultName\cf1 &gt;\par ??    &lt;\cf3 LocationField\cf1 &gt;\cf0 Enabled\cf1 &lt;/\cf3 LocationField\cf1 &gt;\par ??    &lt;\cf3 EnableLocationBrowseButton\cf1 &gt;\cf0 true\cf1 &lt;/\cf3 EnableLocationBrowseButton\cf1 &gt;\par ??    &lt;\cf3 Icon\cf1 &gt;\cf0 MyDslProject.ico\cf1 &lt;/\cf3 Icon\cf1 &gt;\par ??  &lt;/\cf3 TemplateData\cf1 &gt;\par ??  &lt;\cf3 TemplateContent\cf1 &gt;\par ??    &lt;\cf3 Project\cf1  \cf4 TargetFileName\cf1 =\cf0 "\cf1 MyDslProject.mydslproj\cf0 "\cf1  \cf4 File\cf1 =\cf0 "\cf1 MyDslProject.mydslproj\cf0 "\cf1  \cf4 ReplaceParameters\cf1 =\cf0 "\cf1 true\cf0 "\cf1 &gt;\par ??      &lt;\cf3 ProjectItem\cf1  \cf4 TargetFileName\cf1 =\cf0 "\cf1 MyDsl1.mydsl1\cf0 "\cf1 &gt;\cf0 MyDsl1.mydsl1\cf1 &lt;/\cf3 ProjectItem\cf1 &gt;\par ??    &lt;/\cf3 Project\cf1 &gt;\par ??  &lt;/\cf3 TemplateContent\cf1 &gt;\par ??&lt;/\cf3 VSTemplate\cf1 &gt;\par ??}
-->
        </p>
        <div style="FONT-SIZE: 9pt; BACKGROUND: white; COLOR: black; FONT-FAMILY: Courier New">
          <p style="MARGIN: 0px">
            <span style="COLOR: blue">&lt;</span>
            <span style="COLOR: #a31515">VSTemplate</span>
            <span style="COLOR: blue">
            </span>
            <span style="COLOR: red">Version</span>
            <span style="COLOR: blue">=</span>"<span style="COLOR: blue">2.0.0</span>"<span style="COLOR: blue"></span><span style="COLOR: red">Type</span><span style="COLOR: blue">=</span>"<span style="COLOR: blue">Project</span>"
</p>
          <p style="MARGIN: 0px">
            <span style="COLOR: blue">    </span>
            <span style="COLOR: red">xmlns</span>
            <span style="COLOR: blue">=</span>"<span style="COLOR: blue">http://schemas.microsoft.com/developer/vstemplate/2005</span>"<span style="COLOR: blue">&gt;</span></p>
          <p style="MARGIN: 0px">
            <span style="COLOR: blue">  &lt;</span>
            <span style="COLOR: #a31515">TemplateData</span>
            <span style="COLOR: blue">&gt;</span>
          </p>
          <p style="MARGIN: 0px">
            <span style="COLOR: blue">    &lt;</span>
            <span style="COLOR: #a31515">Name</span>
            <span style="COLOR: blue">&gt;</span>MyDsl
Project<span style="COLOR: blue">&lt;/</span><span style="COLOR: #a31515">Name</span><span style="COLOR: blue">&gt;</span></p>
          <p style="MARGIN: 0px">
            <span style="COLOR: blue">    &lt;</span>
            <span style="COLOR: #a31515">Description</span>
            <span style="COLOR: blue">&gt;</span>Create
a new MyDsl project<span style="COLOR: blue">&lt;/</span><span style="COLOR: #a31515">Description</span><span style="COLOR: blue">&gt;</span></p>
          <p style="MARGIN: 0px">
            <span style="COLOR: blue">    &lt;</span>
            <span style="COLOR: #a31515">ProjectType</span>
            <span style="COLOR: blue">&gt;</span>MyDslProject<span style="COLOR: blue">&lt;/</span><span style="COLOR: #a31515">ProjectType</span><span style="COLOR: blue">&gt;</span></p>
          <p style="MARGIN: 0px">
            <span style="COLOR: blue">    &lt;</span>
            <span style="COLOR: #a31515">SortOrder</span>
            <span style="COLOR: blue">&gt;</span>1000<span style="COLOR: blue">&lt;/</span><span style="COLOR: #a31515">SortOrder</span><span style="COLOR: blue">&gt;</span></p>
          <p style="MARGIN: 0px">
            <span style="COLOR: blue">    &lt;</span>
            <span style="COLOR: #a31515">CreateNewFolder</span>
            <span style="COLOR: blue">&gt;</span>true<span style="COLOR: blue">&lt;/</span><span style="COLOR: #a31515">CreateNewFolder</span><span style="COLOR: blue">&gt;</span></p>
          <p style="MARGIN: 0px">
            <span style="COLOR: blue">    &lt;</span>
            <span style="COLOR: #a31515">DefaultName</span>
            <span style="COLOR: blue">&gt;</span>MyDslProject<span style="COLOR: blue">&lt;/</span><span style="COLOR: #a31515">DefaultName</span><span style="COLOR: blue">&gt;</span></p>
          <p style="MARGIN: 0px">
            <span style="COLOR: blue">    &lt;</span>
            <span style="COLOR: #a31515">ProvideDefaultName</span>
            <span style="COLOR: blue">&gt;</span>true<span style="COLOR: blue">&lt;/</span><span style="COLOR: #a31515">ProvideDefaultName</span><span style="COLOR: blue">&gt;</span></p>
          <p style="MARGIN: 0px">
            <span style="COLOR: blue">    &lt;</span>
            <span style="COLOR: #a31515">LocationField</span>
            <span style="COLOR: blue">&gt;</span>Enabled<span style="COLOR: blue">&lt;/</span><span style="COLOR: #a31515">LocationField</span><span style="COLOR: blue">&gt;</span></p>
          <p style="MARGIN: 0px">
            <span style="COLOR: blue">    &lt;</span>
            <span style="COLOR: #a31515">EnableLocationBrowseButton</span>
            <span style="COLOR: blue">&gt;</span>true<span style="COLOR: blue">&lt;/</span><span style="COLOR: #a31515">EnableLocationBrowseButton</span><span style="COLOR: blue">&gt;</span></p>
          <p style="MARGIN: 0px">
            <span style="COLOR: blue">    &lt;</span>
            <span style="COLOR: #a31515">Icon</span>
            <span style="COLOR: blue">&gt;</span>MyDslProject.ico<span style="COLOR: blue">&lt;/</span><span style="COLOR: #a31515">Icon</span><span style="COLOR: blue">&gt;</span></p>
          <p style="MARGIN: 0px">
            <span style="COLOR: blue">  &lt;/</span>
            <span style="COLOR: #a31515">TemplateData</span>
            <span style="COLOR: blue">&gt;</span>
          </p>
          <p style="MARGIN: 0px">
            <span style="COLOR: blue">  &lt;</span>
            <span style="COLOR: #a31515">TemplateContent</span>
            <span style="COLOR: blue">&gt;</span>
          </p>
          <p style="MARGIN: 0px">
            <span style="COLOR: blue">    &lt;</span>
            <span style="COLOR: #a31515">Project</span>
            <span style="COLOR: blue">
            </span>
            <span style="COLOR: red">TargetFileName</span>
            <span style="COLOR: blue">=</span>"<span style="COLOR: blue">MyDslProject.mydslproj</span>"<span style="COLOR: blue"></span><span style="COLOR: red">File</span><span style="COLOR: blue">=</span>"<span style="COLOR: blue">MyDslProject.mydslproj</span>"<span style="COLOR: blue"></span><span style="COLOR: red">ReplaceParameters</span><span style="COLOR: blue">=</span>"<span style="COLOR: blue">true</span>"<span style="COLOR: blue">&gt;</span></p>
          <p style="MARGIN: 0px">
            <span style="COLOR: blue">      &lt;</span>
            <span style="COLOR: #a31515">ProjectItem</span>
            <span style="COLOR: blue">
            </span>
            <span style="COLOR: red">TargetFileName</span>
            <span style="COLOR: blue">=</span>"<span style="COLOR: blue">MyDsl1.mydsl1</span>"<span style="COLOR: blue">&gt;</span>MyDsl1.mydsl1<span style="COLOR: blue">&lt;/</span><span style="COLOR: #a31515">ProjectItem</span><span style="COLOR: blue">&gt;</span></p>
          <p style="MARGIN: 0px">
            <span style="COLOR: blue">    &lt;/</span>
            <span style="COLOR: #a31515">Project</span>
            <span style="COLOR: blue">&gt;</span>
          </p>
          <p style="MARGIN: 0px">
            <span style="COLOR: blue">  &lt;/</span>
            <span style="COLOR: #a31515">TemplateContent</span>
            <span style="COLOR: blue">&gt;</span>
          </p>
          <p style="MARGIN: 0px">
            <span style="COLOR: blue">&lt;/</span>
            <span style="COLOR: #a31515">VSTemplate</span>
            <span style="COLOR: blue">&gt;</span>
          </p>
        </div>
        <p>
        </p>
        <p>
          <img src="http://www.baekdorf.dk/christian/content/binary/68_DSLVSShell_Project_TemplateFile4.png" border="0" />
        </p>
        <p>
          <u>6. Set build action</u>
        </p>
        <p>
Select the four template files added in the above steps and set the build action to
ZipProject.
</p>
        <p>
          <img src="http://www.baekdorf.dk/christian/content/binary/69_DSLVSShell_Project_TemplateZipAction.png" border="0" />
        </p>
        <p>
          <u>7. Add copy events</u>
        </p>
        <p>
Add an after build action to copy the template file to the output folder. Open the
“MyDslProject.csproj” file so you can edit it directly, and add the XML shown below:
</p>
        <p>
          <!--
{\rtf1\ansi\ansicpg\lang1024\noproof65001\uc1 \deff0{\fonttbl{\f0\fnil\fcharset0\fprq1 Courier New;}}{\colortbl;??\red0\green0\blue255;\red255\green255\blue255;\red163\green21\blue21;\red255\green0\blue0;\red0\green0\blue0;}??\fs20 \cf1   &lt;\cf3 Target\cf1  \cf4 Name\cf1 =\cf0 "\cf1 AfterBuild\cf0 "\cf1 &gt;\par ??    &lt;\cf3 MakeDir\cf1  \cf4 Directories\cf1 =\cf0 "\cf1 $(SolutionDir)$(Configuration)\\ProjectTemplates\cf0 "\cf1  /&gt;\par ??    &lt;\cf3 MakeDir\cf1  \cf4 Directories\cf1 =\cf0 "\cf1 $(SolutionDir)$(Configuration)\\ItemTemplates\cf0 "\cf1  /&gt;\par ??    &lt;\cf3 Copy\cf1  \cf4 SourceFiles\cf1 =\cf0 "\cf1 @(IntermediateZipProject)\cf0 "\cf1  \cf4 DestinationFolder\cf1 =\cf0 "\cf1 $(SolutionDir)$(Configuration)\\ProjectTemplates\cf0 "\cf1  /&gt;\par ??    &lt;\cf3 Copy\cf1  \cf4 SourceFiles\cf1 =\cf0 "\cf1 @(IntermediateZipItem)\cf0 "\cf1  \cf4 DestinationFolder\cf1 =\cf0 "\cf1 $(SolutionDir)$(Configuration)\\ItemTemplates\cf0 "\cf1  /&gt;\par ??  &lt;/\cf3 Target\cf1 &gt;\par ??}
-->
        </p>
        <div style="FONT-SIZE: 9pt; BACKGROUND: white; COLOR: black; FONT-FAMILY: Courier New">
          <p style="MARGIN: 0px">
            <span style="COLOR: blue">  &lt;</span>
            <span style="COLOR: #a31515">Target</span>
            <span style="COLOR: blue">
            </span>
            <span style="COLOR: red">Name</span>
            <span style="COLOR: blue">=</span>"<span style="COLOR: blue">AfterBuild</span>"<span style="COLOR: blue">&gt;</span></p>
          <p style="MARGIN: 0px">
            <span style="COLOR: blue">    &lt;</span>
            <span style="COLOR: #a31515">MakeDir</span>
            <span style="COLOR: blue">
            </span>
            <span style="COLOR: red">Directories</span>
            <span style="COLOR: blue">=</span>"<span style="COLOR: blue">$(SolutionDir)$(Configuration)\ProjectTemplates</span>"<span style="COLOR: blue"> /&gt;</span></p>
          <p style="MARGIN: 0px">
            <span style="COLOR: blue">    &lt;</span>
            <span style="COLOR: #a31515">MakeDir</span>
            <span style="COLOR: blue">
            </span>
            <span style="COLOR: red">Directories</span>
            <span style="COLOR: blue">=</span>"<span style="COLOR: blue">$(SolutionDir)$(Configuration)\ItemTemplates</span>"<span style="COLOR: blue"> /&gt;</span></p>
          <p style="MARGIN: 0px">
            <span style="COLOR: blue">    &lt;</span>
            <span style="COLOR: #a31515">Copy</span>
            <span style="COLOR: blue">
            </span>
            <span style="COLOR: red">SourceFiles</span>
            <span style="COLOR: blue">=</span>"<span style="COLOR: blue">@(IntermediateZipProject)</span>"<span style="COLOR: blue"></span><span style="COLOR: red">DestinationFolder</span><span style="COLOR: blue">=</span>"<span style="COLOR: blue">$(SolutionDir)$(Configuration)\ProjectTemplates</span>"<span style="COLOR: blue"> /&gt;</span></p>
          <p style="MARGIN: 0px">
            <span style="COLOR: blue">    &lt;</span>
            <span style="COLOR: #a31515">Copy</span>
            <span style="COLOR: blue">
            </span>
            <span style="COLOR: red">SourceFiles</span>
            <span style="COLOR: blue">=</span>"<span style="COLOR: blue">@(IntermediateZipItem)</span>"<span style="COLOR: blue"></span><span style="COLOR: red">DestinationFolder</span><span style="COLOR: blue">=</span>"<span style="COLOR: blue">$(SolutionDir)$(Configuration)\ItemTemplates</span>"<span style="COLOR: blue"> /&gt;</span></p>
          <p style="MARGIN: 0px">
            <span style="COLOR: blue">  &lt;/</span>
            <span style="COLOR: #a31515">Target</span>
            <span style="COLOR: blue">&gt;</span>
          </p>
        </div>
        <p>
        </p>
        <p>
          <img src="http://www.baekdorf.dk/christian/content/binary/70_DSLVSShell_Project_TemplateCopyEvents.png" border="0" />
        </p>
        <p>
          <u>8. Specify template folder</u>
        </p>
        <p>
The Shell application needs to know where to look for templates, so you have to specify
the template folders.
</p>
        <p>
Open the “MyDslShell.pkgdef” in the “MyDslShell” project and append the following
in to bottom of the file:
</p>
        <p>
          <!--
{\rtf1\ansi\ansicpg\lang1024\noproof1252\uc1 \deff0{\fonttbl{\f0\fnil\fcharset0\fprq1 Courier New;}}{\colortbl;??\red0\green0\blue0;\red255\green255\blue255;}??\fs20 [$RootKey$\\VSTemplate\\Project]\par ??"UserFolder"="$RootFolder$\\ProjectTemplates"\par ??"CacheFolder"="$RootFolder$\\ProjectTemplatesCache"\par ??\par ??[$RootKey$\\VSTemplate\\Item]\par ??"UserFolder"="$RootFolder$\\ItemTemplates"\par ??"CacheFolder"="$RootFolder$\\ItemTemplatesCache"\par ??}
-->
        </p>
        <div style="FONT-SIZE: 9pt; BACKGROUND: white; COLOR: black; FONT-FAMILY: Courier New">
          <p style="MARGIN: 0px">
[$RootKey$\VSTemplate\Project]
</p>
          <p style="MARGIN: 0px">
"UserFolder"="$RootFolder$\ProjectTemplates"
</p>
          <p style="MARGIN: 0px">
"CacheFolder"="$RootFolder$\ProjectTemplatesCache"
</p>
          <p style="MARGIN: 0px">
 
</p>
          <p style="MARGIN: 0px">
[$RootKey$\VSTemplate\Item]
</p>
          <p style="MARGIN: 0px">
"UserFolder"="$RootFolder$\ItemTemplates"
</p>
          <p style="MARGIN: 0px">
"CacheFolder"="$RootFolder$\ItemTemplatesCache"
</p>
        </div>
        <p>
        </p>
        <p>
          <img src="http://www.baekdorf.dk/christian/content/binary/71_DSLVSShell_Project_TemplateTemplateFolder.png" border="0" />
        </p>
        <p>
          <strong>Testing the project</strong>
        </p>
        <p>
Everything should now be in place and we are ready to test the new custom project
type. 
</p>
        <p>
          <u>1. Building the solution</u>
        </p>
        <p>
Rebuild the entire solution. After rebuilding completes check the output folder (e.g.
), it should look as shown below.
</p>
        <p>
          <img src="http://www.baekdorf.dk/christian/content/binary/72_DSLVSShell_Project_TestDebugFolder.png" border="0" />
        </p>
        <p>
          <u>2. Running the application</u>
        </p>
        <p>
Run the solution and select File -&gt; New -&gt; Project on the menu and you should
see the new project type as shown below.
</p>
        <p>
          <img src="http://www.baekdorf.dk/christian/content/binary/73_DSLVSShell_Project_TestNewProject.png" border="0" />
        </p>
        <p>
          <u>3. Create a new project</u>
        </p>
        <p>
Choose OK in the new project and you should get a new project with a DSL file as shown
below.
</p>
        <p>
          <img src="http://www.baekdorf.dk/christian/content/binary/74_DSLVSShell_Project_TestSample.png" border="0" />
        </p>
        <p>
You can now start use the DSL and create diagrams.
</p>
        <p>
          <strong>Summary</strong>
        </p>
        <p>
This end the fifth post about adding custom project type to the Shell application,
next step is about creating a setup project for the entire Shell application, so it
can be deployed.
</p>
        <p>
Next step: Coming soon!
</p>
        <p>
Download: <a href="http://www.baekdorf.dk/christian/content/binary/DslToolsAndVsShell-05.zip" target="_blank">DslToolsAndVsShell-05.zip
(7 MB)</a></p>
        <img width="0" height="0" src="http://www.baekdorf.dk/christian/aggbug.ashx?id=726b5c35-6660-43aa-a25b-d105f9ccf50e" />
      </body>
      <title>DSL and Visual Studio Shell tutorial: Creating a custom project type</title>
      <guid isPermaLink="false">http://www.baekdorf.dk/christian/PermaLink,guid,726b5c35-6660-43aa-a25b-d105f9ccf50e.aspx</guid>
      <link>http://www.baekdorf.dk/christian/2008/10/08/DSLAndVisualStudioShellTutorialCreatingACustomProjectType.aspx</link>
      <pubDate>Wed, 08 Oct 2008 19:04:16 GMT</pubDate>
      <description>&lt;p&gt;
This post is part of a &lt;a href="http://www.baekdorf.dk/christian/2008/09/24/DSLToolsAndVisualStudio2008IsolatedShellTutorial.aspx"&gt;larger
tutorial on DSL Tools and Visual Studio 2008 Isolated Shell&lt;/a&gt;, in this post I will
go through the steps to add a custom project type to the Shell application. 
&lt;/p&gt;
&lt;p&gt;
Previous step: &lt;a href="http://www.baekdorf.dk/christian/2008/10/01/DSLAndVisualStudioShellTutorialAddingTheDSLToTheShell.aspx"&gt;Adding
the DSL to the Shell&lt;/a&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;strong&gt;Creating a new Visual Studio Integration Package&lt;/strong&gt;
&lt;/p&gt;
&lt;p&gt;
A custom project types is implemented as a Visual Studio Integration Package, so the
first step is to add a new integration package to the Shell solution.
&lt;/p&gt;
&lt;p&gt;
&lt;u&gt;1. New project&lt;/u&gt;
&lt;/p&gt;
&lt;p&gt;
Choose Add New Project and select the Visual Studio Integration Package project template.
&lt;/p&gt;
&lt;p&gt;
Name the project “MyDslProject” and accept the default location.
&lt;/p&gt;
&lt;p&gt;
&lt;img src="http://www.baekdorf.dk/christian/content/binary/45_DSLVSShell_Project_NewProject.png" border=0&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;u&gt;2. Welcome page&lt;/u&gt;
&lt;/p&gt;
&lt;p&gt;
Just click next
&lt;/p&gt;
&lt;p&gt;
&lt;img src="http://www.baekdorf.dk/christian/content/binary/46_DSLVSShell_Project_Wizard0.png" border=0&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;u&gt;3. Choose programming language and strong name key&lt;/u&gt;
&lt;/p&gt;
&lt;p&gt;
Choose C# as programming language and just create a new strong name key.
&lt;/p&gt;
&lt;p&gt;
&lt;img src="http://www.baekdorf.dk/christian/content/binary/47_DSLVSShell_Project_Wizard1.png" border=0&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;u&gt;4. Company name and package name&lt;/u&gt;
&lt;/p&gt;
&lt;p&gt;
Specify company name and package name as shown below
&lt;/p&gt;
&lt;p&gt;
&lt;img src="http://www.baekdorf.dk/christian/content/binary/48_DSLVSShell_Project_Wizard2.png" border=0&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;u&gt;5. Testing project&lt;/u&gt;
&lt;/p&gt;
&lt;p&gt;
Deselect both Integration Test Project and Unit Test Project.
&lt;/p&gt;
&lt;p&gt;
Press Finish to create the project
&lt;/p&gt;
&lt;p&gt;
&lt;img src="http://www.baekdorf.dk/christian/content/binary/49_DSLVSShell_Project_Wizard3.png" border=0&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;u&gt;6. Resulting solution&lt;/u&gt;
&lt;/p&gt;
&lt;p&gt;
The solution should now look as shown below.
&lt;/p&gt;
&lt;p&gt;
&lt;img src="http://www.baekdorf.dk/christian/content/binary/51_DSLVSShell_Project_JustAdded.png" border=0&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;u&gt;7. Shell Dependencies&lt;/u&gt;
&lt;/p&gt;
&lt;p&gt;
Now set the shell dependencies for the “MyDslShell” project, so the project will depend
on “MyDslProject”. Right-click “MyDslShell” project and choose “Shell Dependencies…”.
&lt;/p&gt;
&lt;p&gt;
&lt;img src="http://www.baekdorf.dk/christian/content/binary/52_DSLVSShell_Project_ShellDependencies.png" border=0&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;strong&gt;Adding a Package Load Key (PLK)&lt;/strong&gt;
&lt;/p&gt;
&lt;p&gt;
The “MyDslProject” is a Visual Studio integration package, so we need to add a Package
Load Key (PLK) to the project.
&lt;/p&gt;
&lt;p&gt;
&lt;u&gt;1. Gathering necessary information for obtaining a PLK &lt;/u&gt;
&lt;/p&gt;
&lt;p&gt;
To obtain a PLK you will need the following information:
&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
Company name 
&lt;li&gt;
Package name 
&lt;li&gt;
Package Guid 
&lt;li&gt;
Package version&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;
The first part of the information can be found in “MyDslProjectPackage.cs” file, as
shown below
&lt;/p&gt;
&lt;p&gt;
&lt;img src="http://www.baekdorf.dk/christian/content/binary/53_DSLVSShell_Project_PlkInfo1.png" border=0&gt;
&lt;/p&gt;
&lt;p&gt;
The package Guid can be found in “Guids.cs”
&lt;/p&gt;
&lt;p&gt;
&lt;img src="http://www.baekdorf.dk/christian/content/binary/54_DSLVSShell_Project_PlkInfo2.png" border=0&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;u&gt;2. Obtaining a Package Load Key (PLK)&lt;/u&gt;
&lt;/p&gt;
&lt;p&gt;
You can obtain a Package Load Key (PLK) from MSDN: &lt;a href="http://msdn.microsoft.com/en-us/vsx/cc655795.aspx" target=_blank&gt;Generate
Load Keys&lt;/a&gt;
&lt;/p&gt;
&lt;p&gt;
Enter the information about your package; choose “Standard” as Min. Product Edition
and “Visual Studio 2008” as min. VS Version. Finally press “Generate PLK”.
&lt;/p&gt;
&lt;p&gt;
&lt;img src="http://www.baekdorf.dk/christian/content/binary/55_DSLVSShell_Project_PlkGenerate.png" border=0&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;u&gt;3. Adding the Package Load Key (PLK) to MyDslProject&lt;/u&gt;
&lt;/p&gt;
&lt;p&gt;
We have to add the PLK to the “MyDslProject” projects resource file “VSPackage.resx”.
Insert in in the entry with “1” as name without any newlines.
&lt;/p&gt;
&lt;p&gt;
&lt;img src="http://www.baekdorf.dk/christian/content/binary/56_DSLVSShell_Project_PlkAdd.png" border=0&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;strong&gt;Integrating Managed Package Framework for Projects&lt;/strong&gt;
&lt;/p&gt;
&lt;p&gt;
Next we have to integrate the Managed Package Framework for Projects into the “MyDslProject”
project. This we will do be manually editing the “MyDslProject.csproj” in it’s XML
form. If you have &lt;a href="http://code.msdn.microsoft.com/PowerCommands" target=_blank&gt;Power
Commands for Visual Studio 2008&lt;/a&gt; installed you can right-click the project and
choose Edit Project File.
&lt;/p&gt;
&lt;p&gt;
&lt;u&gt;1. Editing the project file&lt;/u&gt;
&lt;/p&gt;
&lt;p&gt;
First you will have to add the line shown below:
&lt;/p&gt;
&lt;p&gt;
&lt;!--
{\rtf1\ansi\ansicpg\lang1024\noproof65001\uc1 \deff0{\fonttbl{\f0\fnil\fcharset0\fprq1 Courier New;}}{\colortbl;??\red0\green0\blue255;\red255\green255\blue255;\red163\green21\blue21;\red0\green0\blue0;}??\fs20 \cf1     &amp;lt;\cf3 ProjectBasePath\cf1 &amp;gt;\cf0 ..\\..\\MPFProj\\9.0\\Src\\CSharp\cf1 &amp;lt;/\cf3 ProjectBasePath\cf1 &amp;gt;\par ??}
--&gt;
&lt;div style="FONT-SIZE: 9pt; BACKGROUND: white; COLOR: black; FONT-FAMILY: Courier New"&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: blue"&gt;&amp;nbsp; &amp;nbsp; &amp;lt;&lt;/span&gt;&lt;span style="COLOR: #a31515"&gt;ProjectBasePath&lt;/span&gt;&lt;span style="COLOR: blue"&gt;&amp;gt;&lt;/span&gt;..\..\MPFProj\9.0\Src\CSharp&lt;span style="COLOR: blue"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="COLOR: #a31515"&gt;ProjectBasePath&lt;/span&gt;&lt;span style="COLOR: blue"&gt;&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;/div&gt;
&lt;p&gt;
&lt;img src="http://www.baekdorf.dk/christian/content/binary/57_DSLVSShell_Project_ChangeProj1.png" border=0&gt;
&lt;/p&gt;
&lt;p&gt;
Then add the line below as shown below:
&lt;/p&gt;
&lt;p&gt;
&lt;!--
{\rtf1\ansi\ansicpg\lang1024\noproof65001\uc1 \deff0{\fonttbl{\f0\fnil\fcharset0\fprq1 Courier New;}}{\colortbl;??\red0\green0\blue255;\red255\green255\blue255;\red163\green21\blue21;\red255\green0\blue0;\red0\green0\blue0;}??\fs20 \cf1   &amp;lt;\cf3 Import\cf1  \cf4 Project\cf1 =\cf0 "\cf1 $(ProjectBasePath)\\ProjectBase.Files\cf0 "\cf1  /&amp;gt;}
--&gt;
&lt;div style="FONT-SIZE: 9pt; BACKGROUND: white; COLOR: black; FONT-FAMILY: Courier New"&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: blue"&gt;&amp;nbsp; &amp;lt;&lt;/span&gt;&lt;span style="COLOR: #a31515"&gt;Import&lt;/span&gt;&lt;span style="COLOR: blue"&gt; &lt;/span&gt;&lt;span style="COLOR: red"&gt;Project&lt;/span&gt;&lt;span style="COLOR: blue"&gt;=&lt;/span&gt;"&lt;span style="COLOR: blue"&gt;$(ProjectBasePath)\ProjectBase.Files&lt;/span&gt;"&lt;span style="COLOR: blue"&gt; /&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;/div&gt;
&lt;p&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;img src="http://www.baekdorf.dk/christian/content/binary/58_DSLVSShell_Project_ChangeProj2.png" border=0&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;u&gt;2. Reload the project in Visual Studio&lt;/u&gt;
&lt;/p&gt;
&lt;p&gt;
When reloading the project, you will get a warning as show below. Just choose Load
project normally.
&lt;/p&gt;
&lt;p&gt;
&lt;img src="http://www.baekdorf.dk/christian/content/binary/59_DSLVSShell_Project_SecurityWarning.png" border=0&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;u&gt;3. Adding required reference&lt;/u&gt;
&lt;/p&gt;
&lt;p&gt;
The Managed Package Framework for Projects uses some extra assemblies, which we need
to reference before the project can compile.
&lt;/p&gt;
&lt;p&gt;
Add a reference to EnvDTE, as show below.
&lt;/p&gt;
&lt;p&gt;
&lt;img src="http://www.baekdorf.dk/christian/content/binary/60_DSLVSShell_Project_AddRef1.png" border=0&gt;
&lt;/p&gt;
&lt;p&gt;
Add a reference to Microsoft.VisualStudio.Designer.Interfaces, as show below.
&lt;/p&gt;
&lt;p&gt;
&lt;img src="http://www.baekdorf.dk/christian/content/binary/61_DSLVSShell_Project_AddRef2.png" border=0&gt;
&lt;/p&gt;
&lt;p&gt;
The “MyDslProject” should now be able to compile.
&lt;/p&gt;
&lt;p&gt;
&lt;strong&gt;Implementing the custom project type&lt;/strong&gt;
&lt;/p&gt;
&lt;p&gt;
Now we are ready to implement the new custom project type for the DSL project.
&lt;/p&gt;
&lt;p&gt;
&lt;u&gt;1. Defining a project type Guid&lt;/u&gt;
&lt;/p&gt;
&lt;p&gt;
First we have to define a Guid for our new project type, just generate a new Guid.
&lt;/p&gt;
&lt;p&gt;
Add the new project type Guid to the “Guids.cs” file as show below:
&lt;/p&gt;
&lt;p&gt;
&lt;!--
{\rtf1\ansi\ansicpg\lang1024\noproof65001\uc1 \deff0{\fonttbl{\f0\fnil\fcharset0\fprq1 Courier New;}}{\colortbl;??\red0\green0\blue0;\red255\green255\blue255;\red0\green0\blue255;\red163\green21\blue21;\red43\green145\blue175;}??\fs20     \cf3 public\cf0  \cf3 const\cf0  \cf3 string\cf0  guidMyDslProjectFactoryString =\par ??        \cf4 "1584A98D-D032-4709-9AC0-C3F2A8C93857"\cf0 ;\par ??    \cf3 public\cf0  \cf3 static\cf0  \cf3 readonly\cf0  \cf5 Guid\cf0  guidMyDslProjectFactory =\par ??        \cf3 new\cf0  \cf5 Guid\cf0 (guidMyDslProjectFactoryString);\par ??}
--&gt;
&lt;div style="FONT-SIZE: 9pt; BACKGROUND: white; COLOR: black; FONT-FAMILY: Courier New"&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;public&lt;/span&gt; &lt;span style="COLOR: blue"&gt;const&lt;/span&gt; &lt;span style="COLOR: blue"&gt;string&lt;/span&gt; guidMyDslProjectFactoryString
=
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: #a31515"&gt;"1584A98D-D032-4709-9AC0-C3F2A8C93857"&lt;/span&gt;;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;public&lt;/span&gt; &lt;span style="COLOR: blue"&gt;static&lt;/span&gt; &lt;span style="COLOR: blue"&gt;readonly&lt;/span&gt; &lt;span style="COLOR: #2b91af"&gt;Guid&lt;/span&gt; guidMyDslProjectFactory
=
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;new&lt;/span&gt; &lt;span style="COLOR: #2b91af"&gt;Guid&lt;/span&gt;(guidMyDslProjectFactoryString);
&lt;/p&gt;
&lt;/div&gt;
&lt;p&gt;
&lt;img src="http://www.baekdorf.dk/christian/content/binary/63_DSLVSShell_Project_PrjGuid.png" border=0&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;u&gt;2. Adding factory and node classes&lt;/u&gt;
&lt;/p&gt;
&lt;p&gt;
To implement a custom project we need a factory class for instantiating new projects
and project node class.
&lt;/p&gt;
&lt;p&gt;
Add two C# classes to the “MyDslProjectFactory” and “MyDslProjectNode.cs” to the “MyDslProject”
project. Your solution should then look as shown below.
&lt;/p&gt;
&lt;p&gt;
&lt;img src="http://www.baekdorf.dk/christian/content/binary/62_DSLVSShell_Project_NewClassFiles.png" border=0&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;u&gt;3. Implement the “MyDslProjectNode” class&lt;/u&gt;
&lt;/p&gt;
&lt;p&gt;
Implement a simple project node as shown below:
&lt;/p&gt;
&lt;p&gt;
&lt;!--
{\rtf1\ansi\ansicpg\lang1024\noproof65001\uc1 \deff0{\fonttbl{\f0\fnil\fcharset0\fprq1 Courier New;}}{\colortbl;??\red0\green0\blue0;\red255\green255\blue255;\red43\green145\blue175;\red163\green21\blue21;\red0\green0\blue255;}??\fs20     [\cf3 Guid\cf0 (\cf4 "8D681873-2A8D-442b-82CE-ED96C69D02D7"\cf0 )]\par ??    \cf5 public\cf0  \cf5 class\cf0  \cf3 MyDslProjectNode\cf0  : \cf3 ProjectNode\par ??\cf0     \{\par ??        \cf5 internal\cf0  \cf5 const\cf0  \cf5 string\cf0  ProjectTypeName = \cf4 "MyDslProject"\cf0 ;\par ??        \cf5 private\cf0  \cf3 MyDslProjectPackage\cf0  m_Package;\par ??\par ??        \cf5 public\cf0  MyDslProjectNode(\cf3 MyDslProjectPackage\cf0  package)\par ??        \{\par ??            m_Package = package;\par ??        \}\par ??\par ??        \cf5 public\cf0  \cf5 override\cf0  \cf5 string\cf0  ProjectType\par ??        \{\par ??            \cf5 get\cf0  \{ \cf5 return\cf0  ProjectTypeName; \}\par ??        \}\par ??\par ??        \cf5 public\cf0  \cf5 override\cf0  \cf3 Guid\cf0  ProjectGuid\par ??        \{\par ??            \cf5 get\cf0  \{ \cf5 return\cf0  \cf5 typeof\cf0 (\cf3 MyDslProjectFactory\cf0 ).GUID; \}\par ??        \}\par ??    \}\par ??}
--&gt;
&lt;div style="FONT-SIZE: 9pt; BACKGROUND: white; COLOR: black; FONT-FAMILY: Courier New"&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; [&lt;span style="COLOR: #2b91af"&gt;Guid&lt;/span&gt;(&lt;span style="COLOR: #a31515"&gt;"8D681873-2A8D-442b-82CE-ED96C69D02D7"&lt;/span&gt;)]
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;public&lt;/span&gt; &lt;span style="COLOR: blue"&gt;class&lt;/span&gt; &lt;span style="COLOR: #2b91af"&gt;MyDslProjectNode&lt;/span&gt; : &lt;span style="COLOR: #2b91af"&gt;ProjectNode&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; {
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;internal&lt;/span&gt; &lt;span style="COLOR: blue"&gt;const&lt;/span&gt; &lt;span style="COLOR: blue"&gt;string&lt;/span&gt; ProjectTypeName
= &lt;span style="COLOR: #a31515"&gt;"MyDslProject"&lt;/span&gt;;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;private&lt;/span&gt; &lt;span style="COLOR: #2b91af"&gt;MyDslProjectPackage&lt;/span&gt; m_Package;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;public&lt;/span&gt; MyDslProjectNode(&lt;span style="COLOR: #2b91af"&gt;MyDslProjectPackage&lt;/span&gt; package)
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; {
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; m_Package = package;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; }
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;public&lt;/span&gt; &lt;span style="COLOR: blue"&gt;override&lt;/span&gt; &lt;span style="COLOR: blue"&gt;string&lt;/span&gt; ProjectType
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; {
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;get&lt;/span&gt; { &lt;span style="COLOR: blue"&gt;return&lt;/span&gt; ProjectTypeName;
}
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; }
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;public&lt;/span&gt; &lt;span style="COLOR: blue"&gt;override&lt;/span&gt; &lt;span style="COLOR: #2b91af"&gt;Guid&lt;/span&gt; ProjectGuid
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; {
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;get&lt;/span&gt; { &lt;span style="COLOR: blue"&gt;return&lt;/span&gt; &lt;span style="COLOR: blue"&gt;typeof&lt;/span&gt;(&lt;span style="COLOR: #2b91af"&gt;MyDslProjectFactory&lt;/span&gt;).GUID;
}
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; }
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; }
&lt;/p&gt;
&lt;/div&gt;
&lt;p&gt;
&lt;/p&gt;
&lt;p&gt;
The project node needs a Guid, just generate a new Guid not used in any other place.
&lt;/p&gt;
&lt;p&gt;
&lt;u&gt;4. Implement the “MyDslProjectFactory” class&lt;/u&gt;
&lt;/p&gt;
&lt;p&gt;
Implement a simple project factory as shown below:
&lt;/p&gt;
&lt;p&gt;
&lt;!--
{\rtf1\ansi\ansicpg\lang1024\noproof65001\uc1 \deff0{\fonttbl{\f0\fnil\fcharset0\fprq1 Courier New;}}{\colortbl;??\red0\green0\blue255;\red255\green255\blue255;\red0\green0\blue0;\red43\green145\blue175;}??\fs20 \cf1 using\cf0  System;\par ??\cf1 using\cf0  System.Runtime.InteropServices;\par ??\cf1 using\cf0  Microsoft.VisualStudio.Project;\par ??\cf1 using\cf0  \cf4 IOleServiceProvider\cf0  = Microsoft.VisualStudio.OLE.Interop.\cf4 IServiceProvider\cf0 ;\par ??\par ??\cf1 namespace\cf0  MyCompany.MyDslProject\par ??\{\par ??    [\cf4 Guid\cf0 (\cf4 GuidList\cf0 .guidMyDslProjectFactoryString)]\par ??    \cf1 public\cf0  \cf1 class\cf0  \cf4 MyDslProjectFactory\cf0  : \cf4 ProjectFactory\par ??\cf0     \{\par ??        \cf1 private\cf0  \cf4 MyDslProjectPackage\cf0  m_Package;\par ??\par ??        \cf1 public\cf0  MyDslProjectFactory(\cf4 MyDslProjectPackage\cf0  package)\par ??            : \cf1 base\cf0 (package)\par ??        \{\par ??            m_Package = package;\par ??        \}\par ??\par ??        \cf1 protected\cf0  \cf1 override\cf0  \cf4 ProjectNode\cf0  CreateProject()\par ??        \{\par ??            \cf4 MyDslProjectNode\cf0  project = \cf1 new\cf0  \cf4 MyDslProjectNode\cf0 (\cf1 this\cf0 .m_Package);\par ??            \cf4 IServiceProvider\cf0  serviceProvider = (\cf4 IServiceProvider\cf0 )\cf1 this\cf0 .m_Package;\par ??            \cf4 IOleServiceProvider\cf0  oleServiceProvider =\par ??                (\cf4 IOleServiceProvider\cf0 )serviceProvider.GetService(\cf1 typeof\cf0 (\cf4 IOleServiceProvider\cf0 ));\par ??            project.SetSite(oleServiceProvider);\par ??            \cf1 return\cf0  project;\par ??        \}\par ??    \}\par ??\}\par ??}
--&gt;
&lt;div style="FONT-SIZE: 9pt; BACKGROUND: white; COLOR: black; FONT-FAMILY: Courier New"&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: blue"&gt;using&lt;/span&gt; System;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: blue"&gt;using&lt;/span&gt; System.Runtime.InteropServices;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: blue"&gt;using&lt;/span&gt; Microsoft.VisualStudio.Project;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: blue"&gt;using&lt;/span&gt; &lt;span style="COLOR: #2b91af"&gt;IOleServiceProvider&lt;/span&gt; =
Microsoft.VisualStudio.OLE.Interop.&lt;span style="COLOR: #2b91af"&gt;IServiceProvider&lt;/span&gt;;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: blue"&gt;namespace&lt;/span&gt; MyCompany.MyDslProject
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
{
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; [&lt;span style="COLOR: #2b91af"&gt;Guid&lt;/span&gt;(&lt;span style="COLOR: #2b91af"&gt;GuidList&lt;/span&gt;.guidMyDslProjectFactoryString)]
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;public&lt;/span&gt; &lt;span style="COLOR: blue"&gt;class&lt;/span&gt; &lt;span style="COLOR: #2b91af"&gt;MyDslProjectFactory&lt;/span&gt; : &lt;span style="COLOR: #2b91af"&gt;ProjectFactory&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; {
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;private&lt;/span&gt; &lt;span style="COLOR: #2b91af"&gt;MyDslProjectPackage&lt;/span&gt; m_Package;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;public&lt;/span&gt; MyDslProjectFactory(&lt;span style="COLOR: #2b91af"&gt;MyDslProjectPackage&lt;/span&gt; package)
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; : &lt;span style="COLOR: blue"&gt;base&lt;/span&gt;(package)
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; {
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; m_Package = package;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; }
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;protected&lt;/span&gt; &lt;span style="COLOR: blue"&gt;override&lt;/span&gt; &lt;span style="COLOR: #2b91af"&gt;ProjectNode&lt;/span&gt; CreateProject()
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; {
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: #2b91af"&gt;MyDslProjectNode&lt;/span&gt; project
= &lt;span style="COLOR: blue"&gt;new&lt;/span&gt; &lt;span style="COLOR: #2b91af"&gt;MyDslProjectNode&lt;/span&gt;(&lt;span style="COLOR: blue"&gt;this&lt;/span&gt;.m_Package);
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: #2b91af"&gt;IServiceProvider&lt;/span&gt; serviceProvider
= (&lt;span style="COLOR: #2b91af"&gt;IServiceProvider&lt;/span&gt;)&lt;span style="COLOR: blue"&gt;this&lt;/span&gt;.m_Package;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: #2b91af"&gt;IOleServiceProvider&lt;/span&gt; oleServiceProvider
=
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; (&lt;span style="COLOR: #2b91af"&gt;IOleServiceProvider&lt;/span&gt;)serviceProvider.GetService(&lt;span style="COLOR: blue"&gt;typeof&lt;/span&gt;(&lt;span style="COLOR: #2b91af"&gt;IOleServiceProvider&lt;/span&gt;));
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; project.SetSite(oleServiceProvider);
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;return&lt;/span&gt; project;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; }
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; }
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
}
&lt;/p&gt;
&lt;/div&gt;
&lt;p&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;u&gt;5. Change package base class&lt;/u&gt;
&lt;/p&gt;
&lt;p&gt;
Change the base class in “MyDslProjectPackage” class, so that it inherits from ProjectPackage,
as show below:
&lt;/p&gt;
&lt;p&gt;
&lt;!--
{\rtf1\ansi\ansicpg\lang1024\noproof65001\uc1 \deff0{\fonttbl{\f0\fnil\fcharset0\fprq1 Courier New;}}{\colortbl;??\red0\green0\blue0;\red255\green255\blue255;\red0\green0\blue255;\red43\green145\blue175;\red128\green128\blue128;\red0\green128\blue0;}??\fs20     \cf3 public\cf0  \cf3 sealed\cf0  \cf3 class\cf0  \cf4 MyDslProjectPackage\cf0  : \cf4 ProjectPackage\par ??\cf0     \{\par ??        \cf5 ///\cf6  ...\par ??\cf0     \}\par ??}
--&gt;
&lt;div style="FONT-SIZE: 9pt; BACKGROUND: white; COLOR: black; FONT-FAMILY: Courier New"&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;public&lt;/span&gt; &lt;span style="COLOR: blue"&gt;sealed&lt;/span&gt; &lt;span style="COLOR: blue"&gt;class&lt;/span&gt; &lt;span style="COLOR: #2b91af"&gt;MyDslProjectPackage&lt;/span&gt; : &lt;span style="COLOR: #2b91af"&gt;ProjectPackage&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; {
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; ...&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; }
&lt;/p&gt;
&lt;/div&gt;
&lt;p&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;u&gt;6. Register project type&lt;/u&gt;
&lt;/p&gt;
&lt;p&gt;
The project factory must be registered in the Initialize method in the MyDslProjectPackage
class. Add a call to RegisterProjectFactory as shown below:
&lt;/p&gt;
&lt;p&gt;
&lt;!--
{\rtf1\ansi\ansicpg\lang1024\noproof65001\uc1 \deff0{\fonttbl{\f0\fnil\fcharset0\fprq1 Courier New;}}{\colortbl;??\red0\green0\blue0;\red255\green255\blue255;\red0\green0\blue255;\red43\green145\blue175;\red163\green21\blue21;}??\fs20     \cf3 public\cf0  \cf3 sealed\cf0  \cf3 class\cf0  \cf4 MyDslProjectPackage\cf0  : \cf4 ProjectPackage\par ??\cf0     \{\par ??        \cf3 protected\cf0  \cf3 override\cf0  \cf3 void\cf0  Initialize()\par ??        \{\par ??            \cf4 Trace\cf0 .WriteLine (\cf3 string\cf0 .Format(\cf4 CultureInfo\cf0 .CurrentCulture,\par ??                \cf5 "Entering Initialize() of: \{0\}"\cf0 , \cf3 this\cf0 .ToString()));\par ??            \cf3 base\cf0 .Initialize();\par ??            \cf3 this\cf0 .RegisterProjectFactory(\cf3 new\cf0  \cf4 MyDslProjectFactory\cf0 (\cf3 this\cf0 ));\par ??        \}\par ??    \}\par ??}
--&gt;
&lt;div style="FONT-SIZE: 9pt; BACKGROUND: white; COLOR: black; FONT-FAMILY: Courier New"&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;public&lt;/span&gt; &lt;span style="COLOR: blue"&gt;sealed&lt;/span&gt; &lt;span style="COLOR: blue"&gt;class&lt;/span&gt; &lt;span style="COLOR: #2b91af"&gt;MyDslProjectPackage&lt;/span&gt; : &lt;span style="COLOR: #2b91af"&gt;ProjectPackage&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; {
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;protected&lt;/span&gt; &lt;span style="COLOR: blue"&gt;override&lt;/span&gt; &lt;span style="COLOR: blue"&gt;void&lt;/span&gt; Initialize()
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; {
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: #2b91af"&gt;Trace&lt;/span&gt;.WriteLine
(&lt;span style="COLOR: blue"&gt;string&lt;/span&gt;.Format(&lt;span style="COLOR: #2b91af"&gt;CultureInfo&lt;/span&gt;.CurrentCulture,
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: #a31515"&gt;"Entering
Initialize() of: {0}"&lt;/span&gt;, &lt;span style="COLOR: blue"&gt;this&lt;/span&gt;.ToString()));
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;base&lt;/span&gt;.Initialize();
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;strong&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;this&lt;/span&gt;.RegisterProjectFactory(&lt;span style="COLOR: blue"&gt;new&lt;/span&gt; &lt;span style="COLOR: #2b91af"&gt;MyDslProjectFactory&lt;/span&gt;(&lt;span style="COLOR: blue"&gt;this&lt;/span&gt;));&lt;/strong&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; }
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; }
&lt;/p&gt;
&lt;/div&gt;
&lt;p&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;u&gt;7. Adding ProvideProjectFactory attribute&lt;/u&gt;
&lt;/p&gt;
&lt;p&gt;
A package implementing a project type must be attributed with the “ProvideProjectFactory”
attribute. Add a “ProvideProjectFactory” attribute to the “MyDslProjectPackage” class
as show below:
&lt;/p&gt;
&lt;p&gt;
&lt;!--
{\rtf1\ansi\ansicpg\lang1024\noproof65001\uc1 \deff0{\fonttbl{\f0\fnil\fcharset0\fprq1 Courier New;}}{\colortbl;??\red0\green0\blue0;\red255\green255\blue255;\red43\green145\blue175;\red0\green0\blue255;\red163\green21\blue21;}??\fs20     [\cf3 ProvideProjectFactory\cf0 (\cf4 typeof\cf0 (\cf3 MyDslProjectFactory\cf0 ),\par ??        \cf5 "MyDsl Project"\cf0 ,\par ??        \cf5 "MyDsl Project Files (*.mydslproj);*.mydslproj"\cf0 , \par ??        \cf5 "mydslproj"\cf0 , \cf5 "mydslproj"\cf0 ,\par ??        \cf5 @"\\\\null"\cf0 ,\par ??        LanguageVsTemplate = \cf5 "MyDslProject"\cf0 ,\par ??        NewProjectRequireNewFolderVsTemplate = \cf4 true\cf0 )]\par ??    \cf4 public\cf0  \cf4 sealed\cf0  \cf4 class\cf0  \cf3 MyDslProjectPackage\cf0  : \cf3 ProjectPackage\par ??\cf0     \{\par ??    \}\par ??}
--&gt;
&lt;div style="FONT-SIZE: 9pt; BACKGROUND: white; COLOR: black; FONT-FAMILY: Courier New"&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;strong&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; [&lt;span style="COLOR: #2b91af"&gt;ProvideProjectFactory&lt;/span&gt;(&lt;span style="COLOR: blue"&gt;typeof&lt;/span&gt;(&lt;span style="COLOR: #2b91af"&gt;MyDslProjectFactory&lt;/span&gt;),&lt;/strong&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;strong&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: #a31515"&gt;"MyDsl
Project"&lt;/span&gt;,&lt;/strong&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;strong&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: #a31515"&gt;"MyDsl
Project Files (*.mydslproj);*.mydslproj"&lt;/span&gt;, &lt;/strong&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;strong&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: #a31515"&gt;"mydslproj"&lt;/span&gt;, &lt;span style="COLOR: #a31515"&gt;"mydslproj"&lt;/span&gt;,&lt;/strong&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;strong&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: #a31515"&gt;@"\\null"&lt;/span&gt;,&lt;/strong&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;strong&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; LanguageVsTemplate = &lt;span style="COLOR: #a31515"&gt;"MyDslProject"&lt;/span&gt;,&lt;/strong&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;strong&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; NewProjectRequireNewFolderVsTemplate
= &lt;span style="COLOR: blue"&gt;true&lt;/span&gt;)]&lt;/strong&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;public&lt;/span&gt; &lt;span style="COLOR: blue"&gt;sealed&lt;/span&gt; &lt;span style="COLOR: blue"&gt;class&lt;/span&gt; &lt;span style="COLOR: #2b91af"&gt;MyDslProjectPackage&lt;/span&gt; : &lt;span style="COLOR: #2b91af"&gt;ProjectPackage&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; {
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; }
&lt;/p&gt;
&lt;/div&gt;
&lt;p&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;strong&gt;Adding a project template&lt;/strong&gt;
&lt;/p&gt;
&lt;p&gt;
Finally we have to create a new project template for our custom project type.
&lt;/p&gt;
&lt;p&gt;
&lt;u&gt;1. Add template folder&lt;/u&gt;
&lt;/p&gt;
&lt;p&gt;
First we have to add a template folder in the “MyDslProject”. Add a folder named “Templates”,
a subfolder named “Projects” and finally a subfolder “MyDslProject”, as show below.
&lt;/p&gt;
&lt;p&gt;
&lt;img src="http://www.baekdorf.dk/christian/content/binary/64_DSLVSShell_Project_TemplateFolders.png" border=0&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;u&gt;2. Add a DSL item file&lt;/u&gt;
&lt;/p&gt;
&lt;p&gt;
Add an empty text file named “MyDsl1.mydsl1” to the “MyDslProject” folder, as shown
below.
&lt;/p&gt;
&lt;p&gt;
&lt;img src="http://www.baekdorf.dk/christian/content/binary/65_DSLVSShell_Project_TemplateFile1.png" border=0&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;u&gt;3. Add a project icon&lt;/u&gt;
&lt;/p&gt;
&lt;p&gt;
Add an icon file named “MyDslProject.ico” to the “MyDslProject” folder, as shown below.
&lt;/p&gt;
&lt;p&gt;
&lt;img src="http://www.baekdorf.dk/christian/content/binary/66_DSLVSShell_Project_TemplateFile2.png" border=0&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;u&gt;4. Add a project file&lt;/u&gt;
&lt;/p&gt;
&lt;p&gt;
Add a project file named “MyDslProject.mydslproj” to the “MyDslProject” folder, with
the content shown below:
&lt;/p&gt;
&lt;p&gt;
&lt;!--
{\rtf1\ansi\ansicpg\lang1024\noproof65001\uc1 \deff0{\fonttbl{\f0\fnil\fcharset0\fprq1 Courier New;}}{\colortbl;??\red0\green0\blue255;\red255\green255\blue255;\red163\green21\blue21;\red255\green0\blue0;\red0\green0\blue0;}??\fs20 \cf1 &amp;lt;\cf3 Project\cf1  \cf4 InitialTargets\cf1 =\cf0 ""\cf1  \cf4 DefaultTargets\cf1 =\cf0 "\cf1 Build\cf0 "\cf1  \cf4 xmlns\cf1 =\cf0 "\cf1 http://schemas.microsoft.com/developer/msbuild/2003\cf0 "\cf1 &amp;gt;\par ??  &amp;lt;\cf3 PropertyGroup\cf1 &amp;gt;\par ??    &amp;lt;\cf3 SchemaVersion\cf1 &amp;gt;\cf0 2.0\cf1 &amp;lt;/\cf3 SchemaVersion\cf1 &amp;gt;\par ??    &amp;lt;\cf3 ProjectGuid\cf1 &amp;gt;\cf0 \{1584A98D-D032-4709-9AC0-C3F2A8C93857\}\cf1 &amp;lt;/\cf3 ProjectGuid\cf1 &amp;gt;\par ??    &amp;lt;\cf3 OutputPath\cf1 &amp;gt;\cf0 bin\\Debug\\\cf1 &amp;lt;/\cf3 OutputPath\cf1 &amp;gt;\par ??  &amp;lt;/\cf3 PropertyGroup\cf1 &amp;gt;\par ??  &amp;lt;\cf3 ItemGroup\cf1 &amp;gt;\par ??    &amp;lt;\cf3 Content\cf1  \cf4 Include\cf1 =\cf0 "\cf1 MyDsl1.mydsl1\cf0 "\cf1 &amp;gt;\par ??      &amp;lt;\cf3 SubType\cf1 &amp;gt;\cf0 Content\cf1 &amp;lt;/\cf3 SubType\cf1 &amp;gt;\par ??    &amp;lt;/\cf3 Content\cf1 &amp;gt;\par ??  &amp;lt;/\cf3 ItemGroup\cf1 &amp;gt;\par ??  &amp;lt;\cf3 Import\cf1  \cf4 Project\cf1 =\cf0 "\cf1 $(MSBuildToolsPath)\\Microsoft.CSharp.targets\cf0 "\cf1  /&amp;gt;\par ??&amp;lt;/\cf3 Project\cf1 &amp;gt;\par ??}
--&gt;
&lt;div style="FONT-SIZE: 9pt; BACKGROUND: white; COLOR: black; FONT-FAMILY: Courier New"&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: blue"&gt;&amp;lt;&lt;/span&gt;&lt;span style="COLOR: #a31515"&gt;Project&lt;/span&gt;&lt;span style="COLOR: blue"&gt; &lt;/span&gt;&lt;span style="COLOR: red"&gt;InitialTargets&lt;/span&gt;&lt;span style="COLOR: blue"&gt;=&lt;/span&gt;""&lt;span style="COLOR: blue"&gt; &lt;/span&gt;&lt;span style="COLOR: red"&gt;DefaultTargets&lt;/span&gt;&lt;span style="COLOR: blue"&gt;=&lt;/span&gt;"&lt;span style="COLOR: blue"&gt;Build&lt;/span&gt;"&lt;span style="COLOR: blue"&gt; &lt;/span&gt;&lt;span style="COLOR: red"&gt;xmlns&lt;/span&gt;&lt;span style="COLOR: blue"&gt;=&lt;/span&gt;"&lt;span style="COLOR: blue"&gt;http://schemas.microsoft.com/developer/msbuild/2003&lt;/span&gt;"&lt;span style="COLOR: blue"&gt;&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: blue"&gt;&amp;nbsp; &amp;lt;&lt;/span&gt;&lt;span style="COLOR: #a31515"&gt;PropertyGroup&lt;/span&gt;&lt;span style="COLOR: blue"&gt;&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: blue"&gt;&amp;nbsp; &amp;nbsp; &amp;lt;&lt;/span&gt;&lt;span style="COLOR: #a31515"&gt;SchemaVersion&lt;/span&gt;&lt;span style="COLOR: blue"&gt;&amp;gt;&lt;/span&gt;2.0&lt;span style="COLOR: blue"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="COLOR: #a31515"&gt;SchemaVersion&lt;/span&gt;&lt;span style="COLOR: blue"&gt;&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: blue"&gt;&amp;nbsp; &amp;nbsp; &amp;lt;&lt;/span&gt;&lt;span style="COLOR: #a31515"&gt;ProjectGuid&lt;/span&gt;&lt;span style="COLOR: blue"&gt;&amp;gt;&lt;/span&gt;{1584A98D-D032-4709-9AC0-C3F2A8C93857}&lt;span style="COLOR: blue"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="COLOR: #a31515"&gt;ProjectGuid&lt;/span&gt;&lt;span style="COLOR: blue"&gt;&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: blue"&gt;&amp;nbsp; &amp;nbsp; &amp;lt;&lt;/span&gt;&lt;span style="COLOR: #a31515"&gt;OutputPath&lt;/span&gt;&lt;span style="COLOR: blue"&gt;&amp;gt;&lt;/span&gt;bin\Debug\&lt;span style="COLOR: blue"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="COLOR: #a31515"&gt;OutputPath&lt;/span&gt;&lt;span style="COLOR: blue"&gt;&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: blue"&gt;&amp;nbsp; &amp;lt;/&lt;/span&gt;&lt;span style="COLOR: #a31515"&gt;PropertyGroup&lt;/span&gt;&lt;span style="COLOR: blue"&gt;&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: blue"&gt;&amp;nbsp; &amp;lt;&lt;/span&gt;&lt;span style="COLOR: #a31515"&gt;ItemGroup&lt;/span&gt;&lt;span style="COLOR: blue"&gt;&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: blue"&gt;&amp;nbsp; &amp;nbsp; &amp;lt;&lt;/span&gt;&lt;span style="COLOR: #a31515"&gt;Content&lt;/span&gt;&lt;span style="COLOR: blue"&gt; &lt;/span&gt;&lt;span style="COLOR: red"&gt;Include&lt;/span&gt;&lt;span style="COLOR: blue"&gt;=&lt;/span&gt;"&lt;span style="COLOR: blue"&gt;MyDsl1.mydsl1&lt;/span&gt;"&lt;span style="COLOR: blue"&gt;&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: blue"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;&lt;/span&gt;&lt;span style="COLOR: #a31515"&gt;SubType&lt;/span&gt;&lt;span style="COLOR: blue"&gt;&amp;gt;&lt;/span&gt;Content&lt;span style="COLOR: blue"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="COLOR: #a31515"&gt;SubType&lt;/span&gt;&lt;span style="COLOR: blue"&gt;&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: blue"&gt;&amp;nbsp; &amp;nbsp; &amp;lt;/&lt;/span&gt;&lt;span style="COLOR: #a31515"&gt;Content&lt;/span&gt;&lt;span style="COLOR: blue"&gt;&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: blue"&gt;&amp;nbsp; &amp;lt;/&lt;/span&gt;&lt;span style="COLOR: #a31515"&gt;ItemGroup&lt;/span&gt;&lt;span style="COLOR: blue"&gt;&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: blue"&gt;&amp;nbsp; &amp;lt;&lt;/span&gt;&lt;span style="COLOR: #a31515"&gt;Import&lt;/span&gt;&lt;span style="COLOR: blue"&gt; &lt;/span&gt;&lt;span style="COLOR: red"&gt;Project&lt;/span&gt;&lt;span style="COLOR: blue"&gt;=&lt;/span&gt;"&lt;span style="COLOR: blue"&gt;$(MSBuildToolsPath)\Microsoft.CSharp.targets&lt;/span&gt;"&lt;span style="COLOR: blue"&gt; /&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: blue"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="COLOR: #a31515"&gt;Project&lt;/span&gt;&lt;span style="COLOR: blue"&gt;&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;/div&gt;
&lt;p&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;img src="http://www.baekdorf.dk/christian/content/binary/67_DSLVSShell_Project_TemplateFile31.png" border=0&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;u&gt;5. Add a vstemplate file&lt;/u&gt;
&lt;/p&gt;
&lt;p&gt;
Add a project file named “MyDslProject.vstemplate” to the “MyDslProject” folder, with
the content shown below:
&lt;/p&gt;
&lt;p&gt;
&lt;!--
{\rtf1\ansi\ansicpg\lang1024\noproof65001\uc1 \deff0{\fonttbl{\f0\fnil\fcharset0\fprq1 Courier New;}}{\colortbl;??\red0\green0\blue255;\red255\green255\blue255;\red163\green21\blue21;\red255\green0\blue0;\red0\green0\blue0;}??\fs20 \cf1 &amp;lt;\cf3 VSTemplate\cf1  \cf4 Version\cf1 =\cf0 "\cf1 2.0.0\cf0 "\cf1  \cf4 Type\cf1 =\cf0 "\cf1 Project\cf0 "\par ??\cf1     \cf4 xmlns\cf1 =\cf0 "\cf1 http://schemas.microsoft.com/developer/vstemplate/2005\cf0 "\cf1 &amp;gt;\par ??  &amp;lt;\cf3 TemplateData\cf1 &amp;gt;\par ??    &amp;lt;\cf3 Name\cf1 &amp;gt;\cf0 MyDsl Project\cf1 &amp;lt;/\cf3 Name\cf1 &amp;gt;\par ??    &amp;lt;\cf3 Description\cf1 &amp;gt;\cf0 Create a new MyDsl project\cf1 &amp;lt;/\cf3 Description\cf1 &amp;gt;\par ??    &amp;lt;\cf3 ProjectType\cf1 &amp;gt;\cf0 MyDslProject\cf1 &amp;lt;/\cf3 ProjectType\cf1 &amp;gt;\par ??    &amp;lt;\cf3 SortOrder\cf1 &amp;gt;\cf0 1000\cf1 &amp;lt;/\cf3 SortOrder\cf1 &amp;gt;\par ??    &amp;lt;\cf3 CreateNewFolder\cf1 &amp;gt;\cf0 true\cf1 &amp;lt;/\cf3 CreateNewFolder\cf1 &amp;gt;\par ??    &amp;lt;\cf3 DefaultName\cf1 &amp;gt;\cf0 MyDslProject\cf1 &amp;lt;/\cf3 DefaultName\cf1 &amp;gt;\par ??    &amp;lt;\cf3 ProvideDefaultName\cf1 &amp;gt;\cf0 true\cf1 &amp;lt;/\cf3 ProvideDefaultName\cf1 &amp;gt;\par ??    &amp;lt;\cf3 LocationField\cf1 &amp;gt;\cf0 Enabled\cf1 &amp;lt;/\cf3 LocationField\cf1 &amp;gt;\par ??    &amp;lt;\cf3 EnableLocationBrowseButton\cf1 &amp;gt;\cf0 true\cf1 &amp;lt;/\cf3 EnableLocationBrowseButton\cf1 &amp;gt;\par ??    &amp;lt;\cf3 Icon\cf1 &amp;gt;\cf0 MyDslProject.ico\cf1 &amp;lt;/\cf3 Icon\cf1 &amp;gt;\par ??  &amp;lt;/\cf3 TemplateData\cf1 &amp;gt;\par ??  &amp;lt;\cf3 TemplateContent\cf1 &amp;gt;\par ??    &amp;lt;\cf3 Project\cf1  \cf4 TargetFileName\cf1 =\cf0 "\cf1 MyDslProject.mydslproj\cf0 "\cf1  \cf4 File\cf1 =\cf0 "\cf1 MyDslProject.mydslproj\cf0 "\cf1  \cf4 ReplaceParameters\cf1 =\cf0 "\cf1 true\cf0 "\cf1 &amp;gt;\par ??      &amp;lt;\cf3 ProjectItem\cf1  \cf4 TargetFileName\cf1 =\cf0 "\cf1 MyDsl1.mydsl1\cf0 "\cf1 &amp;gt;\cf0 MyDsl1.mydsl1\cf1 &amp;lt;/\cf3 ProjectItem\cf1 &amp;gt;\par ??    &amp;lt;/\cf3 Project\cf1 &amp;gt;\par ??  &amp;lt;/\cf3 TemplateContent\cf1 &amp;gt;\par ??&amp;lt;/\cf3 VSTemplate\cf1 &amp;gt;\par ??}
--&gt;
&lt;div style="FONT-SIZE: 9pt; BACKGROUND: white; COLOR: black; FONT-FAMILY: Courier New"&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: blue"&gt;&amp;lt;&lt;/span&gt;&lt;span style="COLOR: #a31515"&gt;VSTemplate&lt;/span&gt;&lt;span style="COLOR: blue"&gt; &lt;/span&gt;&lt;span style="COLOR: red"&gt;Version&lt;/span&gt;&lt;span style="COLOR: blue"&gt;=&lt;/span&gt;"&lt;span style="COLOR: blue"&gt;2.0.0&lt;/span&gt;"&lt;span style="COLOR: blue"&gt; &lt;/span&gt;&lt;span style="COLOR: red"&gt;Type&lt;/span&gt;&lt;span style="COLOR: blue"&gt;=&lt;/span&gt;"&lt;span style="COLOR: blue"&gt;Project&lt;/span&gt;"
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: blue"&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style="COLOR: red"&gt;xmlns&lt;/span&gt;&lt;span style="COLOR: blue"&gt;=&lt;/span&gt;"&lt;span style="COLOR: blue"&gt;http://schemas.microsoft.com/developer/vstemplate/2005&lt;/span&gt;"&lt;span style="COLOR: blue"&gt;&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: blue"&gt;&amp;nbsp; &amp;lt;&lt;/span&gt;&lt;span style="COLOR: #a31515"&gt;TemplateData&lt;/span&gt;&lt;span style="COLOR: blue"&gt;&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: blue"&gt;&amp;nbsp; &amp;nbsp; &amp;lt;&lt;/span&gt;&lt;span style="COLOR: #a31515"&gt;Name&lt;/span&gt;&lt;span style="COLOR: blue"&gt;&amp;gt;&lt;/span&gt;MyDsl
Project&lt;span style="COLOR: blue"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="COLOR: #a31515"&gt;Name&lt;/span&gt;&lt;span style="COLOR: blue"&gt;&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: blue"&gt;&amp;nbsp; &amp;nbsp; &amp;lt;&lt;/span&gt;&lt;span style="COLOR: #a31515"&gt;Description&lt;/span&gt;&lt;span style="COLOR: blue"&gt;&amp;gt;&lt;/span&gt;Create
a new MyDsl project&lt;span style="COLOR: blue"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="COLOR: #a31515"&gt;Description&lt;/span&gt;&lt;span style="COLOR: blue"&gt;&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: blue"&gt;&amp;nbsp; &amp;nbsp; &amp;lt;&lt;/span&gt;&lt;span style="COLOR: #a31515"&gt;ProjectType&lt;/span&gt;&lt;span style="COLOR: blue"&gt;&amp;gt;&lt;/span&gt;MyDslProject&lt;span style="COLOR: blue"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="COLOR: #a31515"&gt;ProjectType&lt;/span&gt;&lt;span style="COLOR: blue"&gt;&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: blue"&gt;&amp;nbsp; &amp;nbsp; &amp;lt;&lt;/span&gt;&lt;span style="COLOR: #a31515"&gt;SortOrder&lt;/span&gt;&lt;span style="COLOR: blue"&gt;&amp;gt;&lt;/span&gt;1000&lt;span style="COLOR: blue"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="COLOR: #a31515"&gt;SortOrder&lt;/span&gt;&lt;span style="COLOR: blue"&gt;&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: blue"&gt;&amp;nbsp; &amp;nbsp; &amp;lt;&lt;/span&gt;&lt;span style="COLOR: #a31515"&gt;CreateNewFolder&lt;/span&gt;&lt;span style="COLOR: blue"&gt;&amp;gt;&lt;/span&gt;true&lt;span style="COLOR: blue"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="COLOR: #a31515"&gt;CreateNewFolder&lt;/span&gt;&lt;span style="COLOR: blue"&gt;&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: blue"&gt;&amp;nbsp; &amp;nbsp; &amp;lt;&lt;/span&gt;&lt;span style="COLOR: #a31515"&gt;DefaultName&lt;/span&gt;&lt;span style="COLOR: blue"&gt;&amp;gt;&lt;/span&gt;MyDslProject&lt;span style="COLOR: blue"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="COLOR: #a31515"&gt;DefaultName&lt;/span&gt;&lt;span style="COLOR: blue"&gt;&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: blue"&gt;&amp;nbsp; &amp;nbsp; &amp;lt;&lt;/span&gt;&lt;span style="COLOR: #a31515"&gt;ProvideDefaultName&lt;/span&gt;&lt;span style="COLOR: blue"&gt;&amp;gt;&lt;/span&gt;true&lt;span style="COLOR: blue"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="COLOR: #a31515"&gt;ProvideDefaultName&lt;/span&gt;&lt;span style="COLOR: blue"&gt;&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: blue"&gt;&amp;nbsp; &amp;nbsp; &amp;lt;&lt;/span&gt;&lt;span style="COLOR: #a31515"&gt;LocationField&lt;/span&gt;&lt;span style="COLOR: blue"&gt;&amp;gt;&lt;/span&gt;Enabled&lt;span style="COLOR: blue"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="COLOR: #a31515"&gt;LocationField&lt;/span&gt;&lt;span style="COLOR: blue"&gt;&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: blue"&gt;&amp;nbsp; &amp;nbsp; &amp;lt;&lt;/span&gt;&lt;span style="COLOR: #a31515"&gt;EnableLocationBrowseButton&lt;/span&gt;&lt;span style="COLOR: blue"&gt;&amp;gt;&lt;/span&gt;true&lt;span style="COLOR: blue"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="COLOR: #a31515"&gt;EnableLocationBrowseButton&lt;/span&gt;&lt;span style="COLOR: blue"&gt;&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: blue"&gt;&amp;nbsp; &amp;nbsp; &amp;lt;&lt;/span&gt;&lt;span style="COLOR: #a31515"&gt;Icon&lt;/span&gt;&lt;span style="COLOR: blue"&gt;&amp;gt;&lt;/span&gt;MyDslProject.ico&lt;span style="COLOR: blue"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="COLOR: #a31515"&gt;Icon&lt;/span&gt;&lt;span style="COLOR: blue"&gt;&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: blue"&gt;&amp;nbsp; &amp;lt;/&lt;/span&gt;&lt;span style="COLOR: #a31515"&gt;TemplateData&lt;/span&gt;&lt;span style="COLOR: blue"&gt;&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: blue"&gt;&amp;nbsp; &amp;lt;&lt;/span&gt;&lt;span style="COLOR: #a31515"&gt;TemplateContent&lt;/span&gt;&lt;span style="COLOR: blue"&gt;&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: blue"&gt;&amp;nbsp; &amp;nbsp; &amp;lt;&lt;/span&gt;&lt;span style="COLOR: #a31515"&gt;Project&lt;/span&gt;&lt;span style="COLOR: blue"&gt; &lt;/span&gt;&lt;span style="COLOR: red"&gt;TargetFileName&lt;/span&gt;&lt;span style="COLOR: blue"&gt;=&lt;/span&gt;"&lt;span style="COLOR: blue"&gt;MyDslProject.mydslproj&lt;/span&gt;"&lt;span style="COLOR: blue"&gt; &lt;/span&gt;&lt;span style="COLOR: red"&gt;File&lt;/span&gt;&lt;span style="COLOR: blue"&gt;=&lt;/span&gt;"&lt;span style="COLOR: blue"&gt;MyDslProject.mydslproj&lt;/span&gt;"&lt;span style="COLOR: blue"&gt; &lt;/span&gt;&lt;span style="COLOR: red"&gt;ReplaceParameters&lt;/span&gt;&lt;span style="COLOR: blue"&gt;=&lt;/span&gt;"&lt;span style="COLOR: blue"&gt;true&lt;/span&gt;"&lt;span style="COLOR: blue"&gt;&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: blue"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;&lt;/span&gt;&lt;span style="COLOR: #a31515"&gt;ProjectItem&lt;/span&gt;&lt;span style="COLOR: blue"&gt; &lt;/span&gt;&lt;span style="COLOR: red"&gt;TargetFileName&lt;/span&gt;&lt;span style="COLOR: blue"&gt;=&lt;/span&gt;"&lt;span style="COLOR: blue"&gt;MyDsl1.mydsl1&lt;/span&gt;"&lt;span style="COLOR: blue"&gt;&amp;gt;&lt;/span&gt;MyDsl1.mydsl1&lt;span style="COLOR: blue"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="COLOR: #a31515"&gt;ProjectItem&lt;/span&gt;&lt;span style="COLOR: blue"&gt;&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: blue"&gt;&amp;nbsp; &amp;nbsp; &amp;lt;/&lt;/span&gt;&lt;span style="COLOR: #a31515"&gt;Project&lt;/span&gt;&lt;span style="COLOR: blue"&gt;&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: blue"&gt;&amp;nbsp; &amp;lt;/&lt;/span&gt;&lt;span style="COLOR: #a31515"&gt;TemplateContent&lt;/span&gt;&lt;span style="COLOR: blue"&gt;&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: blue"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="COLOR: #a31515"&gt;VSTemplate&lt;/span&gt;&lt;span style="COLOR: blue"&gt;&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;/div&gt;
&lt;p&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;img src="http://www.baekdorf.dk/christian/content/binary/68_DSLVSShell_Project_TemplateFile4.png" border=0&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;u&gt;6. Set build action&lt;/u&gt;
&lt;/p&gt;
&lt;p&gt;
Select the four template files added in the above steps and set the build action to
ZipProject.
&lt;/p&gt;
&lt;p&gt;
&lt;img src="http://www.baekdorf.dk/christian/content/binary/69_DSLVSShell_Project_TemplateZipAction.png" border=0&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;u&gt;7. Add copy events&lt;/u&gt;
&lt;/p&gt;
&lt;p&gt;
Add an after build action to copy the template file to the output folder. Open the
“MyDslProject.csproj” file so you can edit it directly, and add the XML shown below:
&lt;/p&gt;
&lt;p&gt;
&lt;!--
{\rtf1\ansi\ansicpg\lang1024\noproof65001\uc1 \deff0{\fonttbl{\f0\fnil\fcharset0\fprq1 Courier New;}}{\colortbl;??\red0\green0\blue255;\red255\green255\blue255;\red163\green21\blue21;\red255\green0\blue0;\red0\green0\blue0;}??\fs20 \cf1   &amp;lt;\cf3 Target\cf1  \cf4 Name\cf1 =\cf0 "\cf1 AfterBuild\cf0 "\cf1 &amp;gt;\par ??    &amp;lt;\cf3 MakeDir\cf1  \cf4 Directories\cf1 =\cf0 "\cf1 $(SolutionDir)$(Configuration)\\ProjectTemplates\cf0 "\cf1  /&amp;gt;\par ??    &amp;lt;\cf3 MakeDir\cf1  \cf4 Directories\cf1 =\cf0 "\cf1 $(SolutionDir)$(Configuration)\\ItemTemplates\cf0 "\cf1  /&amp;gt;\par ??    &amp;lt;\cf3 Copy\cf1  \cf4 SourceFiles\cf1 =\cf0 "\cf1 @(IntermediateZipProject)\cf0 "\cf1  \cf4 DestinationFolder\cf1 =\cf0 "\cf1 $(SolutionDir)$(Configuration)\\ProjectTemplates\cf0 "\cf1  /&amp;gt;\par ??    &amp;lt;\cf3 Copy\cf1  \cf4 SourceFiles\cf1 =\cf0 "\cf1 @(IntermediateZipItem)\cf0 "\cf1  \cf4 DestinationFolder\cf1 =\cf0 "\cf1 $(SolutionDir)$(Configuration)\\ItemTemplates\cf0 "\cf1  /&amp;gt;\par ??  &amp;lt;/\cf3 Target\cf1 &amp;gt;\par ??}
--&gt;
&lt;div style="FONT-SIZE: 9pt; BACKGROUND: white; COLOR: black; FONT-FAMILY: Courier New"&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: blue"&gt;&amp;nbsp; &amp;lt;&lt;/span&gt;&lt;span style="COLOR: #a31515"&gt;Target&lt;/span&gt;&lt;span style="COLOR: blue"&gt; &lt;/span&gt;&lt;span style="COLOR: red"&gt;Name&lt;/span&gt;&lt;span style="COLOR: blue"&gt;=&lt;/span&gt;"&lt;span style="COLOR: blue"&gt;AfterBuild&lt;/span&gt;"&lt;span style="COLOR: blue"&gt;&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: blue"&gt;&amp;nbsp; &amp;nbsp; &amp;lt;&lt;/span&gt;&lt;span style="COLOR: #a31515"&gt;MakeDir&lt;/span&gt;&lt;span style="COLOR: blue"&gt; &lt;/span&gt;&lt;span style="COLOR: red"&gt;Directories&lt;/span&gt;&lt;span style="COLOR: blue"&gt;=&lt;/span&gt;"&lt;span style="COLOR: blue"&gt;$(SolutionDir)$(Configuration)\ProjectTemplates&lt;/span&gt;"&lt;span style="COLOR: blue"&gt; /&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: blue"&gt;&amp;nbsp; &amp;nbsp; &amp;lt;&lt;/span&gt;&lt;span style="COLOR: #a31515"&gt;MakeDir&lt;/span&gt;&lt;span style="COLOR: blue"&gt; &lt;/span&gt;&lt;span style="COLOR: red"&gt;Directories&lt;/span&gt;&lt;span style="COLOR: blue"&gt;=&lt;/span&gt;"&lt;span style="COLOR: blue"&gt;$(SolutionDir)$(Configuration)\ItemTemplates&lt;/span&gt;"&lt;span style="COLOR: blue"&gt; /&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: blue"&gt;&amp;nbsp; &amp;nbsp; &amp;lt;&lt;/span&gt;&lt;span style="COLOR: #a31515"&gt;Copy&lt;/span&gt;&lt;span style="COLOR: blue"&gt; &lt;/span&gt;&lt;span style="COLOR: red"&gt;SourceFiles&lt;/span&gt;&lt;span style="COLOR: blue"&gt;=&lt;/span&gt;"&lt;span style="COLOR: blue"&gt;@(IntermediateZipProject)&lt;/span&gt;"&lt;span style="COLOR: blue"&gt; &lt;/span&gt;&lt;span style="COLOR: red"&gt;DestinationFolder&lt;/span&gt;&lt;span style="COLOR: blue"&gt;=&lt;/span&gt;"&lt;span style="COLOR: blue"&gt;$(SolutionDir)$(Configuration)\ProjectTemplates&lt;/span&gt;"&lt;span style="COLOR: blue"&gt; /&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: blue"&gt;&amp;nbsp; &amp;nbsp; &amp;lt;&lt;/span&gt;&lt;span style="COLOR: #a31515"&gt;Copy&lt;/span&gt;&lt;span style="COLOR: blue"&gt; &lt;/span&gt;&lt;span style="COLOR: red"&gt;SourceFiles&lt;/span&gt;&lt;span style="COLOR: blue"&gt;=&lt;/span&gt;"&lt;span style="COLOR: blue"&gt;@(IntermediateZipItem)&lt;/span&gt;"&lt;span style="COLOR: blue"&gt; &lt;/span&gt;&lt;span style="COLOR: red"&gt;DestinationFolder&lt;/span&gt;&lt;span style="COLOR: blue"&gt;=&lt;/span&gt;"&lt;span style="COLOR: blue"&gt;$(SolutionDir)$(Configuration)\ItemTemplates&lt;/span&gt;"&lt;span style="COLOR: blue"&gt; /&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: blue"&gt;&amp;nbsp; &amp;lt;/&lt;/span&gt;&lt;span style="COLOR: #a31515"&gt;Target&lt;/span&gt;&lt;span style="COLOR: blue"&gt;&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;/div&gt;
&lt;p&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;img src="http://www.baekdorf.dk/christian/content/binary/70_DSLVSShell_Project_TemplateCopyEvents.png" border=0&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;u&gt;8. Specify template folder&lt;/u&gt;
&lt;/p&gt;
&lt;p&gt;
The Shell application needs to know where to look for templates, so you have to specify
the template folders.
&lt;/p&gt;
&lt;p&gt;
Open the “MyDslShell.pkgdef” in the “MyDslShell” project and append the following
in to bottom of the file:
&lt;/p&gt;
&lt;p&gt;
&lt;!--
{\rtf1\ansi\ansicpg\lang1024\noproof1252\uc1 \deff0{\fonttbl{\f0\fnil\fcharset0\fprq1 Courier New;}}{\colortbl;??\red0\green0\blue0;\red255\green255\blue255;}??\fs20 [$RootKey$\\VSTemplate\\Project]\par ??"UserFolder"="$RootFolder$\\ProjectTemplates"\par ??"CacheFolder"="$RootFolder$\\ProjectTemplatesCache"\par ??\par ??[$RootKey$\\VSTemplate\\Item]\par ??"UserFolder"="$RootFolder$\\ItemTemplates"\par ??"CacheFolder"="$RootFolder$\\ItemTemplatesCache"\par ??}
--&gt;
&lt;div style="FONT-SIZE: 9pt; BACKGROUND: white; COLOR: black; FONT-FAMILY: Courier New"&gt;
&lt;p style="MARGIN: 0px"&gt;
[$RootKey$\VSTemplate\Project]
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
"UserFolder"="$RootFolder$\ProjectTemplates"
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
"CacheFolder"="$RootFolder$\ProjectTemplatesCache"
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
[$RootKey$\VSTemplate\Item]
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
"UserFolder"="$RootFolder$\ItemTemplates"
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
"CacheFolder"="$RootFolder$\ItemTemplatesCache"
&lt;/p&gt;
&lt;/div&gt;
&lt;p&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;img src="http://www.baekdorf.dk/christian/content/binary/71_DSLVSShell_Project_TemplateTemplateFolder.png" border=0&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;strong&gt;Testing the project&lt;/strong&gt;
&lt;/p&gt;
&lt;p&gt;
Everything should now be in place and we are ready to test the new custom project
type. 
&lt;/p&gt;
&lt;p&gt;
&lt;u&gt;1. Building the solution&lt;/u&gt;
&lt;/p&gt;
&lt;p&gt;
Rebuild the entire solution. After rebuilding completes check the output folder (e.g.
), it should look as shown below.
&lt;/p&gt;
&lt;p&gt;
&lt;img src="http://www.baekdorf.dk/christian/content/binary/72_DSLVSShell_Project_TestDebugFolder.png" border=0&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;u&gt;2. Running the application&lt;/u&gt;
&lt;/p&gt;
&lt;p&gt;
Run the solution and select File -&amp;gt; New -&amp;gt; Project on the menu and you should
see the new project type as shown below.
&lt;/p&gt;
&lt;p&gt;
&lt;img src="http://www.baekdorf.dk/christian/content/binary/73_DSLVSShell_Project_TestNewProject.png" border=0&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;u&gt;3. Create a new project&lt;/u&gt;
&lt;/p&gt;
&lt;p&gt;
Choose OK in the new project and you should get a new project with a DSL file as shown
below.
&lt;/p&gt;
&lt;p&gt;
&lt;img src="http://www.baekdorf.dk/christian/content/binary/74_DSLVSShell_Project_TestSample.png" border=0&gt;
&lt;/p&gt;
&lt;p&gt;
You can now start use the DSL and create diagrams.
&lt;/p&gt;
&lt;p&gt;
&lt;strong&gt;Summary&lt;/strong&gt;
&lt;/p&gt;
&lt;p&gt;
This end the fifth post about adding custom project type to the Shell application,
next step is about creating a setup project for the entire Shell application, so it
can be deployed.
&lt;/p&gt;
&lt;p&gt;
Next step: Coming soon!
&lt;/p&gt;
&lt;p&gt;
Download: &lt;a href="http://www.baekdorf.dk/christian/content/binary/DslToolsAndVsShell-05.zip" target=_blank&gt;DslToolsAndVsShell-05.zip
(7 MB)&lt;/a&gt;
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.baekdorf.dk/christian/aggbug.ashx?id=726b5c35-6660-43aa-a25b-d105f9ccf50e" /&gt;</description>
      <comments>http://www.baekdorf.dk/christian/CommentView,guid,726b5c35-6660-43aa-a25b-d105f9ccf50e.aspx</comments>
    </item>
    <item>
      <trackback:ping>http://www.baekdorf.dk/christian/Trackback.aspx?guid=9ff785f3-a8a9-4255-a531-3a933145b8ef</trackback:ping>
      <pingback:server>http://www.baekdorf.dk/christian/pingback.aspx</pingback:server>
      <pingback:target>http://www.baekdorf.dk/christian/PermaLink,guid,9ff785f3-a8a9-4255-a531-3a933145b8ef.aspx</pingback:target>
      <dc:creator>Christian B�kdorf (admin)</dc:creator>
      <wfw:comment>http://www.baekdorf.dk/christian/CommentView,guid,9ff785f3-a8a9-4255-a531-3a933145b8ef.aspx</wfw:comment>
      <wfw:commentRss>http://www.baekdorf.dk/christian/SyndicationService.asmx/GetEntryCommentsRss?guid=9ff785f3-a8a9-4255-a531-3a933145b8ef</wfw:commentRss>
      <slash:comments>74</slash:comments>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
          <em>This post is part of a larger </em>
          <a href="http://www.baekdorf.dk/christian/2008/09/24/DSLToolsAndVisualStudio2008IsolatedShellTutorial.aspx">
            <em>tutorial
on DSL Tools and Visual Studio 2008 Isolated Shell</em>
          </a>
          <em>, in this post I will
go through the steps to add the DSL sample to the Shell application. </em>
        </p>
        <p>
Previous step: <a href="http://www.baekdorf.dk/christian/2008/09/29/DSLAndVisualStudioShellTutorialCreatingTheShellApplication.aspx">Creating
the Shell application</a></p>
        <p>
          <strong>Adding the DSL projects</strong>
        </p>
        <p>
We will now add the DSL designer to the Shell application, so if not already open
you should open the Shell solution.
</p>
        <p>
          <u>1. Adding the Dsl project</u>
        </p>
        <p>
Select add existing project and locate the Dsl.csproj and add it to the Shell solution
</p>
        <p>
          <img src="http://www.baekdorf.dk/christian/content/binary/40_DSLVSShell_AddDsl_Proj1.png" border="0" />
        </p>
        <p>
          <u>2. Adding the DslPackage project</u>
        </p>
        <p>
Select add existing project and locate the DslPackage.csproj and add it to the Shell
solution
</p>
        <p>
          <img src="http://www.baekdorf.dk/christian/content/binary/41_DSLVSShell_AddDsl_Proj2.png" border="0" />
        </p>
        <p>
          <u>3. Resulting solution</u>
        </p>
        <p>
The solution should now look as shown below.
</p>
        <p>
          <img src="http://www.baekdorf.dk/christian/content/binary/42_DSLVSShell_AddDsl_Solution.png" border="0" />
        </p>
        <p>
          <u>4. Setting Shell dependencies</u>
        </p>
        <p>
Now set the shell dependencies for the “MyDslShell” project, so the project will depend
on “DslPackage”. Right-click “MyDslShell” project and choose “Shell Dependencies…”.
</p>
        <p>
          <img src="http://www.baekdorf.dk/christian/content/binary/43_DSLVSShell_AddDsl_ShellDep.png" border="0" />
        </p>
        <p>
          <u>5. Testing the DSL within the Shell application</u>
        </p>
        <p>
The Shell application does not yet have the ability to create a new project with a
DSL file, but it can open an existing DSL (.mydsl1 file) and display then activate
the DSL designer.
</p>
        <p>
You can just create an empty text file with extension “.mydsl1” or open an existing
file, such as “D:\project\DslToolsAndVsShell\Code\MyDSLApplication\MyDsl\Debugging\Sample.mydsl1”
which is created as part of the DSL.
</p>
        <p>
You should then see your DSL designer running within the Shell application, as shown
below.
</p>
        <p>
          <img src="http://www.baekdorf.dk/christian/content/binary/44_DSLVSShell_AddDsl_SampleDiagram.png" border="0" />
        </p>
        <p>
          <strong>Summary</strong>
        </p>
        <p>
This end the fourth post about adding the DSL to the Shell application, next step
is about adding a custom project type to the Shell application, so it can create new
projects with the DSL.
</p>
        <p>
Next step: <a href="http://www.baekdorf.dk/christian/2008/10/08/DSLAndVisualStudioShellTutorialCreatingACustomProjectType.aspx">Creating
a custom project type</a></p>
        <p>
Download: <a href="http://www.baekdorf.dk/christian/content/binary/DslToolsAndVsShell-04.zip" target="_blank">DslToolsAndVsShell-04.zip
(5 MB)</a></p>
        <img width="0" height="0" src="http://www.baekdorf.dk/christian/aggbug.ashx?id=9ff785f3-a8a9-4255-a531-3a933145b8ef" />
      </body>
      <title>DSL and Visual Studio Shell tutorial: Adding the DSL to the Shell</title>
      <guid isPermaLink="false">http://www.baekdorf.dk/christian/PermaLink,guid,9ff785f3-a8a9-4255-a531-3a933145b8ef.aspx</guid>
      <link>http://www.baekdorf.dk/christian/2008/10/01/DSLAndVisualStudioShellTutorialAddingTheDSLToTheShell.aspx</link>
      <pubDate>Wed, 01 Oct 2008 18:36:47 GMT</pubDate>
      <description>&lt;p&gt;
&lt;em&gt;This post is part of a larger &lt;/em&gt;&lt;a href="http://www.baekdorf.dk/christian/2008/09/24/DSLToolsAndVisualStudio2008IsolatedShellTutorial.aspx"&gt;&lt;em&gt;tutorial
on DSL Tools and Visual Studio 2008 Isolated Shell&lt;/em&gt;&lt;/a&gt;&lt;em&gt;, in this post I will
go through the steps to add the DSL sample to the Shell application. &lt;/em&gt;
&lt;/p&gt;
&lt;p&gt;
Previous step: &lt;a href="http://www.baekdorf.dk/christian/2008/09/29/DSLAndVisualStudioShellTutorialCreatingTheShellApplication.aspx"&gt;Creating
the Shell application&lt;/a&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;strong&gt;Adding the DSL projects&lt;/strong&gt;
&lt;/p&gt;
&lt;p&gt;
We will now add the DSL designer to the Shell application, so if not already open
you should open the Shell solution.
&lt;/p&gt;
&lt;p&gt;
&lt;u&gt;1. Adding the Dsl project&lt;/u&gt;
&lt;/p&gt;
&lt;p&gt;
Select add existing project and locate the Dsl.csproj and add it to the Shell solution
&lt;/p&gt;
&lt;p&gt;
&lt;img src="http://www.baekdorf.dk/christian/content/binary/40_DSLVSShell_AddDsl_Proj1.png" border=0&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;u&gt;2. Adding the DslPackage project&lt;/u&gt;
&lt;/p&gt;
&lt;p&gt;
Select add existing project and locate the DslPackage.csproj and add it to the Shell
solution
&lt;/p&gt;
&lt;p&gt;
&lt;img src="http://www.baekdorf.dk/christian/content/binary/41_DSLVSShell_AddDsl_Proj2.png" border=0&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;u&gt;3. Resulting solution&lt;/u&gt;
&lt;/p&gt;
&lt;p&gt;
The solution should now look as shown below.
&lt;/p&gt;
&lt;p&gt;
&lt;img src="http://www.baekdorf.dk/christian/content/binary/42_DSLVSShell_AddDsl_Solution.png" border=0&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;u&gt;4. Setting Shell dependencies&lt;/u&gt;
&lt;/p&gt;
&lt;p&gt;
Now set the shell dependencies for the “MyDslShell” project, so the project will depend
on “DslPackage”. Right-click “MyDslShell” project and choose “Shell Dependencies…”.
&lt;/p&gt;
&lt;p&gt;
&lt;img src="http://www.baekdorf.dk/christian/content/binary/43_DSLVSShell_AddDsl_ShellDep.png" border=0&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;u&gt;5. Testing the DSL within the Shell application&lt;/u&gt;
&lt;/p&gt;
&lt;p&gt;
The Shell application does not yet have the ability to create a new project with a
DSL file, but it can open an existing DSL (.mydsl1 file) and display then activate
the DSL designer.
&lt;/p&gt;
&lt;p&gt;
You can just create an empty text file with extension “.mydsl1” or open an existing
file, such as “D:\project\DslToolsAndVsShell\Code\MyDSLApplication\MyDsl\Debugging\Sample.mydsl1”
which is created as part of the DSL.
&lt;/p&gt;
&lt;p&gt;
You should then see your DSL designer running within the Shell application, as shown
below.
&lt;/p&gt;
&lt;p&gt;
&lt;img src="http://www.baekdorf.dk/christian/content/binary/44_DSLVSShell_AddDsl_SampleDiagram.png" border=0&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;strong&gt;Summary&lt;/strong&gt;
&lt;/p&gt;
&lt;p&gt;
This end the fourth post about adding the DSL to the Shell application, next step
is about adding a custom project type to the Shell application, so it can create new
projects with the DSL.
&lt;/p&gt;
&lt;p&gt;
Next step: &lt;a href="http://www.baekdorf.dk/christian/2008/10/08/DSLAndVisualStudioShellTutorialCreatingACustomProjectType.aspx"&gt;Creating
a custom project type&lt;/a&gt;
&lt;/p&gt;
&lt;p&gt;
Download: &lt;a href="http://www.baekdorf.dk/christian/content/binary/DslToolsAndVsShell-04.zip" target=_blank&gt;DslToolsAndVsShell-04.zip
(5 MB)&lt;/a&gt;
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.baekdorf.dk/christian/aggbug.ashx?id=9ff785f3-a8a9-4255-a531-3a933145b8ef" /&gt;</description>
      <comments>http://www.baekdorf.dk/christian/CommentView,guid,9ff785f3-a8a9-4255-a531-3a933145b8ef.aspx</comments>
    </item>
    <item>
      <trackback:ping>http://www.baekdorf.dk/christian/Trackback.aspx?guid=e32911b5-98de-4d62-8718-df238b8fe176</trackback:ping>
      <pingback:server>http://www.baekdorf.dk/christian/pingback.aspx</pingback:server>
      <pingback:target>http://www.baekdorf.dk/christian/PermaLink,guid,e32911b5-98de-4d62-8718-df238b8fe176.aspx</pingback:target>
      <dc:creator>Christian B�kdorf (admin)</dc:creator>
      <wfw:comment>http://www.baekdorf.dk/christian/CommentView,guid,e32911b5-98de-4d62-8718-df238b8fe176.aspx</wfw:comment>
      <wfw:commentRss>http://www.baekdorf.dk/christian/SyndicationService.asmx/GetEntryCommentsRss?guid=e32911b5-98de-4d62-8718-df238b8fe176</wfw:commentRss>
      <slash:comments>69</slash:comments>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
          <em>This post is part of a larger <a href="http://www.baekdorf.dk/christian/2008/09/24/DSLToolsAndVisualStudio2008IsolatedShellTutorial.aspx">tutorial
on DSL Tools and Visual Studio 2008 Isolated Shell</a>, in this post I will go through
creating a Visual Studio 2008 shell application that we later can add the DSL and
a custom project type to.</em>
        </p>
        <p>
Previous step: <a href="http://www.baekdorf.dk/christian/2008/09/27/DSLAndVisualStudioShellTutorialCreatingASampleDSL.aspx">Creating
a sample DSL</a></p>
        <p>
          <strong>Creating a new Isolated Shell application</strong>
        </p>
        <p>
In this section we will create a new Isolated Shell application in a new solution.
</p>
        <p>
          <u>1. New project</u>
        </p>
        <p>
Choose Visual Studio Shell Isolated and name the project “MyDslShell”, in the location
select “D:\project\DslToolsAndVsShell\Code\MyDSLApplication” and uncheck Create directory
for solution.
</p>
        <p>
          <img src="http://www.baekdorf.dk/christian/content/binary/26_DSLVSShell_ShellNewProject.png" border="0" />
        </p>
        <p>
          <u>2. Created solution</u>
        </p>
        <p>
Now you should have a new Shell solutions as shown below.
</p>
        <p>
          <img src="http://www.baekdorf.dk/christian/content/binary/27_DSLVSShell_ShellNewSolution1.png" border="0" />
        </p>
        <p>
The folder structure should look as show below.
</p>
        <p>
          <img src="http://www.baekdorf.dk/christian/content/binary/28_DSLVSShell_ShellNewSolutionFolder.png" border="0" />
        </p>
        <p>
          <u>3. Set debugger</u>
        </p>
        <p>
You should set debugger type on the “MyDslShell” project to Managed Only, otherwise
you can encounter problems when trying to debug managed packages.
</p>
        <p>
          <img src="http://www.baekdorf.dk/christian/content/binary/28a_DSLVSShell_ShellDebugger.png" border="0" />
        </p>
        <p>
          <u>4. Testing the solution</u>
        </p>
        <p>
Build the solution and press F5 to start, you should get an empty shell as shown below.
</p>
        <p>
          <img src="http://www.baekdorf.dk/christian/content/binary/29_DSLVSShell_ShellFirstTest.png" border="0" />
        </p>
        <p>
          <strong>Adding a Shell Load Key (SLK)</strong>
        </p>
        <p>
          <u>1. Gathering necessary information for obtaining a SLK </u>
        </p>
        <p>
To obtain a SLK you will need the following information:
</p>
        <ul>
          <li>
Company name 
</li>
          <li>
Shell name 
</li>
          <li>
Shell Guid 
</li>
          <li>
Shell version</li>
        </ul>
        <p>
The information can be found in “MyDslShell” project in the file “MyDslShell.pkgdef”,
please not that you will have to add some yourself.
</p>
        <p>
The Shell Guid and Shell Name can be found in the beginning the file, as shown below.
</p>
        <p>
          <img src="http://www.baekdorf.dk/christian/content/binary/30_DSLVSShell_ShellFindSLKinfo1.png" border="0" />
        </p>
        <p>
Further down in the file you find Company Name and Product version, these are commented
out, so you will have to uncomment them. The Company Name is NOT filled out by default,
so you will have to fill that in yourself.
</p>
        <p>
          <img src="http://www.baekdorf.dk/christian/content/binary/31_DSLVSShell_ShellFindSLKinfo2.png" border="0" />
        </p>
        <p>
          <u>2. Obtaining a Shell Load Key (SLK)</u>
        </p>
        <p>
You can obtain a Shell Load Key (PLK) from MSDN: <a href="http://msdn.microsoft.com/en-us/vsx/cc655795.aspx" target="_blank">Generate
Load Keys</a></p>
        <p>
Enter the information from the Constants.cs, choose “Standard” as Min. Product Edition
and “Visual Studio 2008” as min. VS Version. Finally press “Generate SLK”.
</p>
        <p>
          <img src="http://www.baekdorf.dk/christian/content/binary/32_DSLVSShell_ShellGenerateSLK.png" border="0" />
        </p>
        <p>
          <u>3. Adding the Shell Load Key (SLK) to Shell</u>
        </p>
        <p>
We have to add the SLK to the “MyDslShell” projects resource file “MyDslShell.rc”.
Open “MyDslShell.rc” and navigate to the String Table and find the entry “IDS_SLKSTRING”
and fill in the SLK without any newlines.
</p>
        <p>
          <img src="http://www.baekdorf.dk/christian/content/binary/33_DSLVSShell_ShellAddSLK1.png" border="0" />
        </p>
        <p>
Next we will have to add a value to the “MyDslShell.pkgdef” file. Find the line
</p>
        <p>
    "ID"=dword:00000069
</p>
        <p>
and uncomment it. Make sure that you get the right line; it should be below the common
explaining SLK’s. Note the number 69, this is in hexadecimal, in decimal it will be
105 and must match the number on the above screen dump.
</p>
        <p>
          <img src="http://www.baekdorf.dk/christian/content/binary/34_DSLVSShell_ShellAddSLK2.png" border="0" />
        </p>
        <p>
          <strong>Adding a Package Load Key (PLK)</strong>
        </p>
        <p>
The “MyDslShellUI” project is a Visual Studio integration package, so we need to add
a Package Load Key (PLK) to this project.
</p>
        <p>
          <u>1. Gathering necessary information for obtaining a PLK </u>
        </p>
        <p>
To obtain a PLK you will need the following information:
</p>
        <ul>
          <li>
Company name 
</li>
          <li>
Package name 
</li>
          <li>
Package Guid 
</li>
          <li>
Package version 
</li>
        </ul>
        <p>
The information can be found in “MyDslShell” project (note, it’s not in the “MyDslShellUI”
) in the bottom of file “MyDslShell.pkgdef”, also not that you will have to add the
company name yourself.
</p>
        <p>
          <img src="http://www.baekdorf.dk/christian/content/binary/35_DSLVSShell_ShellFindPLKinfo.png" border="0" />
        </p>
        <p>
          <u>2. Obtaining a Package Load Key (PLK)</u>
        </p>
        <p>
You can obtain a Package Load Key (PLK) from MSDN: <a href="http://msdn.microsoft.com/en-us/vsx/cc655795.aspx" target="_blank">Generate
Load Keys</a></p>
        <p>
Enter the information from above, choose “Standard” as Min. Product Edition and “Visual
Studio 2008” as min. VS Version. Finally press “Generate PLK”.
</p>
        <p>
          <img src="http://www.baekdorf.dk/christian/content/binary/36_DSLVSShell_ShellGeneratePLK.png" border="0" />
        </p>
        <p>
          <u>3. Adding the Package Load Key (PLK) to the Shell UI package</u>
        </p>
        <p>
The Shell UI package has it’s Package Load Key (PLK) in the “MyDslShellUI.rc” file.
</p>
        <p>
          <img src="http://www.baekdorf.dk/christian/content/binary/37_DSLVSShell_ShellAddPLK.png" border="0" />
        </p>
        <p>
          <u>4. Running and validating the Shell</u>
        </p>
        <p>
To test the SLK and PLK you have to add the /NoVSIP option to the debugging startup
parameter. This will make Visual Studio perform the SLK and PLK validation even when
you have you have Visual Studio SDK installed.
</p>
        <p>
          <img src="http://www.baekdorf.dk/christian/content/binary/38_DSLVSShell_ShellValidate.png" border="0" />
        </p>
        <p>
Now rebuild the solution and try to run the Shell using F5
</p>
        <p>
          <img src="http://www.baekdorf.dk/christian/content/binary/39_DSLVSShell_ShellRunning.png" border="0" />
        </p>
        <p>
          <strong>Summary</strong>
        </p>
        <p>
This end the third post about creating a Shell application, next step is about adding
the DSL to the Shell application.
</p>
        <p>
Next step: <a href="http://www.baekdorf.dk/christian/2008/10/01/DSLAndVisualStudioShellTutorialAddingTheDSLToTheShell.aspx">Adding
the DSL to the Shell </a></p>
        <p>
Download: <a href="http://www.baekdorf.dk/christian/content/binary/DslToolsAndVsShell-03.zip" target="_blank">DslToolsAndVsShell-03.zip
(5 MB)</a></p>
        <img width="0" height="0" src="http://www.baekdorf.dk/christian/aggbug.ashx?id=e32911b5-98de-4d62-8718-df238b8fe176" />
      </body>
      <title>DSL and Visual Studio Shell tutorial: Creating the Shell application</title>
      <guid isPermaLink="false">http://www.baekdorf.dk/christian/PermaLink,guid,e32911b5-98de-4d62-8718-df238b8fe176.aspx</guid>
      <link>http://www.baekdorf.dk/christian/2008/09/29/DSLAndVisualStudioShellTutorialCreatingTheShellApplication.aspx</link>
      <pubDate>Mon, 29 Sep 2008 14:48:37 GMT</pubDate>
      <description>&lt;p&gt;
&lt;em&gt;This post is part of a larger &lt;a href="http://www.baekdorf.dk/christian/2008/09/24/DSLToolsAndVisualStudio2008IsolatedShellTutorial.aspx"&gt;tutorial
on DSL Tools and Visual Studio 2008 Isolated Shell&lt;/a&gt;, in this post I will go through
creating a Visual Studio 2008 shell application that we later can add the DSL and
a custom project type to.&lt;/em&gt; 
&lt;/p&gt;
&lt;p&gt;
Previous step: &lt;a href="http://www.baekdorf.dk/christian/2008/09/27/DSLAndVisualStudioShellTutorialCreatingASampleDSL.aspx"&gt;Creating
a sample DSL&lt;/a&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;strong&gt;Creating a new Isolated Shell application&lt;/strong&gt;
&lt;/p&gt;
&lt;p&gt;
In this section we will create a new Isolated Shell application in a new solution.
&lt;/p&gt;
&lt;p&gt;
&lt;u&gt;1. New project&lt;/u&gt;
&lt;/p&gt;
&lt;p&gt;
Choose Visual Studio Shell Isolated and name the project “MyDslShell”, in the location
select “D:\project\DslToolsAndVsShell\Code\MyDSLApplication” and uncheck Create directory
for solution.
&lt;/p&gt;
&lt;p&gt;
&lt;img src="http://www.baekdorf.dk/christian/content/binary/26_DSLVSShell_ShellNewProject.png" border=0&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;u&gt;2. Created solution&lt;/u&gt;
&lt;/p&gt;
&lt;p&gt;
Now you should have a new Shell solutions as shown below.
&lt;/p&gt;
&lt;p&gt;
&lt;img src="http://www.baekdorf.dk/christian/content/binary/27_DSLVSShell_ShellNewSolution1.png" border=0&gt;
&lt;/p&gt;
&lt;p&gt;
The folder structure should look as show below.
&lt;/p&gt;
&lt;p&gt;
&lt;img src="http://www.baekdorf.dk/christian/content/binary/28_DSLVSShell_ShellNewSolutionFolder.png" border=0&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;u&gt;3. Set debugger&lt;/u&gt;
&lt;/p&gt;
&lt;p&gt;
You should set debugger type on the “MyDslShell” project to Managed Only, otherwise
you can encounter problems when trying to debug managed packages.
&lt;/p&gt;
&lt;p&gt;
&lt;img src="http://www.baekdorf.dk/christian/content/binary/28a_DSLVSShell_ShellDebugger.png" border=0&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;u&gt;4. Testing the solution&lt;/u&gt;
&lt;/p&gt;
&lt;p&gt;
Build the solution and press F5 to start, you should get an empty shell as shown below.
&lt;/p&gt;
&lt;p&gt;
&lt;img src="http://www.baekdorf.dk/christian/content/binary/29_DSLVSShell_ShellFirstTest.png" border=0&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;strong&gt;Adding a Shell Load Key (SLK)&lt;/strong&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;u&gt;1. Gathering necessary information for obtaining a SLK &lt;/u&gt;
&lt;/p&gt;
&lt;p&gt;
To obtain a SLK you will need the following information:
&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
Company name 
&lt;li&gt;
Shell name 
&lt;li&gt;
Shell Guid 
&lt;li&gt;
Shell version&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;
The information can be found in “MyDslShell” project in the file “MyDslShell.pkgdef”,
please not that you will have to add some yourself.
&lt;/p&gt;
&lt;p&gt;
The Shell Guid and Shell Name can be found in the beginning the file, as shown below.
&lt;/p&gt;
&lt;p&gt;
&lt;img src="http://www.baekdorf.dk/christian/content/binary/30_DSLVSShell_ShellFindSLKinfo1.png" border=0&gt;
&lt;/p&gt;
&lt;p&gt;
Further down in the file you find Company Name and Product version, these are commented
out, so you will have to uncomment them. The Company Name is NOT filled out by default,
so you will have to fill that in yourself.
&lt;/p&gt;
&lt;p&gt;
&lt;img src="http://www.baekdorf.dk/christian/content/binary/31_DSLVSShell_ShellFindSLKinfo2.png" border=0&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;u&gt;2. Obtaining a Shell Load Key (SLK)&lt;/u&gt;
&lt;/p&gt;
&lt;p&gt;
You can obtain a Shell Load Key (PLK) from MSDN: &lt;a href="http://msdn.microsoft.com/en-us/vsx/cc655795.aspx" target=_blank&gt;Generate
Load Keys&lt;/a&gt;
&lt;/p&gt;
&lt;p&gt;
Enter the information from the Constants.cs, choose “Standard” as Min. Product Edition
and “Visual Studio 2008” as min. VS Version. Finally press “Generate SLK”.
&lt;/p&gt;
&lt;p&gt;
&lt;img src="http://www.baekdorf.dk/christian/content/binary/32_DSLVSShell_ShellGenerateSLK.png" border=0&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;u&gt;3. Adding the Shell Load Key (SLK) to Shell&lt;/u&gt;
&lt;/p&gt;
&lt;p&gt;
We have to add the SLK to the “MyDslShell” projects resource file “MyDslShell.rc”.
Open “MyDslShell.rc” and navigate to the String Table and find the entry “IDS_SLKSTRING”
and fill in the SLK without any newlines.
&lt;/p&gt;
&lt;p&gt;
&lt;img src="http://www.baekdorf.dk/christian/content/binary/33_DSLVSShell_ShellAddSLK1.png" border=0&gt;
&lt;/p&gt;
&lt;p&gt;
Next we will have to add a value to the “MyDslShell.pkgdef” file. Find the line
&lt;/p&gt;
&lt;p&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;"ID"=dword:00000069
&lt;/p&gt;
&lt;p&gt;
and uncomment it. Make sure that you get the right line; it should be below the common
explaining SLK’s. Note the number 69, this is in hexadecimal, in decimal it will be
105 and must match the number on the above screen dump.
&lt;/p&gt;
&lt;p&gt;
&lt;img src="http://www.baekdorf.dk/christian/content/binary/34_DSLVSShell_ShellAddSLK2.png" border=0&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;strong&gt;Adding a Package Load Key (PLK)&lt;/strong&gt;
&lt;/p&gt;
&lt;p&gt;
The “MyDslShellUI” project is a Visual Studio integration package, so we need to add
a Package Load Key (PLK) to this project.
&lt;/p&gt;
&lt;p&gt;
&lt;u&gt;1. Gathering necessary information for obtaining a PLK &lt;/u&gt;
&lt;/p&gt;
&lt;p&gt;
To obtain a PLK you will need the following information:
&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
Company name 
&lt;li&gt;
Package name 
&lt;li&gt;
Package Guid 
&lt;li&gt;
Package version 
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;
The information can be found in “MyDslShell” project (note, it’s not in the “MyDslShellUI”
) in the bottom of file “MyDslShell.pkgdef”, also not that you will have to add the
company name yourself.
&lt;/p&gt;
&lt;p&gt;
&lt;img src="http://www.baekdorf.dk/christian/content/binary/35_DSLVSShell_ShellFindPLKinfo.png" border=0&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;u&gt;2. Obtaining a Package Load Key (PLK)&lt;/u&gt;
&lt;/p&gt;
&lt;p&gt;
You can obtain a Package Load Key (PLK) from MSDN: &lt;a href="http://msdn.microsoft.com/en-us/vsx/cc655795.aspx" target=_blank&gt;Generate
Load Keys&lt;/a&gt;
&lt;/p&gt;
&lt;p&gt;
Enter the information from above, choose “Standard” as Min. Product Edition and “Visual
Studio 2008” as min. VS Version. Finally press “Generate PLK”.
&lt;/p&gt;
&lt;p&gt;
&lt;img src="http://www.baekdorf.dk/christian/content/binary/36_DSLVSShell_ShellGeneratePLK.png" border=0&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;u&gt;3. Adding the Package Load Key (PLK) to the Shell UI package&lt;/u&gt;
&lt;/p&gt;
&lt;p&gt;
The Shell UI package has it’s Package Load Key (PLK) in the “MyDslShellUI.rc” file.
&lt;/p&gt;
&lt;p&gt;
&lt;img src="http://www.baekdorf.dk/christian/content/binary/37_DSLVSShell_ShellAddPLK.png" border=0&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;u&gt;4. Running and validating the Shell&lt;/u&gt;
&lt;/p&gt;
&lt;p&gt;
To test the SLK and PLK you have to add the /NoVSIP option to the debugging startup
parameter. This will make Visual Studio perform the SLK and PLK validation even when
you have you have Visual Studio SDK installed.
&lt;/p&gt;
&lt;p&gt;
&lt;img src="http://www.baekdorf.dk/christian/content/binary/38_DSLVSShell_ShellValidate.png" border=0&gt;
&lt;/p&gt;
&lt;p&gt;
Now rebuild the solution and try to run the Shell using F5
&lt;/p&gt;
&lt;p&gt;
&lt;img src="http://www.baekdorf.dk/christian/content/binary/39_DSLVSShell_ShellRunning.png" border=0&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;strong&gt;Summary&lt;/strong&gt;
&lt;/p&gt;
&lt;p&gt;
This end the third post about creating a Shell application, next step is about adding
the DSL to the Shell application.
&lt;/p&gt;
&lt;p&gt;
Next step: &lt;a href="http://www.baekdorf.dk/christian/2008/10/01/DSLAndVisualStudioShellTutorialAddingTheDSLToTheShell.aspx"&gt;Adding
the DSL to the Shell &lt;/a&gt;
&lt;/p&gt;
&lt;p&gt;
Download: &lt;a href="http://www.baekdorf.dk/christian/content/binary/DslToolsAndVsShell-03.zip" target=_blank&gt;DslToolsAndVsShell-03.zip
(5 MB)&lt;/a&gt;
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.baekdorf.dk/christian/aggbug.ashx?id=e32911b5-98de-4d62-8718-df238b8fe176" /&gt;</description>
      <comments>http://www.baekdorf.dk/christian/CommentView,guid,e32911b5-98de-4d62-8718-df238b8fe176.aspx</comments>
    </item>
    <item>
      <trackback:ping>http://www.baekdorf.dk/christian/Trackback.aspx?guid=9e98776d-2d32-4f51-9fc1-d36aa0eb32a5</trackback:ping>
      <pingback:server>http://www.baekdorf.dk/christian/pingback.aspx</pingback:server>
      <pingback:target>http://www.baekdorf.dk/christian/PermaLink,guid,9e98776d-2d32-4f51-9fc1-d36aa0eb32a5.aspx</pingback:target>
      <dc:creator>Christian B�kdorf (admin)</dc:creator>
      <wfw:comment>http://www.baekdorf.dk/christian/CommentView,guid,9e98776d-2d32-4f51-9fc1-d36aa0eb32a5.aspx</wfw:comment>
      <wfw:commentRss>http://www.baekdorf.dk/christian/SyndicationService.asmx/GetEntryCommentsRss?guid=9e98776d-2d32-4f51-9fc1-d36aa0eb32a5</wfw:commentRss>
      <slash:comments>80</slash:comments>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
          <em>Note: This post is part of a larger </em>
          <a href="http://www.baekdorf.dk/christian/2008/09/24/DSLToolsAndVisualStudio2008IsolatedShellTutorial.aspx">
            <em>tutorial
on DSL Tools and Visual Studio 2008 Isolated Shell</em>
          </a>
          <em>, in this post I will
go through creating a sample DSL that can be used for hosting in Visual Studio 2008
shell.</em>
        </p>
        <p>
Previous step: <a href="http://www.baekdorf.dk/christian/2008/09/24/DSLAndVisualStudioShellTutorialPrerequisitesAndInitialTasks.aspx">Prerequisites
and Initial tasks</a></p>
        <p>
          <strong>Creating a new DSL</strong>
        </p>
        <p>
We will start by creating a new DSL designer based on one of the standard templates.
It’s is not the intention of this guide to describe how to develop DSL’s, so for the
purpose of this guide we will just use the DSL as it is.
</p>
        <p>
          <u>1. New project</u>
        </p>
        <p>
In Visual Studio 2008, create a new DSL designer and place it in the MyDSLApplication
folder (e.g. D:\project\DslToolsAndVsShell\Code\ MyDSLApplication). Name the DSL ”MyDsl”
</p>
        <p>
          <img src="http://www.baekdorf.dk/christian/content/binary/10_DSLVSShell_DslNewProject.png" border="0" />
        </p>
        <p>
          <u>2. Choose language type and name</u>
        </p>
        <p>
Use the minimal language for this sample and name the DSL “MyDsl”.
</p>
        <p>
          <img src="http://www.baekdorf.dk/christian/content/binary/11_DSLVSShell_DslLanguageName.png" border="0" />
        </p>
        <p>
          <u>3. Choose file extension and icon</u>
        </p>
        <p>
Just accept the default file extension and icon. Please note that we will need to
use the extension later, so if you use a different extension you will also have to
use that later.
</p>
        <p>
          <img src="http://www.baekdorf.dk/christian/content/binary/12_DSLVSShell_DslExtensionIcon.png" border="0" />
        </p>
        <p>
          <u>4. Choose product and company name</u>
        </p>
        <p>
Specify a company name (we are going to use this later). Only use A-Z, space and 0-9
characters in the names.
</p>
        <p>
          <img src="http://www.baekdorf.dk/christian/content/binary/13_DSLVSShell_DslProductCompany.png" border="0" />
        </p>
        <p>
          <u>5. Strong naming</u>
        </p>
        <p>
Just create a new strong naming key.
</p>
        <p>
          <img src="http://www.baekdorf.dk/christian/content/binary/14_DSLVSShell_DslStrongName.png" border="0" />
        </p>
        <p>
          <u>6. Confirm project settings</u>
        </p>
        <p>
Just accept the settings
</p>
        <p>
          <img src="http://www.baekdorf.dk/christian/content/binary/15_DSLVSShell_DslConfirm.png" border="0" />
        </p>
        <p>
          <u>7. Project creation result</u>
        </p>
        <p>
Now you should have a solution as shown below.
</p>
        <p>
          <img src="http://www.baekdorf.dk/christian/content/binary/16_DSLVSShell_DslNewSolution.png" border="0" />
        </p>
        <p>
Your folder structure should now look as shown below.
</p>
        <p>
          <img src="http://www.baekdorf.dk/christian/content/binary/17_DSLVSShell_DslFolder.png" border="0" />
        </p>
        <p>
          <u>8. Testing the DSL</u>
        </p>
        <p>
Test the language by starting it using F5. When running you should see something like
this.
</p>
        <p>
          <img src="http://www.baekdorf.dk/christian/content/binary/18_DSLVSShell_DslFirstTest.png" border="0" />
        </p>
        <p>
          <strong>Adding a Package Load Key (PLK)</strong>
        </p>
        <p>
If we are going to distribute the final DSL application to users who don’t have Visual
Studio 2008 and Visual Studio 2008 SDK installed, we need to provide a Package Load
Key (PLK) for our DSL.
</p>
        <p>
You can learn more about VSPackage Load Keys on MSDN: <a href="http://msdn.microsoft.com/en-us/library/bb165795.aspx" target="_blank">VSPackage
Load Keys</a></p>
        <p>
          <u>1. Gathering necessary information for obtaining a PLK</u>
        </p>
        <p>
To obtain a PLK you will need the following information:
</p>
        <ul>
          <li>
Company name 
</li>
          <li>
Package name 
</li>
          <li>
Package Guid 
</li>
          <li>
Package version</li>
        </ul>
        <p>
The information can be found in DslPackage project under GeneratedCode/Constants.tt/Constants.cs
</p>
        <p>
          <img src="http://www.baekdorf.dk/christian/content/binary/19_DSLVSShell_DslFindPLKInfo.png" border="0" />
        </p>
        <p>
          <u>2. Obtaining a Package Load Key (PLK)</u>
        </p>
        <p>
You can obtain a Package Load Key (PLK) from MSDN: <a href="http://msdn.microsoft.com/en-us/vsx/cc655795.aspx" target="_blank">Generate
Load Keys</a></p>
        <p>
Enter the information from the Constants.cs, choose “Standard” as Min. Product Edition
and “Visual Studio 2008” as min. VS Version. Finally press “Generate PLK”.
</p>
        <p>
          <img src="http://www.baekdorf.dk/christian/content/binary/20_DSLVSShell_DslGeneratedPLK.png" border="0" />
        </p>
        <p>
3. Adding the Package Load Key (PLK) to DSL
</p>
        <p>
We have to add the PLK to the “DslPackage” projects resource file “VSPackage.resx”.
Give it a Name, e.g. 120, and add the key without any newlines.
</p>
        <p>
          <img src="http://www.baekdorf.dk/christian/content/binary/21_DSLVSShell_DslResourcePLK.png" border="0" />
        </p>
        <p>
Next go to the “Package.tt” file and add the following line as shown on the screen
dump below:
</p>
        <p>
[VSShell::ProvideLoadKey("Standard", Constants.ProductVersion, Constants.ProductName,
Constants.CompanyName, 120)] 
</p>
        <p>
          <img src="http://www.baekdorf.dk/christian/content/binary/22_DSLVSShell_DslAttributePLK.png" border="0" />
        </p>
        <p>
Run “Transform All” and rebuild the solution.
</p>
        <p>
          <strong>Testing the Package Load Key (PLK)</strong>
        </p>
        <p>
          <u>1. Adding the NoVSIP option</u>
        </p>
        <p>
To test the PLK you have to add the /NoVSIP option to the debugging startup parameter.
This will make Visual Studio perform the PLK validation even when you have you have
Visual Studio SDK installed.
</p>
        <p>
Add the option to the Dsl project.
</p>
        <p>
          <img src="http://www.baekdorf.dk/christian/content/binary/23_DSLVSShell_DslPropNoVSIPa.png" border="0" />
        </p>
        <p>
Add the option to the DslPackage project.
</p>
        <p>
          <img src="http://www.baekdorf.dk/christian/content/binary/24_DSLVSShell_DslPropNoVSIPb.png" border="0" />
        </p>
        <p>
          <u>2. Running and validating the DSL</u>
        </p>
        <p>
Now rebuild the solution and try to run the DSL using F5
</p>
        <p>
If everything is ok you should see you DSL again, as show below.
</p>
        <p>
          <img src="http://www.baekdorf.dk/christian/content/binary/25_DSLVSShell_DslNoVSIPConfirm.png" border="0" />
        </p>
        <p>
Please check the output window and look for the following message: “VSIP: Developer
edition disabled, normal security checks initiated.”
</p>
        <p>
If you see this message, it means that Visual Studio is validating the PLK.
</p>
        <p>
          <strong>Summary</strong>
        </p>
        <p>
This ends the second post about creating a sample DSL, next step is about creating
the Visual Studio 2008 Shell application.
</p>
        <p>
Next step: <a href="http://www.baekdorf.dk/christian/2008/09/29/DSLAndVisualStudioShellTutorialCreatingTheShellApplication.aspx">Creating
the Shell application</a></p>
        <p>
Download: <a href="http://www.baekdorf.dk/christian/content/binary/DslToolsAndVsShell-02.zip" target="_blank">DslToolsAndVsShell-02.zip
(1,04 MB)</a></p>
        <img width="0" height="0" src="http://www.baekdorf.dk/christian/aggbug.ashx?id=9e98776d-2d32-4f51-9fc1-d36aa0eb32a5" />
      </body>
      <title>DSL and Visual Studio Shell tutorial: Creating a sample DSL</title>
      <guid isPermaLink="false">http://www.baekdorf.dk/christian/PermaLink,guid,9e98776d-2d32-4f51-9fc1-d36aa0eb32a5.aspx</guid>
      <link>http://www.baekdorf.dk/christian/2008/09/27/DSLAndVisualStudioShellTutorialCreatingASampleDSL.aspx</link>
      <pubDate>Sat, 27 Sep 2008 08:40:27 GMT</pubDate>
      <description>&lt;p&gt;
&lt;em&gt;Note: This post is part of a larger &lt;/em&gt;&lt;a href="http://www.baekdorf.dk/christian/2008/09/24/DSLToolsAndVisualStudio2008IsolatedShellTutorial.aspx"&gt;&lt;em&gt;tutorial
on DSL Tools and Visual Studio 2008 Isolated Shell&lt;/em&gt;&lt;/a&gt;&lt;em&gt;, in this post I will
go through creating a sample DSL that can be used for hosting in Visual Studio 2008
shell.&lt;/em&gt; 
&lt;/p&gt;
&lt;p&gt;
Previous step: &lt;a href="http://www.baekdorf.dk/christian/2008/09/24/DSLAndVisualStudioShellTutorialPrerequisitesAndInitialTasks.aspx"&gt;Prerequisites
and Initial tasks&lt;/a&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;strong&gt;Creating a new DSL&lt;/strong&gt;
&lt;/p&gt;
&lt;p&gt;
We will start by creating a new DSL designer based on one of the standard templates.
It’s is not the intention of this guide to describe how to develop DSL’s, so for the
purpose of this guide we will just use the DSL as it is.
&lt;/p&gt;
&lt;p&gt;
&lt;u&gt;1. New project&lt;/u&gt;
&lt;/p&gt;
&lt;p&gt;
In Visual Studio 2008, create a new DSL designer and place it in the MyDSLApplication
folder (e.g. D:\project\DslToolsAndVsShell\Code\ MyDSLApplication). Name the DSL ”MyDsl”
&lt;/p&gt;
&lt;p&gt;
&lt;img src="http://www.baekdorf.dk/christian/content/binary/10_DSLVSShell_DslNewProject.png" border=0&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;u&gt;2. Choose language type and name&lt;/u&gt;
&lt;/p&gt;
&lt;p&gt;
Use the minimal language for this sample and name the DSL “MyDsl”.
&lt;/p&gt;
&lt;p&gt;
&lt;img src="http://www.baekdorf.dk/christian/content/binary/11_DSLVSShell_DslLanguageName.png" border=0&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;u&gt;3. Choose file extension and icon&lt;/u&gt;
&lt;/p&gt;
&lt;p&gt;
Just accept the default file extension and icon. Please note that we will need to
use the extension later, so if you use a different extension you will also have to
use that later.
&lt;/p&gt;
&lt;p&gt;
&lt;img src="http://www.baekdorf.dk/christian/content/binary/12_DSLVSShell_DslExtensionIcon.png" border=0&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;u&gt;4. Choose product and company name&lt;/u&gt;
&lt;/p&gt;
&lt;p&gt;
Specify a company name (we are going to use this later). Only use A-Z, space and 0-9
characters in the names.
&lt;/p&gt;
&lt;p&gt;
&lt;img src="http://www.baekdorf.dk/christian/content/binary/13_DSLVSShell_DslProductCompany.png" border=0&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;u&gt;5. Strong naming&lt;/u&gt;
&lt;/p&gt;
&lt;p&gt;
Just create a new strong naming key.
&lt;/p&gt;
&lt;p&gt;
&lt;img src="http://www.baekdorf.dk/christian/content/binary/14_DSLVSShell_DslStrongName.png" border=0&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;u&gt;6. Confirm project settings&lt;/u&gt;
&lt;/p&gt;
&lt;p&gt;
Just accept the settings
&lt;/p&gt;
&lt;p&gt;
&lt;img src="http://www.baekdorf.dk/christian/content/binary/15_DSLVSShell_DslConfirm.png" border=0&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;u&gt;7. Project creation result&lt;/u&gt;
&lt;/p&gt;
&lt;p&gt;
Now you should have a solution as shown below.
&lt;/p&gt;
&lt;p&gt;
&lt;img src="http://www.baekdorf.dk/christian/content/binary/16_DSLVSShell_DslNewSolution.png" border=0&gt;
&lt;/p&gt;
&lt;p&gt;
Your folder structure should now look as shown below.
&lt;/p&gt;
&lt;p&gt;
&lt;img src="http://www.baekdorf.dk/christian/content/binary/17_DSLVSShell_DslFolder.png" border=0&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;u&gt;8. Testing the DSL&lt;/u&gt;
&lt;/p&gt;
&lt;p&gt;
Test the language by starting it using F5. When running you should see something like
this.
&lt;/p&gt;
&lt;p&gt;
&lt;img src="http://www.baekdorf.dk/christian/content/binary/18_DSLVSShell_DslFirstTest.png" border=0&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;strong&gt;Adding a Package Load Key (PLK)&lt;/strong&gt;
&lt;/p&gt;
&lt;p&gt;
If we are going to distribute the final DSL application to users who don’t have Visual
Studio 2008 and Visual Studio 2008 SDK installed, we need to provide a Package Load
Key (PLK) for our DSL.
&lt;/p&gt;
&lt;p&gt;
You can learn more about VSPackage Load Keys on MSDN: &lt;a href="http://msdn.microsoft.com/en-us/library/bb165795.aspx" target=_blank&gt;VSPackage
Load Keys&lt;/a&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;u&gt;1. Gathering necessary information for obtaining a PLK&lt;/u&gt;
&lt;/p&gt;
&lt;p&gt;
To obtain a PLK you will need the following information:
&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
Company name 
&lt;li&gt;
Package name 
&lt;li&gt;
Package Guid 
&lt;li&gt;
Package version&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;
The information can be found in DslPackage project under GeneratedCode/Constants.tt/Constants.cs
&lt;/p&gt;
&lt;p&gt;
&lt;img src="http://www.baekdorf.dk/christian/content/binary/19_DSLVSShell_DslFindPLKInfo.png" border=0&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;u&gt;2. Obtaining a Package Load Key (PLK)&lt;/u&gt;
&lt;/p&gt;
&lt;p&gt;
You can obtain a Package Load Key (PLK) from MSDN: &lt;a href="http://msdn.microsoft.com/en-us/vsx/cc655795.aspx" target=_blank&gt;Generate
Load Keys&lt;/a&gt;
&lt;/p&gt;
&lt;p&gt;
Enter the information from the Constants.cs, choose “Standard” as Min. Product Edition
and “Visual Studio 2008” as min. VS Version. Finally press “Generate PLK”.
&lt;/p&gt;
&lt;p&gt;
&lt;img src="http://www.baekdorf.dk/christian/content/binary/20_DSLVSShell_DslGeneratedPLK.png" border=0&gt;
&lt;/p&gt;
&lt;p&gt;
3. Adding the Package Load Key (PLK) to DSL
&lt;/p&gt;
&lt;p&gt;
We have to add the PLK to the “DslPackage” projects resource file “VSPackage.resx”.
Give it a Name, e.g. 120, and add the key without any newlines.
&lt;/p&gt;
&lt;p&gt;
&lt;img src="http://www.baekdorf.dk/christian/content/binary/21_DSLVSShell_DslResourcePLK.png" border=0&gt;
&lt;/p&gt;
&lt;p&gt;
Next go to the “Package.tt” file and add the following line as shown on the screen
dump below:
&lt;/p&gt;
&lt;p&gt;
[VSShell::ProvideLoadKey("Standard", Constants.ProductVersion, Constants.ProductName,
Constants.CompanyName, 120)] 
&lt;/p&gt;
&lt;p&gt;
&lt;img src="http://www.baekdorf.dk/christian/content/binary/22_DSLVSShell_DslAttributePLK.png" border=0&gt;
&lt;/p&gt;
&lt;p&gt;
Run “Transform All” and rebuild the solution.
&lt;/p&gt;
&lt;p&gt;
&lt;strong&gt;Testing the Package Load Key (PLK)&lt;/strong&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;u&gt;1. Adding the NoVSIP option&lt;/u&gt;
&lt;/p&gt;
&lt;p&gt;
To test the PLK you have to add the /NoVSIP option to the debugging startup parameter.
This will make Visual Studio perform the PLK validation even when you have you have
Visual Studio SDK installed.
&lt;/p&gt;
&lt;p&gt;
Add the option to the Dsl project.
&lt;/p&gt;
&lt;p&gt;
&lt;img src="http://www.baekdorf.dk/christian/content/binary/23_DSLVSShell_DslPropNoVSIPa.png" border=0&gt;
&lt;/p&gt;
&lt;p&gt;
Add the option to the DslPackage project.
&lt;/p&gt;
&lt;p&gt;
&lt;img src="http://www.baekdorf.dk/christian/content/binary/24_DSLVSShell_DslPropNoVSIPb.png" border=0&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;u&gt;2. Running and validating the DSL&lt;/u&gt;
&lt;/p&gt;
&lt;p&gt;
Now rebuild the solution and try to run the DSL using F5
&lt;/p&gt;
&lt;p&gt;
If everything is ok you should see you DSL again, as show below.
&lt;/p&gt;
&lt;p&gt;
&lt;img src="http://www.baekdorf.dk/christian/content/binary/25_DSLVSShell_DslNoVSIPConfirm.png" border=0&gt;
&lt;/p&gt;
&lt;p&gt;
Please check the output window and look for the following message: “VSIP: Developer
edition disabled, normal security checks initiated.”
&lt;/p&gt;
&lt;p&gt;
If you see this message, it means that Visual Studio is validating the PLK.
&lt;/p&gt;
&lt;p&gt;
&lt;strong&gt;Summary&lt;/strong&gt;
&lt;/p&gt;
&lt;p&gt;
This ends the second post about creating a sample DSL, next step is about creating
the Visual Studio 2008 Shell application.
&lt;/p&gt;
&lt;p&gt;
Next step: &lt;a href="http://www.baekdorf.dk/christian/2008/09/29/DSLAndVisualStudioShellTutorialCreatingTheShellApplication.aspx"&gt;Creating
the Shell application&lt;/a&gt;
&lt;/p&gt;
&lt;p&gt;
Download: &lt;a href="http://www.baekdorf.dk/christian/content/binary/DslToolsAndVsShell-02.zip" target=_blank&gt;DslToolsAndVsShell-02.zip
(1,04 MB)&lt;/a&gt;
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.baekdorf.dk/christian/aggbug.ashx?id=9e98776d-2d32-4f51-9fc1-d36aa0eb32a5" /&gt;</description>
      <comments>http://www.baekdorf.dk/christian/CommentView,guid,9e98776d-2d32-4f51-9fc1-d36aa0eb32a5.aspx</comments>
    </item>
    <item>
      <trackback:ping>http://www.baekdorf.dk/christian/Trackback.aspx?guid=e6bde13a-5cd8-4098-ab7a-29b673baac4e</trackback:ping>
      <pingback:server>http://www.baekdorf.dk/christian/pingback.aspx</pingback:server>
      <pingback:target>http://www.baekdorf.dk/christian/PermaLink,guid,e6bde13a-5cd8-4098-ab7a-29b673baac4e.aspx</pingback:target>
      <dc:creator>Christian B�kdorf (admin)</dc:creator>
      <wfw:comment>http://www.baekdorf.dk/christian/CommentView,guid,e6bde13a-5cd8-4098-ab7a-29b673baac4e.aspx</wfw:comment>
      <wfw:commentRss>http://www.baekdorf.dk/christian/SyndicationService.asmx/GetEntryCommentsRss?guid=e6bde13a-5cd8-4098-ab7a-29b673baac4e</wfw:commentRss>
      <slash:comments>57</slash:comments>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
          <em>Note: This post is part of a <a href="http://www.baekdorf.dk/christian/2008/09/24/DSLToolsAndVisualStudio2008IsolatedShellTutorial.aspx">larger
tutorial on DSL Tools and Visual Studio 2008 Isolated Shell</a>, for more information
se the previous link.</em>
        </p>
        <p>
In this post I will go through some Prerequisites and Initial tasks that need to be
in place before starting the actual tutorial.
</p>
        <p>
          <strong>Prerequisites</strong>
        </p>
        <ul>
          <li>
Microsoft Visual Studio 2008 (Professional edition or larger) 
</li>
          <li>
Microsoft Visual Studio 2008 service pack 1 - <a href="http://www.microsoft.com/downloads/details.aspx?FamilyId=FBEE1648-7106-44A7-9649-6D9F6D58056E&amp;displaylang=en" target="_blank">Download</a></li>
          <li>
Microsoft Visual Studio 2008 SDK 1.1 - <a href="http://www.microsoft.com/downloads/details.aspx?FamilyID=59ec6ec3-4273-48a3-ba25-dc925a45584d&amp;displaylang=en" target="_blank">Download</a></li>
          <li>
Visual Studio 2008 Shell (isolated mode) with Service Pack 1 Redistributable Package
- <a href="http://www.microsoft.com/DOWNLOADS/details.aspx?FamilyID=021b3bee-b2ad-42a8-854a-c5eaef69e927&amp;displaylang=en" target="_blank">Download</a></li>
        </ul>
        <p>
When running the Visual Studio 2008 Shell (isolated mode) with Service Pack 1 Redistributable
package, please note that the installer only extracts the files into the “C:\VS 2008
Shell Redist\Isolated Mode” folder. After running the first installer you will need
to run “vs_shell_isolated.enu.exe” from “C:\VS 2008 Shell Redist\Isolated Mode” folder
to actual install the Visual Studio 2008 Shell.
</p>
        <p>
          <strong>Initial tasks</strong>
        </p>
        <p>
          <u>1. Create a working folder</u>
        </p>
        <p>
Start by creating an empty folder, on a local drive, for the code. In this guide we
will use: ”D:\project\DslToolsAndVsShell\Code” as shown below:
</p>
        <p>
          <img src="http://www.baekdorf.dk/christian/content/binary/02_DSLVSShell_EmptyWorkFolder1.png" border="0" />
        </p>
        <p>
          <u>2. Prepare Managed Package Framework for Projects</u>
        </p>
        <p>
Later in this tutorial we will create a new Visual Studio custom project type, to
simplify this process we will use <a href="http://www.codeplex.com/mpfproj" target="_blank">Managed
Package Framework for Projects</a> available on CodePlex.
</p>
        <p>
          <a href="http://www.codeplex.com/mpfproj/SourceControl/ListDownloadableCommits.aspx" target="_blank">Download
the Package Framework for Projects source code</a> form the CodePlex site.
</p>
        <p>
          <img src="http://www.baekdorf.dk/christian/content/binary/03_DSLVSShell_MPFP_Download.png" border="0" />
        </p>
        <p>
The download will consist of a zip file containing the source code. When you have
extracted the downloaded file you will have file structure as shown below:
</p>
        <p>
          <img src="http://www.baekdorf.dk/christian/content/binary/04_DSLVSShell_MPFP_Extracted.png" border="0" />
        </p>
        <p>
        </p>
        <p>
Create a new folder “MPFProj” under your code folder, e.g.in this guide “D:\project\DslToolsAndVsShell\Code”,
and copy the “9.0” folder from the MPFProj download to this folder new folder.
</p>
        <p>
          <img src="http://www.baekdorf.dk/christian/content/binary/05_DSLVSShell_MPFP_inplace.png" border="0" />
        </p>
        <p>
Finally create a new folder “MyDSLApplication” under the “D:\project\DslToolsAndVsShell\Code”
folder. This folder will be the base folder for the application.
</p>
        <p>
          <img src="http://www.baekdorf.dk/christian/content/binary/06_DSLVSShell_appbasefolder.png" border="0" />
        </p>
        <p>
          <u>Summary</u>
        </p>
        <p>
This ends the first post about prerequisites and initial tasks, next is creating the
DSL that we want to host in Visual Studio 2008 Shell.
</p>
        <p>
Next step: <a href="http://www.baekdorf.dk/christian/2008/09/27/DSLAndVisualStudioShellTutorialCreatingASampleDSL.aspx">Creating
a sample DSL</a></p>
        <p>
Download: <a href="http://www.baekdorf.dk/christian/content/binary/DslToolsAndVsShell-01.zip" target="_blank">DslToolsAndVsShell-01.zip
(510,1 KB)</a></p>
        <img width="0" height="0" src="http://www.baekdorf.dk/christian/aggbug.ashx?id=e6bde13a-5cd8-4098-ab7a-29b673baac4e" />
      </body>
      <title>DSL and Visual Studio Shell tutorial: Prerequisites and Initial tasks</title>
      <guid isPermaLink="false">http://www.baekdorf.dk/christian/PermaLink,guid,e6bde13a-5cd8-4098-ab7a-29b673baac4e.aspx</guid>
      <link>http://www.baekdorf.dk/christian/2008/09/24/DSLAndVisualStudioShellTutorialPrerequisitesAndInitialTasks.aspx</link>
      <pubDate>Wed, 24 Sep 2008 18:53:51 GMT</pubDate>
      <description>&lt;p&gt;
&lt;em&gt;Note: This post is part of a &lt;a href="http://www.baekdorf.dk/christian/2008/09/24/DSLToolsAndVisualStudio2008IsolatedShellTutorial.aspx"&gt;larger
tutorial on DSL Tools and Visual Studio 2008 Isolated Shell&lt;/a&gt;, for more information
se the previous link.&lt;/em&gt;
&lt;/p&gt;
&lt;p&gt;
In this post I will go through some Prerequisites and Initial tasks that need to be
in place before starting the actual tutorial.
&lt;/p&gt;
&lt;p&gt;
&lt;strong&gt;Prerequisites&lt;/strong&gt;
&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
Microsoft Visual Studio 2008 (Professional edition or larger) 
&lt;li&gt;
Microsoft Visual Studio 2008 service pack 1 - &lt;a href="http://www.microsoft.com/downloads/details.aspx?FamilyId=FBEE1648-7106-44A7-9649-6D9F6D58056E&amp;amp;displaylang=en" target=_blank&gt;Download&lt;/a&gt; 
&lt;li&gt;
Microsoft Visual Studio 2008 SDK 1.1 - &lt;a href="http://www.microsoft.com/downloads/details.aspx?FamilyID=59ec6ec3-4273-48a3-ba25-dc925a45584d&amp;amp;displaylang=en" target=_blank&gt;Download&lt;/a&gt; 
&lt;li&gt;
Visual Studio 2008 Shell (isolated mode) with Service Pack 1 Redistributable Package
- &lt;a href="http://www.microsoft.com/DOWNLOADS/details.aspx?FamilyID=021b3bee-b2ad-42a8-854a-c5eaef69e927&amp;amp;displaylang=en" target=_blank&gt;Download&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;
When running the Visual Studio 2008 Shell (isolated mode) with Service Pack 1 Redistributable
package, please note that the installer only extracts the files into the “C:\VS 2008
Shell Redist\Isolated Mode” folder. After running the first installer you will need
to run “vs_shell_isolated.enu.exe” from “C:\VS 2008 Shell Redist\Isolated Mode” folder
to actual install the Visual Studio 2008 Shell.
&lt;/p&gt;
&lt;p&gt;
&lt;strong&gt;Initial tasks&lt;/strong&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;u&gt;1. Create a working folder&lt;/u&gt;
&lt;/p&gt;
&lt;p&gt;
Start by creating an empty folder, on a local drive, for the code. In this guide we
will use: ”D:\project\DslToolsAndVsShell\Code” as shown below:
&lt;/p&gt;
&lt;p&gt;
&lt;img src="http://www.baekdorf.dk/christian/content/binary/02_DSLVSShell_EmptyWorkFolder1.png" border=0&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;u&gt;2. Prepare Managed Package Framework for Projects&lt;/u&gt;
&lt;/p&gt;
&lt;p&gt;
Later in this tutorial we will create a new Visual Studio custom project type, to
simplify this process we will use &lt;a href="http://www.codeplex.com/mpfproj" target=_blank&gt;Managed
Package Framework for Projects&lt;/a&gt; available on CodePlex.
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://www.codeplex.com/mpfproj/SourceControl/ListDownloadableCommits.aspx" target=_blank&gt;Download
the Package Framework for Projects source code&lt;/a&gt; form the CodePlex site.
&lt;/p&gt;
&lt;p&gt;
&lt;img src="http://www.baekdorf.dk/christian/content/binary/03_DSLVSShell_MPFP_Download.png" border=0&gt;
&lt;/p&gt;
&lt;p&gt;
The download will consist of a zip file containing the source code. When you have
extracted the downloaded file you will have file structure as shown below:
&lt;/p&gt;
&lt;p&gt;
&lt;img src="http://www.baekdorf.dk/christian/content/binary/04_DSLVSShell_MPFP_Extracted.png" border=0&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;/p&gt;
&lt;p&gt;
Create a new folder “MPFProj” under your code folder, e.g.in this guide “D:\project\DslToolsAndVsShell\Code”,
and copy the “9.0” folder from the MPFProj download to this folder new folder.
&lt;/p&gt;
&lt;p&gt;
&lt;img src="http://www.baekdorf.dk/christian/content/binary/05_DSLVSShell_MPFP_inplace.png" border=0&gt;
&lt;/p&gt;
&lt;p&gt;
Finally create a new folder “MyDSLApplication” under the “D:\project\DslToolsAndVsShell\Code”
folder. This folder will be the base folder for the application.
&lt;/p&gt;
&lt;p&gt;
&lt;img src="http://www.baekdorf.dk/christian/content/binary/06_DSLVSShell_appbasefolder.png" border=0&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;u&gt;Summary&lt;/u&gt;
&lt;/p&gt;
&lt;p&gt;
This ends the first post about prerequisites and initial tasks, next is creating the
DSL that we want to host in Visual Studio 2008 Shell.
&lt;/p&gt;
&lt;p&gt;
Next step: &lt;a href="http://www.baekdorf.dk/christian/2008/09/27/DSLAndVisualStudioShellTutorialCreatingASampleDSL.aspx"&gt;Creating
a sample DSL&lt;/a&gt;
&lt;/p&gt;
&lt;p&gt;
Download: &lt;a href="http://www.baekdorf.dk/christian/content/binary/DslToolsAndVsShell-01.zip" target=_blank&gt;DslToolsAndVsShell-01.zip
(510,1 KB)&lt;/a&gt;
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.baekdorf.dk/christian/aggbug.ashx?id=e6bde13a-5cd8-4098-ab7a-29b673baac4e" /&gt;</description>
      <comments>http://www.baekdorf.dk/christian/CommentView,guid,e6bde13a-5cd8-4098-ab7a-29b673baac4e.aspx</comments>
    </item>
    <item>
      <trackback:ping>http://www.baekdorf.dk/christian/Trackback.aspx?guid=0b7f33de-2e46-4ae0-ba25-712aba397cb9</trackback:ping>
      <pingback:server>http://www.baekdorf.dk/christian/pingback.aspx</pingback:server>
      <pingback:target>http://www.baekdorf.dk/christian/PermaLink,guid,0b7f33de-2e46-4ae0-ba25-712aba397cb9.aspx</pingback:target>
      <dc:creator>Christian B�kdorf (admin)</dc:creator>
      <wfw:comment>http://www.baekdorf.dk/christian/CommentView,guid,0b7f33de-2e46-4ae0-ba25-712aba397cb9.aspx</wfw:comment>
      <wfw:commentRss>http://www.baekdorf.dk/christian/SyndicationService.asmx/GetEntryCommentsRss?guid=0b7f33de-2e46-4ae0-ba25-712aba397cb9</wfw:commentRss>
      <slash:comments>56</slash:comments>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
          <a href="http://msdn.microsoft.com/en-us/library/bb126235.aspx" target="_blank">Microsoft
DSL Tools</a> provides an easy way to create visual languages and designers that can
be hosted in Visual Studio 2008, but sometimes it could be interesting to distribute
the designers to user who don’t have Visual Studio 2008 installed. This can be archived
by using the <a href="http://msdn.microsoft.com/en-us/vsx2008/products/bb933751.aspx" target="_blank">Visual
Studio 2008 Isolated Shell</a> to host the DSL designers, but implementing this can
be a difficult process. 
</p>
        <p>
As a sample of this kind of application you can look at the <a href="http://www.codeplex.com/storyboarddesigner" target="_blank">Storyboard
designer on CodePlex</a> or the screen dump below.
</p>
        <p>
          <img src="http://www.baekdorf.dk/christian/content/binary/01_DSLVSShell_SampleApp.png" border="0" />
        </p>
        <p>
After spending some time on creating a standalone application based on Microsoft DSL
Tools and Microsoft Visual Studio 2008 Shell (isolated), I have decided to write end-to-end
tutorial describing all the steps necessary to create a fully deployable standalone
DSL Tools based application that can be used without Visual Studio 2008 installed.
All the information on how to create such an application is available on the Internet,
but only as separate pieces, so it can be difficult putting it all together.
</p>
        <p>
The primary audience for this tutorial will be developers familiar with DSL Tools
who wants to create a standalone DSL application, but don’t have a lot of experience
with Visual Studio extensibility and Visual Studio Shell development in general. Anybody
else interested in the subject can of cause also use the tutorial. I will not spend
a lot of time on DSL Tools, the focus will be on how to create a standalone application
based on a DSL designer.
</p>
        <p>
I will post the tutorial on my blog as it progresses and add links from this post.
</p>
        <p>
Table of content (links will be add when new posts come)
</p>
        <ul>
          <li>
            <a href="http://www.baekdorf.dk/christian/2008/09/24/DSLAndVisualStudioShellTutorialPrerequisitesAndInitialTasks.aspx">Prerequisites
and Initial tasks</a>
          </li>
          <li>
            <a href="http://www.baekdorf.dk/christian/2008/09/27/DSLAndVisualStudioShellTutorialCreatingASampleDSL.aspx">Creating
a sample DSL</a>
          </li>
          <li>
            <a href="http://www.baekdorf.dk/christian/2008/09/29/DSLAndVisualStudioShellTutorialCreatingTheShellApplication.aspx">Creating
the Shell application</a>
          </li>
          <li>
            <a href="http://www.baekdorf.dk/christian/2008/10/01/DSLAndVisualStudioShellTutorialAddingTheDSLToTheShell.aspx">Adding
the DSL to the Shell</a>
          </li>
          <li>
            <a href="http://www.baekdorf.dk/christian/2008/10/08/DSLAndVisualStudioShellTutorialCreatingACustomProjectType.aspx">Creating
a custom project type</a>
          </li>
          <li>
            <a href="http://www.baekdorf.dk/christian/2008/12/02/DSLAndVisualStudioShellTutorialCreatingASetupPackage.aspx">Creating
a setup package</a>
          </li>
        </ul>
        <img width="0" height="0" src="http://www.baekdorf.dk/christian/aggbug.ashx?id=0b7f33de-2e46-4ae0-ba25-712aba397cb9" />
      </body>
      <title>DSL Tools and Visual Studio 2008 Isolated Shell (tutorial)</title>
      <guid isPermaLink="false">http://www.baekdorf.dk/christian/PermaLink,guid,0b7f33de-2e46-4ae0-ba25-712aba397cb9.aspx</guid>
      <link>http://www.baekdorf.dk/christian/2008/09/24/DSLToolsAndVisualStudio2008IsolatedShellTutorial.aspx</link>
      <pubDate>Wed, 24 Sep 2008 18:11:37 GMT</pubDate>
      <description>&lt;p&gt;
&lt;a href="http://msdn.microsoft.com/en-us/library/bb126235.aspx" target=_blank&gt;Microsoft
DSL Tools&lt;/a&gt; provides an easy way to create visual languages and designers that can
be hosted in Visual Studio 2008, but sometimes it could be interesting to distribute
the designers to user who don’t have Visual Studio 2008 installed. This can be archived
by using the &lt;a href="http://msdn.microsoft.com/en-us/vsx2008/products/bb933751.aspx" target=_blank&gt;Visual
Studio 2008 Isolated Shell&lt;/a&gt; to host the DSL designers, but implementing this can
be a difficult process. 
&lt;/p&gt;
&lt;p&gt;
As a sample of this kind of application you can look at the &lt;a href="http://www.codeplex.com/storyboarddesigner" target=_blank&gt;Storyboard
designer on CodePlex&lt;/a&gt; or the screen dump below.
&lt;/p&gt;
&lt;p&gt;
&lt;img src="http://www.baekdorf.dk/christian/content/binary/01_DSLVSShell_SampleApp.png" border=0&gt;
&lt;/p&gt;
&lt;p&gt;
After spending some time on creating a standalone application based on Microsoft DSL
Tools and Microsoft Visual Studio 2008 Shell (isolated), I have decided to write end-to-end
tutorial describing all the steps necessary to create a fully deployable standalone
DSL Tools based application that can be used without Visual Studio 2008 installed.
All the information on how to create such an application is available on the Internet,
but only as separate pieces, so it can be difficult putting it all together.
&lt;/p&gt;
&lt;p&gt;
The primary audience for this tutorial will be developers familiar with DSL Tools
who wants to create a standalone DSL application, but don’t have a lot of experience
with Visual Studio extensibility and Visual Studio Shell development in general. Anybody
else interested in the subject can of cause also use the tutorial. I will not spend
a lot of time on DSL Tools, the focus will be on how to create a standalone application
based on a DSL designer.
&lt;/p&gt;
&lt;p&gt;
I will post the tutorial on my blog as it progresses and add links from this post.
&lt;/p&gt;
&lt;p&gt;
Table of content (links will be add when new posts come)
&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;a href="http://www.baekdorf.dk/christian/2008/09/24/DSLAndVisualStudioShellTutorialPrerequisitesAndInitialTasks.aspx"&gt;Prerequisites
and Initial tasks&lt;/a&gt; 
&lt;li&gt;
&lt;a href="http://www.baekdorf.dk/christian/2008/09/27/DSLAndVisualStudioShellTutorialCreatingASampleDSL.aspx"&gt;Creating
a sample DSL&lt;/a&gt; 
&lt;li&gt;
&lt;a href="http://www.baekdorf.dk/christian/2008/09/29/DSLAndVisualStudioShellTutorialCreatingTheShellApplication.aspx"&gt;Creating
the Shell application&lt;/a&gt; 
&lt;li&gt;
&lt;a href="http://www.baekdorf.dk/christian/2008/10/01/DSLAndVisualStudioShellTutorialAddingTheDSLToTheShell.aspx"&gt;Adding
the DSL to the Shell&lt;/a&gt; 
&lt;li&gt;
&lt;a href="http://www.baekdorf.dk/christian/2008/10/08/DSLAndVisualStudioShellTutorialCreatingACustomProjectType.aspx"&gt;Creating
a custom project type&lt;/a&gt; 
&lt;li&gt;
&lt;a href="http://www.baekdorf.dk/christian/2008/12/02/DSLAndVisualStudioShellTutorialCreatingASetupPackage.aspx"&gt;Creating
a setup package&lt;/a&gt; 
&lt;/li&gt;
&lt;/ul&gt;
&lt;img width="0" height="0" src="http://www.baekdorf.dk/christian/aggbug.ashx?id=0b7f33de-2e46-4ae0-ba25-712aba397cb9" /&gt;</description>
      <comments>http://www.baekdorf.dk/christian/CommentView,guid,0b7f33de-2e46-4ae0-ba25-712aba397cb9.aspx</comments>
    </item>
    <item>
      <trackback:ping>http://www.baekdorf.dk/christian/Trackback.aspx?guid=f82d01d7-2ff5-4bde-914a-be2cabef315c</trackback:ping>
      <pingback:server>http://www.baekdorf.dk/christian/pingback.aspx</pingback:server>
      <pingback:target>http://www.baekdorf.dk/christian/PermaLink,guid,f82d01d7-2ff5-4bde-914a-be2cabef315c.aspx</pingback:target>
      <dc:creator>Christian B�kdorf (admin)</dc:creator>
      <wfw:comment>http://www.baekdorf.dk/christian/CommentView,guid,f82d01d7-2ff5-4bde-914a-be2cabef315c.aspx</wfw:comment>
      <wfw:commentRss>http://www.baekdorf.dk/christian/SyndicationService.asmx/GetEntryCommentsRss?guid=f82d01d7-2ff5-4bde-914a-be2cabef315c</wfw:commentRss>
      <slash:comments>137</slash:comments>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
In this small tutorial I will show how to create a simple <a href="http://msdn.microsoft.com/en-us/library/aa381223(VS.85).aspx" target="_blank">UPnP
hosted device</a> containing a simple HelloWorld service using C# and the Windows
UPnP framework.
</p>
        <p>
Windows UPnP is available in Windows XP, Vista and 2008 Server, but not in Windows
2003 Server. If you want UPnP on Windows 2003, have a look at the <a href="http://www.intel.com/cd/ids/developer/asmo-na/eng/downloads/upnp/tools/index.htm" target="_blank">Intel
UPnP stack</a>.
</p>
        <p>
I will not explain the basic concepts of UPnP, so if you don’t feel familiar with
basic UPnP concepts it might be at good idea to look at some of the documentation
at <a href="http://upnp.org" target="_blank">UPNP.ORG</a> or <a href="http://msdn.microsoft.com/en-us/library/aa382303%28VS.85%29.aspx" target="_blank">MSDN</a>.
</p>
        <p>
Intel has some great tools for working with UPnP and I will be using these during
the tutorial, so it would a good idea to install then if you want to go through the
steps. They can be downloaded from <a href="http://www.intel.com/cd/ids/developer/asmo-na/eng/downloads/upnp/tools/index.htm" target="_blank">Intel’s
website</a>, pick <a href="http://softwarecommunity.intel.com/isn/downloads/zips/IntelToolsForUPnPTechnology_v2.zip" target="_blank">Intel®
Tools for UPnP Technologies (Build 2777) and the .NET 2.0 CLR edition</a>.
</p>
        <p>
          <strong>Designing/specifying the service</strong>
        </p>
        <p>
First steps is to create a services description, this is just like an interface for
the service – specifying methods, properties and events. This is done in an XML file,
see paragraph 2.3 of <a href="http://upnp.org/specs/arch/UPnP-arch-DeviceArchitecture-v1.0-20080424.pdf" target="_blank">UPnP
Device Architecture 1.0</a> for a detailed description of the XML format.
</p>
        <p>
For this example we will just create a simple “HelloWorld” service that can return
a simple text message, so we will have a services description as shown below:
</p>
        <p>
          <!--
{\rtf1\ansi\ansicpg\lang1024\noproof65001\uc1 \deff0{\fonttbl{\f0\fnil\fcharset0\fprq1 Courier New;}}{\colortbl;??\red0\green0\blue255;\red255\green255\blue255;\red163\green21\blue21;\red255\green0\blue0;\red0\green0\blue0;}??\fs24 \cf1 &lt;?\cf3 xml\cf1  \cf4 version\cf1 =\cf0 "\cf1 1.0\cf0 "\cf1  \cf4 encoding\cf1 =\cf0 "\cf1 utf-8\cf0 "\cf1 ?&gt;\par ??&lt;\cf3 scpd\cf1  \cf4 xmlns\cf1 =\cf0 "\cf1 urn:schemas-upnp-org:service-1-0\cf0 "\cf1 &gt;\par ??   &lt;\cf3 specVersion\cf1 &gt;\par ??      &lt;\cf3 major\cf1 &gt;\cf0 1\cf1 &lt;/\cf3 major\cf1 &gt;\par ??      &lt;\cf3 minor\cf1 &gt;\cf0 0\cf1 &lt;/\cf3 minor\cf1 &gt;\par ??   &lt;/\cf3 specVersion\cf1 &gt;\par ??   &lt;\cf3 actionList\cf1 &gt;\par ??      &lt;\cf3 action\cf1 &gt;\par ??         &lt;\cf3 name\cf1 &gt;\cf0 HelloWorld\cf1 &lt;/\cf3 name\cf1 &gt;\par ??         &lt;\cf3 argumentList\cf1 &gt;\par ??            &lt;\cf3 argument\cf1 &gt;\par ??               &lt;\cf3 name\cf1 &gt;\cf0 message\cf1 &lt;/\cf3 name\cf1 &gt;\par ??               &lt;\cf3 direction\cf1 &gt;\cf0 out\cf1 &lt;/\cf3 direction\cf1 &gt;\par ??               &lt;\cf3 retval\cf1  /&gt;\par ??               &lt;\cf3 relatedStateVariable\cf1 &gt;\cf0 Message\cf1 &lt;/\cf3 relatedStateVariable\cf1 &gt;\par ??            &lt;/\cf3 argument\cf1 &gt;\par ??         &lt;/\cf3 argumentList\cf1 &gt;\par ??      &lt;/\cf3 action\cf1 &gt;\par ??   &lt;/\cf3 actionList\cf1 &gt;\par ??   &lt;\cf3 serviceStateTable\cf1 &gt;\par ??      &lt;\cf3 stateVariable\cf1  \cf4 sendEvents\cf1 =\cf0 "\cf1 no\cf0 "\cf1 &gt;\par ??         &lt;\cf3 name\cf1 &gt;\cf0 Message\cf1 &lt;/\cf3 name\cf1 &gt;\par ??         &lt;\cf3 dataType\cf1 &gt;\cf0 string\cf1 &lt;/\cf3 dataType\cf1 &gt;\par ??      &lt;/\cf3 stateVariable\cf1 &gt;\par ??   &lt;/\cf3 serviceStateTable\cf1 &gt;\par ??&lt;/\cf3 scpd\cf1 &gt;}
-->
        </p>
        <div style="FONT-SIZE: 9pt; BACKGROUND: white; COLOR: black; FONT-FAMILY: Courier New">
          <p style="MARGIN: 0px">
            <span style="COLOR: blue">&lt;?</span>
            <span style="COLOR: #a31515">xml</span>
            <span style="COLOR: blue">
            </span>
            <span style="COLOR: red">version</span>
            <span style="COLOR: blue">=</span>"<span style="COLOR: blue">1.0</span>"<span style="COLOR: blue"></span><span style="COLOR: red">encoding</span><span style="COLOR: blue">=</span>"<span style="COLOR: blue">utf-8</span>"<span style="COLOR: blue">?&gt;</span></p>
          <p style="MARGIN: 0px">
            <span style="COLOR: blue">&lt;</span>
            <span style="COLOR: #a31515">scpd</span>
            <span style="COLOR: blue">
            </span>
            <span style="COLOR: red">xmlns</span>
            <span style="COLOR: blue">=</span>"<span style="COLOR: blue">urn:schemas-upnp-org:service-1-0</span>"<span style="COLOR: blue">&gt;</span></p>
          <p style="MARGIN: 0px">
            <span style="COLOR: blue">  &lt;</span>
            <span style="COLOR: #a31515">specVersion</span>
            <span style="COLOR: blue">&gt;</span>
          </p>
          <p style="MARGIN: 0px">
            <span style="COLOR: blue">      &lt;</span>
            <span style="COLOR: #a31515">major</span>
            <span style="COLOR: blue">&gt;</span>1<span style="COLOR: blue">&lt;/</span><span style="COLOR: #a31515">major</span><span style="COLOR: blue">&gt;</span></p>
          <p style="MARGIN: 0px">
            <span style="COLOR: blue">      &lt;</span>
            <span style="COLOR: #a31515">minor</span>
            <span style="COLOR: blue">&gt;</span>0<span style="COLOR: blue">&lt;/</span><span style="COLOR: #a31515">minor</span><span style="COLOR: blue">&gt;</span></p>
          <p style="MARGIN: 0px">
            <span style="COLOR: blue">  &lt;/</span>
            <span style="COLOR: #a31515">specVersion</span>
            <span style="COLOR: blue">&gt;</span>
          </p>
          <p style="MARGIN: 0px">
            <span style="COLOR: blue">  &lt;</span>
            <span style="COLOR: #a31515">actionList</span>
            <span style="COLOR: blue">&gt;</span>
          </p>
          <p style="MARGIN: 0px">
            <span style="COLOR: blue">      &lt;</span>
            <span style="COLOR: #a31515">action</span>
            <span style="COLOR: blue">&gt;</span>
          </p>
          <p style="MARGIN: 0px">
            <span style="COLOR: blue">        &lt;</span>
            <span style="COLOR: #a31515">name</span>
            <span style="COLOR: blue">&gt;</span>HelloWorld<span style="COLOR: blue">&lt;/</span><span style="COLOR: #a31515">name</span><span style="COLOR: blue">&gt;</span></p>
          <p style="MARGIN: 0px">
            <span style="COLOR: blue">        &lt;</span>
            <span style="COLOR: #a31515">argumentList</span>
            <span style="COLOR: blue">&gt;</span>
          </p>
          <p style="MARGIN: 0px">
            <span style="COLOR: blue">            &lt;</span>
            <span style="COLOR: #a31515">argument</span>
            <span style="COLOR: blue">&gt;</span>
          </p>
          <p style="MARGIN: 0px">
            <span style="COLOR: blue">              &lt;</span>
            <span style="COLOR: #a31515">name</span>
            <span style="COLOR: blue">&gt;</span>message<span style="COLOR: blue">&lt;/</span><span style="COLOR: #a31515">name</span><span style="COLOR: blue">&gt;</span></p>
          <p style="MARGIN: 0px">
            <span style="COLOR: blue">              &lt;</span>
            <span style="COLOR: #a31515">direction</span>
            <span style="COLOR: blue">&gt;</span>out<span style="COLOR: blue">&lt;/</span><span style="COLOR: #a31515">direction</span><span style="COLOR: blue">&gt;</span></p>
          <p style="MARGIN: 0px">
            <span style="COLOR: blue">              &lt;</span>
            <span style="COLOR: #a31515">retval</span>
            <span style="COLOR: blue"> /&gt;</span>
          </p>
          <p style="MARGIN: 0px">
            <span style="COLOR: blue">              &lt;</span>
            <span style="COLOR: #a31515">relatedStateVariable</span>
            <span style="COLOR: blue">&gt;</span>Message<span style="COLOR: blue">&lt;/</span><span style="COLOR: #a31515">relatedStateVariable</span><span style="COLOR: blue">&gt;</span></p>
          <p style="MARGIN: 0px">
            <span style="COLOR: blue">            &lt;/</span>
            <span style="COLOR: #a31515">argument</span>
            <span style="COLOR: blue">&gt;</span>
          </p>
          <p style="MARGIN: 0px">
            <span style="COLOR: blue">        &lt;/</span>
            <span style="COLOR: #a31515">argumentList</span>
            <span style="COLOR: blue">&gt;</span>
          </p>
          <p style="MARGIN: 0px">
            <span style="COLOR: blue">      &lt;/</span>
            <span style="COLOR: #a31515">action</span>
            <span style="COLOR: blue">&gt;</span>
          </p>
          <p style="MARGIN: 0px">
            <span style="COLOR: blue">  &lt;/</span>
            <span style="COLOR: #a31515">actionList</span>
            <span style="COLOR: blue">&gt;</span>
          </p>
          <p style="MARGIN: 0px">
            <span style="COLOR: blue">  &lt;</span>
            <span style="COLOR: #a31515">serviceStateTable</span>
            <span style="COLOR: blue">&gt;</span>
          </p>
          <p style="MARGIN: 0px">
            <span style="COLOR: blue">      &lt;</span>
            <span style="COLOR: #a31515">stateVariable</span>
            <span style="COLOR: blue">
            </span>
            <span style="COLOR: red">sendEvents</span>
            <span style="COLOR: blue">=</span>"<span style="COLOR: blue">no</span>"<span style="COLOR: blue">&gt;</span></p>
          <p style="MARGIN: 0px">
            <span style="COLOR: blue">        &lt;</span>
            <span style="COLOR: #a31515">name</span>
            <span style="COLOR: blue">&gt;</span>Message<span style="COLOR: blue">&lt;/</span><span style="COLOR: #a31515">name</span><span style="COLOR: blue">&gt;</span></p>
          <p style="MARGIN: 0px">
            <span style="COLOR: blue">        &lt;</span>
            <span style="COLOR: #a31515">dataType</span>
            <span style="COLOR: blue">&gt;</span>string<span style="COLOR: blue">&lt;/</span><span style="COLOR: #a31515">dataType</span><span style="COLOR: blue">&gt;</span></p>
          <p style="MARGIN: 0px">
            <span style="COLOR: blue">      &lt;/</span>
            <span style="COLOR: #a31515">stateVariable</span>
            <span style="COLOR: blue">&gt;</span>
          </p>
          <p style="MARGIN: 0px">
            <span style="COLOR: blue">  &lt;/</span>
            <span style="COLOR: #a31515">serviceStateTable</span>
            <span style="COLOR: blue">&gt;</span>
          </p>
          <p style="MARGIN: 0px">
            <span style="COLOR: blue">&lt;/</span>
            <span style="COLOR: #a31515">scpd</span>
            <span style="COLOR: blue">&gt;</span>
          </p>
        </div>
        <p>
        </p>
        <p>
Specifying this service could be done using any text editor or by using the Intel
Service Author application which comes a part of the Intel tools for UPnP.
</p>
        <p>
          <img src="http://www.baekdorf.dk/christian/content/binary/01_IntelServiceAuthor.PNG" border="0" />
        </p>
        <p>
          <strong>Designing/specifying the device</strong>
        </p>
        <p>
Next we need to create a device specification; this is a specification of the services
that should be published and other meta-information related to the devices and services.
This will also be represented by an XML file, see paragraph 2.1 of <a href="http://upnp.org/specs/arch/UPnP-arch-DeviceArchitecture-v1.0-20080424.pdf" target="_blank">UPnP
Device Architecture 1.0</a> and <a href="http://msdn.microsoft.com/en-us/library/aa381130(VS.85).aspx" target="_blank">Creating
a Device Description on MSDN</a> for a detailed description of the XML format.
</p>
        <p>
Sample device description:
</p>
        <p>
          <!--
{\rtf1\ansi\ansicpg\lang1024\noproof65001\uc1 \deff0{\fonttbl{\f0\fnil\fcharset0\fprq1 Courier New;}}{\colortbl;??\red0\green0\blue255;\red255\green255\blue255;\red163\green21\blue21;\red255\green0\blue0;\red0\green0\blue0;}??\fs24 \cf1 &lt;?\cf3 xml\cf1  \cf4 version\cf1 =\cf0 "\cf1 1.0\cf0 "\cf1 ?&gt;\par ??&lt;\cf3 root\cf1  \cf4 xmlns\cf1 =\cf0 "\cf1 urn:schemas-upnp-org:device-1-0\cf0 "\cf1 &gt;\par ??  &lt;\cf3 specVersion\cf1 &gt;\par ??    &lt;\cf3 major\cf1 &gt;\cf0 1\cf1 &lt;/\cf3 major\cf1 &gt;\par ??    &lt;\cf3 minor\cf1 &gt;\cf0 0\cf1 &lt;/\cf3 minor\cf1 &gt;\par ??  &lt;/\cf3 specVersion\cf1 &gt;\par ??  &lt;\cf3 device\cf1 &gt;\par ??    &lt;\cf3 deviceType\cf1 &gt;\cf0 urn:schemas-mycompany-net:device:MyDevice:1\cf1 &lt;/\cf3 deviceType\cf1 &gt;\par ??    &lt;\cf3 presentationURL\cf1 &gt;&lt;/\cf3 presentationURL\cf1 &gt;\par ??    &lt;\cf3 friendlyName\cf1 &gt;\cf0 MyDevice\cf1 &lt;/\cf3 friendlyName\cf1 &gt;\par ??    &lt;\cf3 manufacturer\cf1 &gt;\cf0 My Company\cf1 &lt;/\cf3 manufacturer\cf1 &gt;\par ??    &lt;\cf3 manufacturerURL\cf1 &gt;\cf0 http://www.mycompany.net\cf1 &lt;/\cf3 manufacturerURL\cf1 &gt;\par ??    &lt;\cf3 modelDescription\cf1 &gt;\cf0 Just some sample stuff\cf1 &lt;/\cf3 modelDescription\cf1 &gt;\par ??    &lt;\cf3 modelName\cf1 &gt;\cf0 My Device X\cf1 &lt;/\cf3 modelName\cf1 &gt;\par ??    &lt;\cf3 modelNumber\cf1 &gt;\cf0 X\cf1 &lt;/\cf3 modelNumber\cf1 &gt;\par ??    &lt;\cf3 modelURL\cf1 &gt;\cf0 http://www.mycompany.net\cf1 &lt;/\cf3 modelURL\cf1 &gt;\par ??    &lt;\cf3 serialNumber\cf1 &gt;\cf0 0000001\cf1 &lt;/\cf3 serialNumber\cf1 &gt;\par ??    &lt;\cf3 UDN\cf1 &gt;\cf0 uuid:RootDevice\cf1 &lt;/\cf3 UDN\cf1 &gt;\par ??    &lt;\cf3 UPC\cf1 &gt;\cf0 00000-00001\cf1 &lt;/\cf3 UPC\cf1 &gt;\par ??    &lt;\cf3 serviceList\cf1 &gt;\par ??      &lt;\cf3 service\cf1 &gt;\par ??        &lt;\cf3 serviceType\cf1 &gt;\cf0 urn:schemas-mycompany-net:service:MyService:1\cf1 &lt;/\cf3 serviceType\cf1 &gt;\par ??        &lt;\cf3 serviceId\cf1 &gt;\cf0 urn:upnp-mycompany-net:MyService:1\cf1 &lt;/\cf3 serviceId\cf1 &gt;\par ??        &lt;\cf3 controlURL\cf1 &gt;&lt;/\cf3 controlURL\cf1 &gt;\par ??        &lt;\cf3 eventSubURL\cf1 &gt;&lt;/\cf3 eventSubURL\cf1 &gt;\par ??        &lt;\cf3 SCPDURL\cf1 &gt;\cf0 MyService.xml\cf1 &lt;/\cf3 SCPDURL\cf1 &gt;\par ??      &lt;/\cf3 service\cf1 &gt;\par ??    &lt;/\cf3 serviceList\cf1 &gt;\par ??  &lt;/\cf3 device\cf1 &gt;\par ??&lt;/\cf3 root\cf1 &gt;\par ??}
-->
        </p>
        <div style="FONT-SIZE: 9pt; BACKGROUND: white; COLOR: black; FONT-FAMILY: Courier New">
          <p style="MARGIN: 0px">
            <span style="COLOR: blue">&lt;?</span>
            <span style="COLOR: #a31515">xml</span>
            <span style="COLOR: blue">
            </span>
            <span style="COLOR: red">version</span>
            <span style="COLOR: blue">=</span>"<span style="COLOR: blue">1.0</span>"<span style="COLOR: blue">?&gt;</span></p>
          <p style="MARGIN: 0px">
            <span style="COLOR: blue">&lt;</span>
            <span style="COLOR: #a31515">root</span>
            <span style="COLOR: blue">
            </span>
            <span style="COLOR: red">xmlns</span>
            <span style="COLOR: blue">=</span>"<span style="COLOR: blue">urn:schemas-upnp-org:device-1-0</span>"<span style="COLOR: blue">&gt;</span></p>
          <p style="MARGIN: 0px">
            <span style="COLOR: blue">  &lt;</span>
            <span style="COLOR: #a31515">specVersion</span>
            <span style="COLOR: blue">&gt;</span>
          </p>
          <p style="MARGIN: 0px">
            <span style="COLOR: blue">    &lt;</span>
            <span style="COLOR: #a31515">major</span>
            <span style="COLOR: blue">&gt;</span>1<span style="COLOR: blue">&lt;/</span><span style="COLOR: #a31515">major</span><span style="COLOR: blue">&gt;</span></p>
          <p style="MARGIN: 0px">
            <span style="COLOR: blue">    &lt;</span>
            <span style="COLOR: #a31515">minor</span>
            <span style="COLOR: blue">&gt;</span>0<span style="COLOR: blue">&lt;/</span><span style="COLOR: #a31515">minor</span><span style="COLOR: blue">&gt;</span></p>
          <p style="MARGIN: 0px">
            <span style="COLOR: blue">  &lt;/</span>
            <span style="COLOR: #a31515">specVersion</span>
            <span style="COLOR: blue">&gt;</span>
          </p>
          <p style="MARGIN: 0px">
            <span style="COLOR: blue">  &lt;</span>
            <span style="COLOR: #a31515">device</span>
            <span style="COLOR: blue">&gt;</span>
          </p>
          <p style="MARGIN: 0px">
            <span style="COLOR: blue">    &lt;</span>
            <span style="COLOR: #a31515">deviceType</span>
            <span style="COLOR: blue">&gt;</span>urn:schemas-mycompany-net:device:MyDevice:1<span style="COLOR: blue">&lt;/</span><span style="COLOR: #a31515">deviceType</span><span style="COLOR: blue">&gt;</span></p>
          <p style="MARGIN: 0px">
            <span style="COLOR: blue">    &lt;</span>
            <span style="COLOR: #a31515">presentationURL</span>
            <span style="COLOR: blue">&gt;&lt;/</span>
            <span style="COLOR: #a31515">presentationURL</span>
            <span style="COLOR: blue">&gt;</span>
          </p>
          <p style="MARGIN: 0px">
            <span style="COLOR: blue">    &lt;</span>
            <span style="COLOR: #a31515">friendlyName</span>
            <span style="COLOR: blue">&gt;</span>MyDevice<span style="COLOR: blue">&lt;/</span><span style="COLOR: #a31515">friendlyName</span><span style="COLOR: blue">&gt;</span></p>
          <p style="MARGIN: 0px">
            <span style="COLOR: blue">    &lt;</span>
            <span style="COLOR: #a31515">manufacturer</span>
            <span style="COLOR: blue">&gt;</span>My
Company<span style="COLOR: blue">&lt;/</span><span style="COLOR: #a31515">manufacturer</span><span style="COLOR: blue">&gt;</span></p>
          <p style="MARGIN: 0px">
            <span style="COLOR: blue">    &lt;</span>
            <span style="COLOR: #a31515">manufacturerURL</span>
            <span style="COLOR: blue">&gt;</span>http://www.mycompany.net<span style="COLOR: blue">&lt;/</span><span style="COLOR: #a31515">manufacturerURL</span><span style="COLOR: blue">&gt;</span></p>
          <p style="MARGIN: 0px">
            <span style="COLOR: blue">    &lt;</span>
            <span style="COLOR: #a31515">modelDescription</span>
            <span style="COLOR: blue">&gt;</span>Just
some sample stuff<span style="COLOR: blue">&lt;/</span><span style="COLOR: #a31515">modelDescription</span><span style="COLOR: blue">&gt;</span></p>
          <p style="MARGIN: 0px">
            <span style="COLOR: blue">    &lt;</span>
            <span style="COLOR: #a31515">modelName</span>
            <span style="COLOR: blue">&gt;</span>My
Device X<span style="COLOR: blue">&lt;/</span><span style="COLOR: #a31515">modelName</span><span style="COLOR: blue">&gt;</span></p>
          <p style="MARGIN: 0px">
            <span style="COLOR: blue">    &lt;</span>
            <span style="COLOR: #a31515">modelNumber</span>
            <span style="COLOR: blue">&gt;</span>X<span style="COLOR: blue">&lt;/</span><span style="COLOR: #a31515">modelNumber</span><span style="COLOR: blue">&gt;</span></p>
          <p style="MARGIN: 0px">
            <span style="COLOR: blue">    &lt;</span>
            <span style="COLOR: #a31515">modelURL</span>
            <span style="COLOR: blue">&gt;</span>http://www.mycompany.net<span style="COLOR: blue">&lt;/</span><span style="COLOR: #a31515">modelURL</span><span style="COLOR: blue">&gt;</span></p>
          <p style="MARGIN: 0px">
            <span style="COLOR: blue">    &lt;</span>
            <span style="COLOR: #a31515">serialNumber</span>
            <span style="COLOR: blue">&gt;</span>0000001<span style="COLOR: blue">&lt;/</span><span style="COLOR: #a31515">serialNumber</span><span style="COLOR: blue">&gt;</span></p>
          <p style="MARGIN: 0px">
            <span style="COLOR: blue">    &lt;</span>
            <span style="COLOR: #a31515">UDN</span>
            <span style="COLOR: blue">&gt;</span>uuid:RootDevice<span style="COLOR: blue">&lt;/</span><span style="COLOR: #a31515">UDN</span><span style="COLOR: blue">&gt;</span></p>
          <p style="MARGIN: 0px">
            <span style="COLOR: blue">    &lt;</span>
            <span style="COLOR: #a31515">UPC</span>
            <span style="COLOR: blue">&gt;</span>00000-00001<span style="COLOR: blue">&lt;/</span><span style="COLOR: #a31515">UPC</span><span style="COLOR: blue">&gt;</span></p>
          <p style="MARGIN: 0px">
            <span style="COLOR: blue">    &lt;</span>
            <span style="COLOR: #a31515">serviceList</span>
            <span style="COLOR: blue">&gt;</span>
          </p>
          <p style="MARGIN: 0px">
            <span style="COLOR: blue">      &lt;</span>
            <span style="COLOR: #a31515">service</span>
            <span style="COLOR: blue">&gt;</span>
          </p>
          <p style="MARGIN: 0px">
            <span style="COLOR: blue">        &lt;</span>
            <span style="COLOR: #a31515">serviceType</span>
            <span style="COLOR: blue">&gt;</span>urn:schemas-mycompany-net:service:MyService:1<span style="COLOR: blue">&lt;/</span><span style="COLOR: #a31515">serviceType</span><span style="COLOR: blue">&gt;</span></p>
          <p style="MARGIN: 0px">
            <span style="COLOR: blue">        &lt;</span>
            <span style="COLOR: #a31515">serviceId</span>
            <span style="COLOR: blue">&gt;</span>urn:upnp-mycompany-net:MyService:1<span style="COLOR: blue">&lt;/</span><span style="COLOR: #a31515">serviceId</span><span style="COLOR: blue">&gt;</span></p>
          <p style="MARGIN: 0px">
            <span style="COLOR: blue">        &lt;</span>
            <span style="COLOR: #a31515">controlURL</span>
            <span style="COLOR: blue">&gt;&lt;/</span>
            <span style="COLOR: #a31515">controlURL</span>
            <span style="COLOR: blue">&gt;</span>
          </p>
          <p style="MARGIN: 0px">
            <span style="COLOR: blue">        &lt;</span>
            <span style="COLOR: #a31515">eventSubURL</span>
            <span style="COLOR: blue">&gt;&lt;/</span>
            <span style="COLOR: #a31515">eventSubURL</span>
            <span style="COLOR: blue">&gt;</span>
          </p>
          <p style="MARGIN: 0px">
            <span style="COLOR: blue">        &lt;</span>
            <span style="COLOR: #a31515">SCPDURL</span>
            <span style="COLOR: blue">&gt;</span>MyService.xml<span style="COLOR: blue">&lt;/</span><span style="COLOR: #a31515">SCPDURL</span><span style="COLOR: blue">&gt;</span></p>
          <p style="MARGIN: 0px">
            <span style="COLOR: blue">      &lt;/</span>
            <span style="COLOR: #a31515">service</span>
            <span style="COLOR: blue">&gt;</span>
          </p>
          <p style="MARGIN: 0px">
            <span style="COLOR: blue">    &lt;/</span>
            <span style="COLOR: #a31515">serviceList</span>
            <span style="COLOR: blue">&gt;</span>
          </p>
          <p style="MARGIN: 0px">
            <span style="COLOR: blue">  &lt;/</span>
            <span style="COLOR: #a31515">device</span>
            <span style="COLOR: blue">&gt;</span>
          </p>
          <p style="MARGIN: 0px">
            <span style="COLOR: blue">&lt;/</span>
            <span style="COLOR: #a31515">root</span>
            <span style="COLOR: blue">&gt;</span>
          </p>
        </div>
        <p>
        </p>
        <p>
where MyService.xml is containing the services description.
</p>
        <p>
          <strong>Creating an application to get the device up and running</strong>
        </p>
        <p>
To get the device up and running we need an executable application where we can implement
the service and register the device with the Windows UPnP host. For this purpose I
will use a standard C# Console application.
</p>
        <p>
          <img src="http://www.baekdorf.dk/christian/content/binary/02_VsNewConsoleApp1.PNG" border="0" />
        </p>
        <p>
Add the device description and service description files to the console application,
mark then as “Content” and “Copy if newer”.
</p>
        <p>
It is necessary to disable the use of Visual Studio host process when debugging, otherwise
the application will fail when debugging (some COM related issue).
</p>
        <p>
          <img src="http://www.baekdorf.dk/christian/content/binary/03_VsNoHostProcess1.PNG" border="0" />
        </p>
        <p>
Next we need to add some references to the UPnP COM type libraries ("upnpcont.exe"
and "upnp.dll" typical found in “c:\windows\system32”) for the Windows UPnP framework.
</p>
        <p>
          <img src="http://www.baekdorf.dk/christian/content/binary/04_UPnP_References.PNG" border="0" />
        </p>
        <p>
Now we are ready to implement the service, this is done by adding a plain C# class:
</p>
        <p>
          <!--
{\rtf1\ansi\ansicpg\lang1024\noproof65001\uc1 \deff0{\fonttbl{\f0\fnil\fcharset0\fprq1 Courier New;}}{\colortbl;??\red0\green0\blue0;\red255\green255\blue255;\red43\green145\blue175;\red0\green0\blue255;\red163\green21\blue21;}??\fs24     [\cf3 ComVisible\cf0 (\cf4 true\cf0 )]\par ??    [\cf3 ClassInterface\cf0 (\cf3 ClassInterfaceType\cf0 .AutoDispatch)]\par ??    \cf4 public\cf0  \cf4 class\cf0  \cf3 MyService\par ??\cf0     \{\par ??        \cf4 private\cf0  \cf4 string\cf0  m_Message;\par ??\par ??        \cf4 public\cf0  \cf4 string\cf0  Message\par ??        \{\par ??            \cf4 get\cf0  \{ \cf4 return\cf0  m_Message; \}\par ??            \cf4 set\cf0  \{ m_Message = \cf4 value\cf0 ; \}\par ??        \}\par ??\par ??        \cf4 public\cf0  \cf4 string\cf0  HelloWorld()\par ??        \{\par ??            \cf4 return\cf0  \cf5 "Hello World, time is "\cf0  +\par ??                \cf3 DateTime\cf0 .Now.ToString();\par ??        \}\par ??    \}\par ??}
-->
        </p>
        <div style="FONT-SIZE: 9pt; BACKGROUND: white; COLOR: black; FONT-FAMILY: Courier New">
          <p style="MARGIN: 0px">
    [<span style="COLOR: #2b91af">ComVisible</span>(<span style="COLOR: blue">true</span>)]
</p>
          <p style="MARGIN: 0px">
    [<span style="COLOR: #2b91af">ClassInterface</span>(<span style="COLOR: #2b91af">ClassInterfaceType</span>.AutoDispatch)]
</p>
          <p style="MARGIN: 0px">
    <span style="COLOR: blue">public</span><span style="COLOR: blue">class</span><span style="COLOR: #2b91af">MyService</span></p>
          <p style="MARGIN: 0px">
    {
</p>
          <p style="MARGIN: 0px">
        <span style="COLOR: blue">private</span><span style="COLOR: blue">string</span> m_Message;
</p>
          <p style="MARGIN: 0px">
 
</p>
          <p style="MARGIN: 0px">
        <span style="COLOR: blue">public</span><span style="COLOR: blue">string</span> Message
</p>
          <p style="MARGIN: 0px">
        {
</p>
          <p style="MARGIN: 0px">
            <span style="COLOR: blue">get</span> { <span style="COLOR: blue">return</span> m_Message;
}
</p>
          <p style="MARGIN: 0px">
            <span style="COLOR: blue">set</span> {
m_Message = <span style="COLOR: blue">value</span>; }
</p>
          <p style="MARGIN: 0px">
        }
</p>
          <p style="MARGIN: 0px">
 
</p>
          <p style="MARGIN: 0px">
        <span style="COLOR: blue">public</span><span style="COLOR: blue">string</span> HelloWorld()
</p>
          <p style="MARGIN: 0px">
        {
</p>
          <p style="MARGIN: 0px">
            <span style="COLOR: blue">return</span><span style="COLOR: #a31515">"Hello
World, time is "</span> +
</p>
          <p style="MARGIN: 0px">
                <span style="COLOR: #2b91af">DateTime</span>.Now.ToString();
</p>
          <p style="MARGIN: 0px">
        }
</p>
          <p style="MARGIN: 0px">
    }
</p>
        </div>
        <p>
        </p>
        <p>
The service class should match the service description; have the same methods and
properties. It also needs to be COM visible and implement the COM IDispatch interface.
</p>
        <p>
Next we need a device control class which acts as a factory for instantiating the
service class. This class is also a plain C# deriving from the interface IUPnPDeviceControl.
</p>
        <p>
          <!--
{\rtf1\ansi\ansicpg\lang1024\noproof65001\uc1 \deff0{\fonttbl{\f0\fnil\fcharset0\fprq1 Courier New;}}{\colortbl;??\red0\green0\blue0;\red255\green255\blue255;\red0\green0\blue255;\red43\green145\blue175;}??\fs24     \cf3 public\cf0  \cf3 class\cf0  \cf4 MyDeviceControl\cf0  : \cf4 IUPnPDeviceControl\par ??\cf0     \{\par ??        \cf3 private\cf0  \cf4 MyService\cf0  m_Service;\par ??\par ??        \cf3 public\cf0  \cf3 object\cf0  GetServiceObject(\cf3 string\cf0  bstrUDN, \cf3 string\cf0  bstrServiceId)\par ??        \{\par ??            \cf3 return\cf0  m_Service;\par ??        \}\par ??\par ??        \cf3 public\cf0  \cf3 void\cf0  Initialize(\cf3 string\cf0  bstrXMLDesc, \cf3 string\cf0  bstrDeviceIdentifier, \cf3 string\cf0  bstrInitString)\par ??        \{\par ??            m_Service = \cf3 new\cf0  \cf4 MyService\cf0 ();\par ??        \}\par ??    \}\par ??}
-->
        </p>
        <div style="FONT-SIZE: 9pt; BACKGROUND: white; COLOR: black; FONT-FAMILY: Courier New">
          <p style="MARGIN: 0px">
    <span style="COLOR: blue">public</span><span style="COLOR: blue">class</span><span style="COLOR: #2b91af">MyDeviceControl</span> : <span style="COLOR: #2b91af">IUPnPDeviceControl</span></p>
          <p style="MARGIN: 0px">
    {
</p>
          <p style="MARGIN: 0px">
        <span style="COLOR: blue">private</span><span style="COLOR: #2b91af">MyService</span> m_Service;
</p>
          <p style="MARGIN: 0px">
 
</p>
          <p style="MARGIN: 0px">
        <span style="COLOR: blue">public</span><span style="COLOR: blue">object</span> GetServiceObject(<span style="COLOR: blue">string</span> bstrUDN, <span style="COLOR: blue">string</span> bstrServiceId)
</p>
          <p style="MARGIN: 0px">
        {
</p>
          <p style="MARGIN: 0px">
            <span style="COLOR: blue">return</span> m_Service;
</p>
          <p style="MARGIN: 0px">
        }
</p>
          <p style="MARGIN: 0px">
 
</p>
          <p style="MARGIN: 0px">
        <span style="COLOR: blue">public</span><span style="COLOR: blue">void</span> Initialize(<span style="COLOR: blue">string</span> bstrXMLDesc, <span style="COLOR: blue">string</span> bstrDeviceIdentifier, <span style="COLOR: blue">string</span> bstrInitString)
</p>
          <p style="MARGIN: 0px">
        {
</p>
          <p style="MARGIN: 0px">
            m_Service = <span style="COLOR: blue">new</span><span style="COLOR: #2b91af">MyService</span>();
</p>
          <p style="MARGIN: 0px">
        }
</p>
          <p style="MARGIN: 0px">
    }
</p>
        </div>
        <p>
        </p>
        <p>
Finally we need to fill out the Main method with the code for registering the device
control class with the Windows UPnP framework. See <a href="http://msdn.microsoft.com/en-us/library/aa382282(VS.85).aspx" target="_blank">Registering
a Hosted Device With the Device Host</a> on MSDN for more information for more information.
</p>
        <p>
Note that we need to make a call to <a href="http://msdn.microsoft.com/en-us/library/ms693736(VS.85).aspx" target="_blank">CoInitializeSecurity</a> to
get the COM Interorp to work. For details abort this see the downloadable code.
</p>
        <p>
          <!--
{\rtf1\ansi\ansicpg\lang1024\noproof65001\uc1 \deff0{\fonttbl{\f0\fnil\fcharset0\fprq1 Courier New;}}{\colortbl;??\red0\green0\blue0;\red255\green255\blue255;\red0\green0\blue255;\red43\green145\blue175;\red163\green21\blue21;}??\fs24     \cf3 static\cf0  \cf3 void\cf0  Main(\cf3 string\cf0 [] args)\par ??    \{\par ??        \cf3 try\par ??\cf0         \{\par ??            \cf3 int\cf0  result = \cf4 Win32\cf0 .CoInitializeSecurity(\cf4 IntPtr\cf0 .Zero, -1,\par ??                \cf4 IntPtr\cf0 .Zero, \cf4 IntPtr\cf0 .Zero,\par ??                \cf4 Win32\cf0 .\cf4 RpcAuthnLevel\cf0 .Default, \cf4 Win32\cf0 .\cf4 RpcImpLevel\cf0 .Impersonate,\par ??                \cf4 IntPtr\cf0 .Zero, \cf4 Win32\cf0 .\cf4 EoAuthnCap\cf0 .None, \cf4 IntPtr\cf0 .Zero);\par ??            \cf3 if\cf0  (result != 0)\par ??            \{\par ??                \cf4 Console\cf0 .WriteLine(\cf5 "CoInitializeSecurity failed."\cf0 );\par ??                \cf3 return\cf0 ;\par ??            \}\par ??\par ??            \cf3 string\cf0  descDoc = \cf4 File\cf0 .ReadAllText(\cf5 "DeviceDescription.xml"\cf0 );\par ??            \cf3 object\cf0  myDeviceControl = \cf3 new\cf0  \cf4 MyDeviceControl\cf0 ();\par ??\par ??            \cf4 IUPnPRegistrar\cf0  registrar = (\cf4 IUPnPRegistrar\cf0 )\cf3 new\cf0  \cf4 UPnPRegistrarClass\cf0 ();\par ??\par ??            \cf3 string\cf0  deviceId = registrar.RegisterRunningDevice(\par ??                descDoc, myDeviceControl, \cf5 "Init string..."\cf0 ,\par ??                \cf4 Directory\cf0 .GetCurrentDirectory(), 3200);\par ??\par ??            \cf4 Console\cf0 .WriteLine(\cf5 "Ready, press any key to stop..."\cf0 );\par ??            \cf4 Console\cf0 .ReadLine();\par ??\par ??            registrar.UnregisterDevice(deviceId, 1);\par ??        \}\par ??        \cf3 catch\cf0  (\cf4 Exception\cf0  ex)\par ??        \{\par ??            \cf4 Console\cf0 .WriteLine(ex.ToString());\par ??        \}\par ??    \}\par ??}
-->
        </p>
        <div style="FONT-SIZE: 9pt; BACKGROUND: white; COLOR: black; FONT-FAMILY: Courier New">
          <p style="MARGIN: 0px">
    <span style="COLOR: blue">static</span><span style="COLOR: blue">void</span> Main(<span style="COLOR: blue">string</span>[]
args)
</p>
          <p style="MARGIN: 0px">
    {
</p>
          <p style="MARGIN: 0px">
        <span style="COLOR: blue">try</span></p>
          <p style="MARGIN: 0px">
        {
</p>
          <p style="MARGIN: 0px">
            <span style="COLOR: blue">int</span> result
= <span style="COLOR: #2b91af">Win32</span>.CoInitializeSecurity(<span style="COLOR: #2b91af">IntPtr</span>.Zero,
-1,
</p>
          <p style="MARGIN: 0px">
                <span style="COLOR: #2b91af">IntPtr</span>.Zero, <span style="COLOR: #2b91af">IntPtr</span>.Zero,
</p>
          <p style="MARGIN: 0px">
                <span style="COLOR: #2b91af">Win32</span>.<span style="COLOR: #2b91af">RpcAuthnLevel</span>.Default, <span style="COLOR: #2b91af">Win32</span>.<span style="COLOR: #2b91af">RpcImpLevel</span>.Impersonate,
</p>
          <p style="MARGIN: 0px">
                <span style="COLOR: #2b91af">IntPtr</span>.Zero, <span style="COLOR: #2b91af">Win32</span>.<span style="COLOR: #2b91af">EoAuthnCap</span>.None, <span style="COLOR: #2b91af">IntPtr</span>.Zero);
</p>
          <p style="MARGIN: 0px">
            <span style="COLOR: blue">if</span> (result
!= 0)
</p>
          <p style="MARGIN: 0px">
            {
</p>
          <p style="MARGIN: 0px">
                <span style="COLOR: #2b91af">Console</span>.WriteLine(<span style="COLOR: #a31515">"CoInitializeSecurity
failed."</span>);
</p>
          <p style="MARGIN: 0px">
                <span style="COLOR: blue">return</span>;
</p>
          <p style="MARGIN: 0px">
            }
</p>
          <p style="MARGIN: 0px">
 
</p>
          <p style="MARGIN: 0px">
            <span style="COLOR: blue">string</span> descDoc
= <span style="COLOR: #2b91af">File</span>.ReadAllText(<span style="COLOR: #a31515">"DeviceDescription.xml"</span>);
</p>
          <p style="MARGIN: 0px">
            <span style="COLOR: blue">object</span> myDeviceControl
= <span style="COLOR: blue">new</span><span style="COLOR: #2b91af">MyDeviceControl</span>();
</p>
          <p style="MARGIN: 0px">
 
</p>
          <p style="MARGIN: 0px">
            <span style="COLOR: #2b91af">IUPnPRegistrar</span> registrar
= (<span style="COLOR: #2b91af">IUPnPRegistrar</span>)<span style="COLOR: blue">new</span><span style="COLOR: #2b91af">UPnPRegistrarClass</span>();
</p>
          <p style="MARGIN: 0px">
 
</p>
          <p style="MARGIN: 0px">
            <span style="COLOR: blue">string</span> deviceId
= registrar.RegisterRunningDevice(
</p>
          <p style="MARGIN: 0px">
                descDoc,
myDeviceControl, <span style="COLOR: #a31515">"Init string..."</span>,
</p>
          <p style="MARGIN: 0px">
                <span style="COLOR: #2b91af">Directory</span>.GetCurrentDirectory(),
3200);
</p>
          <p style="MARGIN: 0px">
 
</p>
          <p style="MARGIN: 0px">
            <span style="COLOR: #2b91af">Console</span>.WriteLine(<span style="COLOR: #a31515">"Ready,
press any key to stop..."</span>);
</p>
          <p style="MARGIN: 0px">
            <span style="COLOR: #2b91af">Console</span>.ReadLine();
</p>
          <p style="MARGIN: 0px">
 
</p>
          <p style="MARGIN: 0px">
            registrar.UnregisterDevice(deviceId,
1);
</p>
          <p style="MARGIN: 0px">
        }
</p>
          <p style="MARGIN: 0px">
        <span style="COLOR: blue">catch</span> (<span style="COLOR: #2b91af">Exception</span> ex)
</p>
          <p style="MARGIN: 0px">
        {
</p>
          <p style="MARGIN: 0px">
            <span style="COLOR: #2b91af">Console</span>.WriteLine(ex.ToString());
</p>
          <p style="MARGIN: 0px">
        }
</p>
          <p style="MARGIN: 0px">
    }
</p>
        </div>
        <p>
        </p>
        <p>
          <strong>Testing the UPnP device and service</strong>
        </p>
        <p>
Now we can build and start the program
</p>
        <p>
          <img src="http://www.baekdorf.dk/christian/content/binary/05_RunningApp.png" border="0" />
        </p>
        <p>
To test the UPnP device and service we will use Intel Device Spy for UPnP, this way
we can test the HelloWorld method without having to implement a UPnP client.
</p>
        <p>
          <img src="http://www.baekdorf.dk/christian/content/binary/06_DeviceSpy.png" border="0" />
        </p>
        <p>
If our new UPnP device is running, we should see it in the UPnP Device Spy with the
name MyDevice and should be able to find the service and HelloWorld method. Try invoking
the HelloWorld method by right-clicking it.
</p>
        <p>
          <strong>Downloadable code</strong>
        </p>
        <p>
You can download the sample code here: <a href="http://www.baekdorf.dk/christian/content/binary/MyUPnP-Tutorial-01.zip">MyUPnP-Tutorial-01.zip
(33,37 KB)</a></p>
        <img width="0" height="0" src="http://www.baekdorf.dk/christian/aggbug.ashx?id=f82d01d7-2ff5-4bde-914a-be2cabef315c" />
      </body>
      <title>UPnP hosted device using C# / .NET and Windows UPnP</title>
      <guid isPermaLink="false">http://www.baekdorf.dk/christian/PermaLink,guid,f82d01d7-2ff5-4bde-914a-be2cabef315c.aspx</guid>
      <link>http://www.baekdorf.dk/christian/2008/09/21/UPnPHostedDeviceUsingCNETAndWindowsUPnP.aspx</link>
      <pubDate>Sun, 21 Sep 2008 10:53:09 GMT</pubDate>
      <description>&lt;p&gt;
In this small tutorial I will show how to create a simple &lt;a href="http://msdn.microsoft.com/en-us/library/aa381223(VS.85).aspx" target=_blank&gt;UPnP
hosted device&lt;/a&gt; containing a simple HelloWorld service using C# and the Windows
UPnP framework.
&lt;/p&gt;
&lt;p&gt;
Windows UPnP is available in Windows XP, Vista and 2008 Server, but not in Windows
2003 Server. If you want UPnP on Windows 2003, have a look at the &lt;a href="http://www.intel.com/cd/ids/developer/asmo-na/eng/downloads/upnp/tools/index.htm" target=_blank&gt;Intel
UPnP stack&lt;/a&gt;.
&lt;/p&gt;
&lt;p&gt;
I will not explain the basic concepts of UPnP, so if you don’t feel familiar with
basic UPnP concepts it might be at good idea to look at some of the documentation
at &lt;a href="http://upnp.org" target=_blank&gt;UPNP.ORG&lt;/a&gt; or &lt;a href="http://msdn.microsoft.com/en-us/library/aa382303%28VS.85%29.aspx" target=_blank&gt;MSDN&lt;/a&gt;.
&lt;/p&gt;
&lt;p&gt;
Intel has some great tools for working with UPnP and I will be using these during
the tutorial, so it would a good idea to install then if you want to go through the
steps. They can be downloaded from &lt;a href="http://www.intel.com/cd/ids/developer/asmo-na/eng/downloads/upnp/tools/index.htm" target=_blank&gt;Intel’s
website&lt;/a&gt;, pick &lt;a href="http://softwarecommunity.intel.com/isn/downloads/zips/IntelToolsForUPnPTechnology_v2.zip" target=_blank&gt;Intel®
Tools for UPnP Technologies (Build 2777) and the .NET 2.0 CLR edition&lt;/a&gt;.
&lt;/p&gt;
&lt;p&gt;
&lt;strong&gt;Designing/specifying the service&lt;/strong&gt;
&lt;/p&gt;
&lt;p&gt;
First steps is to create a services description, this is just like an interface for
the service – specifying methods, properties and events. This is done in an XML file,
see paragraph 2.3 of &lt;a href="http://upnp.org/specs/arch/UPnP-arch-DeviceArchitecture-v1.0-20080424.pdf" target=_blank&gt;UPnP
Device Architecture 1.0&lt;/a&gt; for a detailed description of the XML format.
&lt;/p&gt;
&lt;p&gt;
For this example we will just create a simple “HelloWorld” service that can return
a simple text message, so we will have a services description as shown below:
&lt;/p&gt;
&lt;p&gt;
&lt;!--
{\rtf1\ansi\ansicpg\lang1024\noproof65001\uc1 \deff0{\fonttbl{\f0\fnil\fcharset0\fprq1 Courier New;}}{\colortbl;??\red0\green0\blue255;\red255\green255\blue255;\red163\green21\blue21;\red255\green0\blue0;\red0\green0\blue0;}??\fs24 \cf1 &amp;lt;?\cf3 xml\cf1  \cf4 version\cf1 =\cf0 "\cf1 1.0\cf0 "\cf1  \cf4 encoding\cf1 =\cf0 "\cf1 utf-8\cf0 "\cf1 ?&amp;gt;\par ??&amp;lt;\cf3 scpd\cf1  \cf4 xmlns\cf1 =\cf0 "\cf1 urn:schemas-upnp-org:service-1-0\cf0 "\cf1 &amp;gt;\par ??   &amp;lt;\cf3 specVersion\cf1 &amp;gt;\par ??      &amp;lt;\cf3 major\cf1 &amp;gt;\cf0 1\cf1 &amp;lt;/\cf3 major\cf1 &amp;gt;\par ??      &amp;lt;\cf3 minor\cf1 &amp;gt;\cf0 0\cf1 &amp;lt;/\cf3 minor\cf1 &amp;gt;\par ??   &amp;lt;/\cf3 specVersion\cf1 &amp;gt;\par ??   &amp;lt;\cf3 actionList\cf1 &amp;gt;\par ??      &amp;lt;\cf3 action\cf1 &amp;gt;\par ??         &amp;lt;\cf3 name\cf1 &amp;gt;\cf0 HelloWorld\cf1 &amp;lt;/\cf3 name\cf1 &amp;gt;\par ??         &amp;lt;\cf3 argumentList\cf1 &amp;gt;\par ??            &amp;lt;\cf3 argument\cf1 &amp;gt;\par ??               &amp;lt;\cf3 name\cf1 &amp;gt;\cf0 message\cf1 &amp;lt;/\cf3 name\cf1 &amp;gt;\par ??               &amp;lt;\cf3 direction\cf1 &amp;gt;\cf0 out\cf1 &amp;lt;/\cf3 direction\cf1 &amp;gt;\par ??               &amp;lt;\cf3 retval\cf1  /&amp;gt;\par ??               &amp;lt;\cf3 relatedStateVariable\cf1 &amp;gt;\cf0 Message\cf1 &amp;lt;/\cf3 relatedStateVariable\cf1 &amp;gt;\par ??            &amp;lt;/\cf3 argument\cf1 &amp;gt;\par ??         &amp;lt;/\cf3 argumentList\cf1 &amp;gt;\par ??      &amp;lt;/\cf3 action\cf1 &amp;gt;\par ??   &amp;lt;/\cf3 actionList\cf1 &amp;gt;\par ??   &amp;lt;\cf3 serviceStateTable\cf1 &amp;gt;\par ??      &amp;lt;\cf3 stateVariable\cf1  \cf4 sendEvents\cf1 =\cf0 "\cf1 no\cf0 "\cf1 &amp;gt;\par ??         &amp;lt;\cf3 name\cf1 &amp;gt;\cf0 Message\cf1 &amp;lt;/\cf3 name\cf1 &amp;gt;\par ??         &amp;lt;\cf3 dataType\cf1 &amp;gt;\cf0 string\cf1 &amp;lt;/\cf3 dataType\cf1 &amp;gt;\par ??      &amp;lt;/\cf3 stateVariable\cf1 &amp;gt;\par ??   &amp;lt;/\cf3 serviceStateTable\cf1 &amp;gt;\par ??&amp;lt;/\cf3 scpd\cf1 &amp;gt;}
--&gt;
&lt;div style="FONT-SIZE: 9pt; BACKGROUND: white; COLOR: black; FONT-FAMILY: Courier New"&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: blue"&gt;&amp;lt;?&lt;/span&gt;&lt;span style="COLOR: #a31515"&gt;xml&lt;/span&gt;&lt;span style="COLOR: blue"&gt; &lt;/span&gt;&lt;span style="COLOR: red"&gt;version&lt;/span&gt;&lt;span style="COLOR: blue"&gt;=&lt;/span&gt;"&lt;span style="COLOR: blue"&gt;1.0&lt;/span&gt;"&lt;span style="COLOR: blue"&gt; &lt;/span&gt;&lt;span style="COLOR: red"&gt;encoding&lt;/span&gt;&lt;span style="COLOR: blue"&gt;=&lt;/span&gt;"&lt;span style="COLOR: blue"&gt;utf-8&lt;/span&gt;"&lt;span style="COLOR: blue"&gt;?&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: blue"&gt;&amp;lt;&lt;/span&gt;&lt;span style="COLOR: #a31515"&gt;scpd&lt;/span&gt;&lt;span style="COLOR: blue"&gt; &lt;/span&gt;&lt;span style="COLOR: red"&gt;xmlns&lt;/span&gt;&lt;span style="COLOR: blue"&gt;=&lt;/span&gt;"&lt;span style="COLOR: blue"&gt;urn:schemas-upnp-org:service-1-0&lt;/span&gt;"&lt;span style="COLOR: blue"&gt;&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: blue"&gt;&amp;nbsp; &amp;lt;&lt;/span&gt;&lt;span style="COLOR: #a31515"&gt;specVersion&lt;/span&gt;&lt;span style="COLOR: blue"&gt;&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: blue"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;&lt;/span&gt;&lt;span style="COLOR: #a31515"&gt;major&lt;/span&gt;&lt;span style="COLOR: blue"&gt;&amp;gt;&lt;/span&gt;1&lt;span style="COLOR: blue"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="COLOR: #a31515"&gt;major&lt;/span&gt;&lt;span style="COLOR: blue"&gt;&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: blue"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;&lt;/span&gt;&lt;span style="COLOR: #a31515"&gt;minor&lt;/span&gt;&lt;span style="COLOR: blue"&gt;&amp;gt;&lt;/span&gt;0&lt;span style="COLOR: blue"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="COLOR: #a31515"&gt;minor&lt;/span&gt;&lt;span style="COLOR: blue"&gt;&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: blue"&gt;&amp;nbsp; &amp;lt;/&lt;/span&gt;&lt;span style="COLOR: #a31515"&gt;specVersion&lt;/span&gt;&lt;span style="COLOR: blue"&gt;&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: blue"&gt;&amp;nbsp; &amp;lt;&lt;/span&gt;&lt;span style="COLOR: #a31515"&gt;actionList&lt;/span&gt;&lt;span style="COLOR: blue"&gt;&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: blue"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;&lt;/span&gt;&lt;span style="COLOR: #a31515"&gt;action&lt;/span&gt;&lt;span style="COLOR: blue"&gt;&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: blue"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;&lt;/span&gt;&lt;span style="COLOR: #a31515"&gt;name&lt;/span&gt;&lt;span style="COLOR: blue"&gt;&amp;gt;&lt;/span&gt;HelloWorld&lt;span style="COLOR: blue"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="COLOR: #a31515"&gt;name&lt;/span&gt;&lt;span style="COLOR: blue"&gt;&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: blue"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;&lt;/span&gt;&lt;span style="COLOR: #a31515"&gt;argumentList&lt;/span&gt;&lt;span style="COLOR: blue"&gt;&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: blue"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;&lt;/span&gt;&lt;span style="COLOR: #a31515"&gt;argument&lt;/span&gt;&lt;span style="COLOR: blue"&gt;&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: blue"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;&lt;/span&gt;&lt;span style="COLOR: #a31515"&gt;name&lt;/span&gt;&lt;span style="COLOR: blue"&gt;&amp;gt;&lt;/span&gt;message&lt;span style="COLOR: blue"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="COLOR: #a31515"&gt;name&lt;/span&gt;&lt;span style="COLOR: blue"&gt;&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: blue"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;&lt;/span&gt;&lt;span style="COLOR: #a31515"&gt;direction&lt;/span&gt;&lt;span style="COLOR: blue"&gt;&amp;gt;&lt;/span&gt;out&lt;span style="COLOR: blue"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="COLOR: #a31515"&gt;direction&lt;/span&gt;&lt;span style="COLOR: blue"&gt;&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: blue"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;&lt;/span&gt;&lt;span style="COLOR: #a31515"&gt;retval&lt;/span&gt;&lt;span style="COLOR: blue"&gt; /&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: blue"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;&lt;/span&gt;&lt;span style="COLOR: #a31515"&gt;relatedStateVariable&lt;/span&gt;&lt;span style="COLOR: blue"&gt;&amp;gt;&lt;/span&gt;Message&lt;span style="COLOR: blue"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="COLOR: #a31515"&gt;relatedStateVariable&lt;/span&gt;&lt;span style="COLOR: blue"&gt;&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: blue"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;/&lt;/span&gt;&lt;span style="COLOR: #a31515"&gt;argument&lt;/span&gt;&lt;span style="COLOR: blue"&gt;&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: blue"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;/&lt;/span&gt;&lt;span style="COLOR: #a31515"&gt;argumentList&lt;/span&gt;&lt;span style="COLOR: blue"&gt;&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: blue"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;/&lt;/span&gt;&lt;span style="COLOR: #a31515"&gt;action&lt;/span&gt;&lt;span style="COLOR: blue"&gt;&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: blue"&gt;&amp;nbsp; &amp;lt;/&lt;/span&gt;&lt;span style="COLOR: #a31515"&gt;actionList&lt;/span&gt;&lt;span style="COLOR: blue"&gt;&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: blue"&gt;&amp;nbsp; &amp;lt;&lt;/span&gt;&lt;span style="COLOR: #a31515"&gt;serviceStateTable&lt;/span&gt;&lt;span style="COLOR: blue"&gt;&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: blue"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;&lt;/span&gt;&lt;span style="COLOR: #a31515"&gt;stateVariable&lt;/span&gt;&lt;span style="COLOR: blue"&gt; &lt;/span&gt;&lt;span style="COLOR: red"&gt;sendEvents&lt;/span&gt;&lt;span style="COLOR: blue"&gt;=&lt;/span&gt;"&lt;span style="COLOR: blue"&gt;no&lt;/span&gt;"&lt;span style="COLOR: blue"&gt;&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: blue"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;&lt;/span&gt;&lt;span style="COLOR: #a31515"&gt;name&lt;/span&gt;&lt;span style="COLOR: blue"&gt;&amp;gt;&lt;/span&gt;Message&lt;span style="COLOR: blue"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="COLOR: #a31515"&gt;name&lt;/span&gt;&lt;span style="COLOR: blue"&gt;&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: blue"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;&lt;/span&gt;&lt;span style="COLOR: #a31515"&gt;dataType&lt;/span&gt;&lt;span style="COLOR: blue"&gt;&amp;gt;&lt;/span&gt;string&lt;span style="COLOR: blue"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="COLOR: #a31515"&gt;dataType&lt;/span&gt;&lt;span style="COLOR: blue"&gt;&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: blue"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;/&lt;/span&gt;&lt;span style="COLOR: #a31515"&gt;stateVariable&lt;/span&gt;&lt;span style="COLOR: blue"&gt;&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: blue"&gt;&amp;nbsp; &amp;lt;/&lt;/span&gt;&lt;span style="COLOR: #a31515"&gt;serviceStateTable&lt;/span&gt;&lt;span style="COLOR: blue"&gt;&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: blue"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="COLOR: #a31515"&gt;scpd&lt;/span&gt;&lt;span style="COLOR: blue"&gt;&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;/div&gt;
&lt;p&gt;
&lt;/p&gt;
&lt;p&gt;
Specifying this service could be done using any text editor or by using the Intel
Service Author application which comes a part of the Intel tools for UPnP.
&lt;/p&gt;
&lt;p&gt;
&lt;img src="http://www.baekdorf.dk/christian/content/binary/01_IntelServiceAuthor.PNG" border=0&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;strong&gt;Designing/specifying the device&lt;/strong&gt;
&lt;/p&gt;
&lt;p&gt;
Next we need to create a device specification; this is a specification of the services
that should be published and other meta-information related to the devices and services.
This will also be represented by an XML file, see paragraph 2.1 of &lt;a href="http://upnp.org/specs/arch/UPnP-arch-DeviceArchitecture-v1.0-20080424.pdf" target=_blank&gt;UPnP
Device Architecture 1.0&lt;/a&gt; and &lt;a href="http://msdn.microsoft.com/en-us/library/aa381130(VS.85).aspx" target=_blank&gt;Creating
a Device Description on MSDN&lt;/a&gt; for a detailed description of the XML format.
&lt;/p&gt;
&lt;p&gt;
Sample device description:
&lt;/p&gt;
&lt;p&gt;
&lt;!--
{\rtf1\ansi\ansicpg\lang1024\noproof65001\uc1 \deff0{\fonttbl{\f0\fnil\fcharset0\fprq1 Courier New;}}{\colortbl;??\red0\green0\blue255;\red255\green255\blue255;\red163\green21\blue21;\red255\green0\blue0;\red0\green0\blue0;}??\fs24 \cf1 &amp;lt;?\cf3 xml\cf1  \cf4 version\cf1 =\cf0 "\cf1 1.0\cf0 "\cf1 ?&amp;gt;\par ??&amp;lt;\cf3 root\cf1  \cf4 xmlns\cf1 =\cf0 "\cf1 urn:schemas-upnp-org:device-1-0\cf0 "\cf1 &amp;gt;\par ??  &amp;lt;\cf3 specVersion\cf1 &amp;gt;\par ??    &amp;lt;\cf3 major\cf1 &amp;gt;\cf0 1\cf1 &amp;lt;/\cf3 major\cf1 &amp;gt;\par ??    &amp;lt;\cf3 minor\cf1 &amp;gt;\cf0 0\cf1 &amp;lt;/\cf3 minor\cf1 &amp;gt;\par ??  &amp;lt;/\cf3 specVersion\cf1 &amp;gt;\par ??  &amp;lt;\cf3 device\cf1 &amp;gt;\par ??    &amp;lt;\cf3 deviceType\cf1 &amp;gt;\cf0 urn:schemas-mycompany-net:device:MyDevice:1\cf1 &amp;lt;/\cf3 deviceType\cf1 &amp;gt;\par ??    &amp;lt;\cf3 presentationURL\cf1 &amp;gt;&amp;lt;/\cf3 presentationURL\cf1 &amp;gt;\par ??    &amp;lt;\cf3 friendlyName\cf1 &amp;gt;\cf0 MyDevice\cf1 &amp;lt;/\cf3 friendlyName\cf1 &amp;gt;\par ??    &amp;lt;\cf3 manufacturer\cf1 &amp;gt;\cf0 My Company\cf1 &amp;lt;/\cf3 manufacturer\cf1 &amp;gt;\par ??    &amp;lt;\cf3 manufacturerURL\cf1 &amp;gt;\cf0 http://www.mycompany.net\cf1 &amp;lt;/\cf3 manufacturerURL\cf1 &amp;gt;\par ??    &amp;lt;\cf3 modelDescription\cf1 &amp;gt;\cf0 Just some sample stuff\cf1 &amp;lt;/\cf3 modelDescription\cf1 &amp;gt;\par ??    &amp;lt;\cf3 modelName\cf1 &amp;gt;\cf0 My Device X\cf1 &amp;lt;/\cf3 modelName\cf1 &amp;gt;\par ??    &amp;lt;\cf3 modelNumber\cf1 &amp;gt;\cf0 X\cf1 &amp;lt;/\cf3 modelNumber\cf1 &amp;gt;\par ??    &amp;lt;\cf3 modelURL\cf1 &amp;gt;\cf0 http://www.mycompany.net\cf1 &amp;lt;/\cf3 modelURL\cf1 &amp;gt;\par ??    &amp;lt;\cf3 serialNumber\cf1 &amp;gt;\cf0 0000001\cf1 &amp;lt;/\cf3 serialNumber\cf1 &amp;gt;\par ??    &amp;lt;\cf3 UDN\cf1 &amp;gt;\cf0 uuid:RootDevice\cf1 &amp;lt;/\cf3 UDN\cf1 &amp;gt;\par ??    &amp;lt;\cf3 UPC\cf1 &amp;gt;\cf0 00000-00001\cf1 &amp;lt;/\cf3 UPC\cf1 &amp;gt;\par ??    &amp;lt;\cf3 serviceList\cf1 &amp;gt;\par ??      &amp;lt;\cf3 service\cf1 &amp;gt;\par ??        &amp;lt;\cf3 serviceType\cf1 &amp;gt;\cf0 urn:schemas-mycompany-net:service:MyService:1\cf1 &amp;lt;/\cf3 serviceType\cf1 &amp;gt;\par ??        &amp;lt;\cf3 serviceId\cf1 &amp;gt;\cf0 urn:upnp-mycompany-net:MyService:1\cf1 &amp;lt;/\cf3 serviceId\cf1 &amp;gt;\par ??        &amp;lt;\cf3 controlURL\cf1 &amp;gt;&amp;lt;/\cf3 controlURL\cf1 &amp;gt;\par ??        &amp;lt;\cf3 eventSubURL\cf1 &amp;gt;&amp;lt;/\cf3 eventSubURL\cf1 &amp;gt;\par ??        &amp;lt;\cf3 SCPDURL\cf1 &amp;gt;\cf0 MyService.xml\cf1 &amp;lt;/\cf3 SCPDURL\cf1 &amp;gt;\par ??      &amp;lt;/\cf3 service\cf1 &amp;gt;\par ??    &amp;lt;/\cf3 serviceList\cf1 &amp;gt;\par ??  &amp;lt;/\cf3 device\cf1 &amp;gt;\par ??&amp;lt;/\cf3 root\cf1 &amp;gt;\par ??}
--&gt;
&lt;div style="FONT-SIZE: 9pt; BACKGROUND: white; COLOR: black; FONT-FAMILY: Courier New"&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: blue"&gt;&amp;lt;?&lt;/span&gt;&lt;span style="COLOR: #a31515"&gt;xml&lt;/span&gt;&lt;span style="COLOR: blue"&gt; &lt;/span&gt;&lt;span style="COLOR: red"&gt;version&lt;/span&gt;&lt;span style="COLOR: blue"&gt;=&lt;/span&gt;"&lt;span style="COLOR: blue"&gt;1.0&lt;/span&gt;"&lt;span style="COLOR: blue"&gt;?&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: blue"&gt;&amp;lt;&lt;/span&gt;&lt;span style="COLOR: #a31515"&gt;root&lt;/span&gt;&lt;span style="COLOR: blue"&gt; &lt;/span&gt;&lt;span style="COLOR: red"&gt;xmlns&lt;/span&gt;&lt;span style="COLOR: blue"&gt;=&lt;/span&gt;"&lt;span style="COLOR: blue"&gt;urn:schemas-upnp-org:device-1-0&lt;/span&gt;"&lt;span style="COLOR: blue"&gt;&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: blue"&gt;&amp;nbsp; &amp;lt;&lt;/span&gt;&lt;span style="COLOR: #a31515"&gt;specVersion&lt;/span&gt;&lt;span style="COLOR: blue"&gt;&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: blue"&gt;&amp;nbsp; &amp;nbsp; &amp;lt;&lt;/span&gt;&lt;span style="COLOR: #a31515"&gt;major&lt;/span&gt;&lt;span style="COLOR: blue"&gt;&amp;gt;&lt;/span&gt;1&lt;span style="COLOR: blue"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="COLOR: #a31515"&gt;major&lt;/span&gt;&lt;span style="COLOR: blue"&gt;&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: blue"&gt;&amp;nbsp; &amp;nbsp; &amp;lt;&lt;/span&gt;&lt;span style="COLOR: #a31515"&gt;minor&lt;/span&gt;&lt;span style="COLOR: blue"&gt;&amp;gt;&lt;/span&gt;0&lt;span style="COLOR: blue"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="COLOR: #a31515"&gt;minor&lt;/span&gt;&lt;span style="COLOR: blue"&gt;&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: blue"&gt;&amp;nbsp; &amp;lt;/&lt;/span&gt;&lt;span style="COLOR: #a31515"&gt;specVersion&lt;/span&gt;&lt;span style="COLOR: blue"&gt;&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: blue"&gt;&amp;nbsp; &amp;lt;&lt;/span&gt;&lt;span style="COLOR: #a31515"&gt;device&lt;/span&gt;&lt;span style="COLOR: blue"&gt;&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: blue"&gt;&amp;nbsp; &amp;nbsp; &amp;lt;&lt;/span&gt;&lt;span style="COLOR: #a31515"&gt;deviceType&lt;/span&gt;&lt;span style="COLOR: blue"&gt;&amp;gt;&lt;/span&gt;urn:schemas-mycompany-net:device:MyDevice:1&lt;span style="COLOR: blue"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="COLOR: #a31515"&gt;deviceType&lt;/span&gt;&lt;span style="COLOR: blue"&gt;&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: blue"&gt;&amp;nbsp; &amp;nbsp; &amp;lt;&lt;/span&gt;&lt;span style="COLOR: #a31515"&gt;presentationURL&lt;/span&gt;&lt;span style="COLOR: blue"&gt;&amp;gt;&amp;lt;/&lt;/span&gt;&lt;span style="COLOR: #a31515"&gt;presentationURL&lt;/span&gt;&lt;span style="COLOR: blue"&gt;&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: blue"&gt;&amp;nbsp; &amp;nbsp; &amp;lt;&lt;/span&gt;&lt;span style="COLOR: #a31515"&gt;friendlyName&lt;/span&gt;&lt;span style="COLOR: blue"&gt;&amp;gt;&lt;/span&gt;MyDevice&lt;span style="COLOR: blue"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="COLOR: #a31515"&gt;friendlyName&lt;/span&gt;&lt;span style="COLOR: blue"&gt;&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: blue"&gt;&amp;nbsp; &amp;nbsp; &amp;lt;&lt;/span&gt;&lt;span style="COLOR: #a31515"&gt;manufacturer&lt;/span&gt;&lt;span style="COLOR: blue"&gt;&amp;gt;&lt;/span&gt;My
Company&lt;span style="COLOR: blue"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="COLOR: #a31515"&gt;manufacturer&lt;/span&gt;&lt;span style="COLOR: blue"&gt;&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: blue"&gt;&amp;nbsp; &amp;nbsp; &amp;lt;&lt;/span&gt;&lt;span style="COLOR: #a31515"&gt;manufacturerURL&lt;/span&gt;&lt;span style="COLOR: blue"&gt;&amp;gt;&lt;/span&gt;http://www.mycompany.net&lt;span style="COLOR: blue"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="COLOR: #a31515"&gt;manufacturerURL&lt;/span&gt;&lt;span style="COLOR: blue"&gt;&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: blue"&gt;&amp;nbsp; &amp;nbsp; &amp;lt;&lt;/span&gt;&lt;span style="COLOR: #a31515"&gt;modelDescription&lt;/span&gt;&lt;span style="COLOR: blue"&gt;&amp;gt;&lt;/span&gt;Just
some sample stuff&lt;span style="COLOR: blue"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="COLOR: #a31515"&gt;modelDescription&lt;/span&gt;&lt;span style="COLOR: blue"&gt;&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: blue"&gt;&amp;nbsp; &amp;nbsp; &amp;lt;&lt;/span&gt;&lt;span style="COLOR: #a31515"&gt;modelName&lt;/span&gt;&lt;span style="COLOR: blue"&gt;&amp;gt;&lt;/span&gt;My
Device X&lt;span style="COLOR: blue"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="COLOR: #a31515"&gt;modelName&lt;/span&gt;&lt;span style="COLOR: blue"&gt;&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: blue"&gt;&amp;nbsp; &amp;nbsp; &amp;lt;&lt;/span&gt;&lt;span style="COLOR: #a31515"&gt;modelNumber&lt;/span&gt;&lt;span style="COLOR: blue"&gt;&amp;gt;&lt;/span&gt;X&lt;span style="COLOR: blue"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="COLOR: #a31515"&gt;modelNumber&lt;/span&gt;&lt;span style="COLOR: blue"&gt;&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: blue"&gt;&amp;nbsp; &amp;nbsp; &amp;lt;&lt;/span&gt;&lt;span style="COLOR: #a31515"&gt;modelURL&lt;/span&gt;&lt;span style="COLOR: blue"&gt;&amp;gt;&lt;/span&gt;http://www.mycompany.net&lt;span style="COLOR: blue"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="COLOR: #a31515"&gt;modelURL&lt;/span&gt;&lt;span style="COLOR: blue"&gt;&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: blue"&gt;&amp;nbsp; &amp;nbsp; &amp;lt;&lt;/span&gt;&lt;span style="COLOR: #a31515"&gt;serialNumber&lt;/span&gt;&lt;span style="COLOR: blue"&gt;&amp;gt;&lt;/span&gt;0000001&lt;span style="COLOR: blue"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="COLOR: #a31515"&gt;serialNumber&lt;/span&gt;&lt;span style="COLOR: blue"&gt;&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: blue"&gt;&amp;nbsp; &amp;nbsp; &amp;lt;&lt;/span&gt;&lt;span style="COLOR: #a31515"&gt;UDN&lt;/span&gt;&lt;span style="COLOR: blue"&gt;&amp;gt;&lt;/span&gt;uuid:RootDevice&lt;span style="COLOR: blue"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="COLOR: #a31515"&gt;UDN&lt;/span&gt;&lt;span style="COLOR: blue"&gt;&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: blue"&gt;&amp;nbsp; &amp;nbsp; &amp;lt;&lt;/span&gt;&lt;span style="COLOR: #a31515"&gt;UPC&lt;/span&gt;&lt;span style="COLOR: blue"&gt;&amp;gt;&lt;/span&gt;00000-00001&lt;span style="COLOR: blue"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="COLOR: #a31515"&gt;UPC&lt;/span&gt;&lt;span style="COLOR: blue"&gt;&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: blue"&gt;&amp;nbsp; &amp;nbsp; &amp;lt;&lt;/span&gt;&lt;span style="COLOR: #a31515"&gt;serviceList&lt;/span&gt;&lt;span style="COLOR: blue"&gt;&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: blue"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;&lt;/span&gt;&lt;span style="COLOR: #a31515"&gt;service&lt;/span&gt;&lt;span style="COLOR: blue"&gt;&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: blue"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;&lt;/span&gt;&lt;span style="COLOR: #a31515"&gt;serviceType&lt;/span&gt;&lt;span style="COLOR: blue"&gt;&amp;gt;&lt;/span&gt;urn:schemas-mycompany-net:service:MyService:1&lt;span style="COLOR: blue"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="COLOR: #a31515"&gt;serviceType&lt;/span&gt;&lt;span style="COLOR: blue"&gt;&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: blue"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;&lt;/span&gt;&lt;span style="COLOR: #a31515"&gt;serviceId&lt;/span&gt;&lt;span style="COLOR: blue"&gt;&amp;gt;&lt;/span&gt;urn:upnp-mycompany-net:MyService:1&lt;span style="COLOR: blue"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="COLOR: #a31515"&gt;serviceId&lt;/span&gt;&lt;span style="COLOR: blue"&gt;&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: blue"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;&lt;/span&gt;&lt;span style="COLOR: #a31515"&gt;controlURL&lt;/span&gt;&lt;span style="COLOR: blue"&gt;&amp;gt;&amp;lt;/&lt;/span&gt;&lt;span style="COLOR: #a31515"&gt;controlURL&lt;/span&gt;&lt;span style="COLOR: blue"&gt;&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: blue"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;&lt;/span&gt;&lt;span style="COLOR: #a31515"&gt;eventSubURL&lt;/span&gt;&lt;span style="COLOR: blue"&gt;&amp;gt;&amp;lt;/&lt;/span&gt;&lt;span style="COLOR: #a31515"&gt;eventSubURL&lt;/span&gt;&lt;span style="COLOR: blue"&gt;&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: blue"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;&lt;/span&gt;&lt;span style="COLOR: #a31515"&gt;SCPDURL&lt;/span&gt;&lt;span style="COLOR: blue"&gt;&amp;gt;&lt;/span&gt;MyService.xml&lt;span style="COLOR: blue"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="COLOR: #a31515"&gt;SCPDURL&lt;/span&gt;&lt;span style="COLOR: blue"&gt;&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: blue"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;/&lt;/span&gt;&lt;span style="COLOR: #a31515"&gt;service&lt;/span&gt;&lt;span style="COLOR: blue"&gt;&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: blue"&gt;&amp;nbsp; &amp;nbsp; &amp;lt;/&lt;/span&gt;&lt;span style="COLOR: #a31515"&gt;serviceList&lt;/span&gt;&lt;span style="COLOR: blue"&gt;&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: blue"&gt;&amp;nbsp; &amp;lt;/&lt;/span&gt;&lt;span style="COLOR: #a31515"&gt;device&lt;/span&gt;&lt;span style="COLOR: blue"&gt;&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: blue"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="COLOR: #a31515"&gt;root&lt;/span&gt;&lt;span style="COLOR: blue"&gt;&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;/div&gt;
&lt;p&gt;
&lt;/p&gt;
&lt;p&gt;
where MyService.xml is containing the services description.
&lt;/p&gt;
&lt;p&gt;
&lt;strong&gt;Creating an application to get the device up and running&lt;/strong&gt;
&lt;/p&gt;
&lt;p&gt;
To get the device up and running we need an executable application where we can implement
the service and register the device with the Windows UPnP host. For this purpose I
will use a standard C# Console application.
&lt;/p&gt;
&lt;p&gt;
&lt;img src="http://www.baekdorf.dk/christian/content/binary/02_VsNewConsoleApp1.PNG" border=0&gt;
&lt;/p&gt;
&lt;p&gt;
Add the device description and service description files to the console application,
mark then as “Content” and “Copy if newer”.
&lt;/p&gt;
&lt;p&gt;
It is necessary to disable the use of Visual Studio host process when debugging, otherwise
the application will fail when debugging (some COM related issue).
&lt;/p&gt;
&lt;p&gt;
&lt;img src="http://www.baekdorf.dk/christian/content/binary/03_VsNoHostProcess1.PNG" border=0&gt;
&lt;/p&gt;
&lt;p&gt;
Next we need to add some references to the UPnP COM type libraries ("upnpcont.exe"
and "upnp.dll" typical found in “c:\windows\system32”) for the Windows UPnP framework.
&lt;/p&gt;
&lt;p&gt;
&lt;img src="http://www.baekdorf.dk/christian/content/binary/04_UPnP_References.PNG" border=0&gt;
&lt;/p&gt;
&lt;p&gt;
Now we are ready to implement the service, this is done by adding a plain C# class:
&lt;/p&gt;
&lt;p&gt;
&lt;!--
{\rtf1\ansi\ansicpg\lang1024\noproof65001\uc1 \deff0{\fonttbl{\f0\fnil\fcharset0\fprq1 Courier New;}}{\colortbl;??\red0\green0\blue0;\red255\green255\blue255;\red43\green145\blue175;\red0\green0\blue255;\red163\green21\blue21;}??\fs24     [\cf3 ComVisible\cf0 (\cf4 true\cf0 )]\par ??    [\cf3 ClassInterface\cf0 (\cf3 ClassInterfaceType\cf0 .AutoDispatch)]\par ??    \cf4 public\cf0  \cf4 class\cf0  \cf3 MyService\par ??\cf0     \{\par ??        \cf4 private\cf0  \cf4 string\cf0  m_Message;\par ??\par ??        \cf4 public\cf0  \cf4 string\cf0  Message\par ??        \{\par ??            \cf4 get\cf0  \{ \cf4 return\cf0  m_Message; \}\par ??            \cf4 set\cf0  \{ m_Message = \cf4 value\cf0 ; \}\par ??        \}\par ??\par ??        \cf4 public\cf0  \cf4 string\cf0  HelloWorld()\par ??        \{\par ??            \cf4 return\cf0  \cf5 "Hello World, time is "\cf0  +\par ??                \cf3 DateTime\cf0 .Now.ToString();\par ??        \}\par ??    \}\par ??}
--&gt;
&lt;div style="FONT-SIZE: 9pt; BACKGROUND: white; COLOR: black; FONT-FAMILY: Courier New"&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; [&lt;span style="COLOR: #2b91af"&gt;ComVisible&lt;/span&gt;(&lt;span style="COLOR: blue"&gt;true&lt;/span&gt;)]
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; [&lt;span style="COLOR: #2b91af"&gt;ClassInterface&lt;/span&gt;(&lt;span style="COLOR: #2b91af"&gt;ClassInterfaceType&lt;/span&gt;.AutoDispatch)]
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;public&lt;/span&gt; &lt;span style="COLOR: blue"&gt;class&lt;/span&gt; &lt;span style="COLOR: #2b91af"&gt;MyService&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; {
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;private&lt;/span&gt; &lt;span style="COLOR: blue"&gt;string&lt;/span&gt; m_Message;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;public&lt;/span&gt; &lt;span style="COLOR: blue"&gt;string&lt;/span&gt; Message
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; {
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;get&lt;/span&gt; { &lt;span style="COLOR: blue"&gt;return&lt;/span&gt; m_Message;
}
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;set&lt;/span&gt; {
m_Message = &lt;span style="COLOR: blue"&gt;value&lt;/span&gt;; }
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; }
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;public&lt;/span&gt; &lt;span style="COLOR: blue"&gt;string&lt;/span&gt; HelloWorld()
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; {
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;return&lt;/span&gt; &lt;span style="COLOR: #a31515"&gt;"Hello
World, time is "&lt;/span&gt; +
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: #2b91af"&gt;DateTime&lt;/span&gt;.Now.ToString();
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; }
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; }
&lt;/p&gt;
&lt;/div&gt;
&lt;p&gt;
&lt;/p&gt;
&lt;p&gt;
The service class should match the service description; have the same methods and
properties. It also needs to be COM visible and implement the COM IDispatch interface.
&lt;/p&gt;
&lt;p&gt;
Next we need a device control class which acts as a factory for instantiating the
service class. This class is also a plain C# deriving from the interface IUPnPDeviceControl.
&lt;/p&gt;
&lt;p&gt;
&lt;!--
{\rtf1\ansi\ansicpg\lang1024\noproof65001\uc1 \deff0{\fonttbl{\f0\fnil\fcharset0\fprq1 Courier New;}}{\colortbl;??\red0\green0\blue0;\red255\green255\blue255;\red0\green0\blue255;\red43\green145\blue175;}??\fs24     \cf3 public\cf0  \cf3 class\cf0  \cf4 MyDeviceControl\cf0  : \cf4 IUPnPDeviceControl\par ??\cf0     \{\par ??        \cf3 private\cf0  \cf4 MyService\cf0  m_Service;\par ??\par ??        \cf3 public\cf0  \cf3 object\cf0  GetServiceObject(\cf3 string\cf0  bstrUDN, \cf3 string\cf0  bstrServiceId)\par ??        \{\par ??            \cf3 return\cf0  m_Service;\par ??        \}\par ??\par ??        \cf3 public\cf0  \cf3 void\cf0  Initialize(\cf3 string\cf0  bstrXMLDesc, \cf3 string\cf0  bstrDeviceIdentifier, \cf3 string\cf0  bstrInitString)\par ??        \{\par ??            m_Service = \cf3 new\cf0  \cf4 MyService\cf0 ();\par ??        \}\par ??    \}\par ??}
--&gt;
&lt;div style="FONT-SIZE: 9pt; BACKGROUND: white; COLOR: black; FONT-FAMILY: Courier New"&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;public&lt;/span&gt; &lt;span style="COLOR: blue"&gt;class&lt;/span&gt; &lt;span style="COLOR: #2b91af"&gt;MyDeviceControl&lt;/span&gt; : &lt;span style="COLOR: #2b91af"&gt;IUPnPDeviceControl&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; {
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;private&lt;/span&gt; &lt;span style="COLOR: #2b91af"&gt;MyService&lt;/span&gt; m_Service;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;public&lt;/span&gt; &lt;span style="COLOR: blue"&gt;object&lt;/span&gt; GetServiceObject(&lt;span style="COLOR: blue"&gt;string&lt;/span&gt; bstrUDN, &lt;span style="COLOR: blue"&gt;string&lt;/span&gt; bstrServiceId)
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; {
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;return&lt;/span&gt; m_Service;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; }
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;public&lt;/span&gt; &lt;span style="COLOR: blue"&gt;void&lt;/span&gt; Initialize(&lt;span style="COLOR: blue"&gt;string&lt;/span&gt; bstrXMLDesc, &lt;span style="COLOR: blue"&gt;string&lt;/span&gt; bstrDeviceIdentifier, &lt;span style="COLOR: blue"&gt;string&lt;/span&gt; bstrInitString)
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; {
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; m_Service = &lt;span style="COLOR: blue"&gt;new&lt;/span&gt; &lt;span style="COLOR: #2b91af"&gt;MyService&lt;/span&gt;();
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; }
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; }
&lt;/p&gt;
&lt;/div&gt;
&lt;p&gt;
&lt;/p&gt;
&lt;p&gt;
Finally we need to fill out the Main method with the code for registering the device
control class with the Windows UPnP framework. See &lt;a href="http://msdn.microsoft.com/en-us/library/aa382282(VS.85).aspx" target=_blank&gt;Registering
a Hosted Device With the Device Host&lt;/a&gt; on MSDN for more information for more information.
&lt;/p&gt;
&lt;p&gt;
Note that we need to make a call to &lt;a href="http://msdn.microsoft.com/en-us/library/ms693736(VS.85).aspx" target=_blank&gt;CoInitializeSecurity&lt;/a&gt; to
get the COM Interorp to work. For details abort this see the downloadable code.
&lt;/p&gt;
&lt;p&gt;
&lt;!--
{\rtf1\ansi\ansicpg\lang1024\noproof65001\uc1 \deff0{\fonttbl{\f0\fnil\fcharset0\fprq1 Courier New;}}{\colortbl;??\red0\green0\blue0;\red255\green255\blue255;\red0\green0\blue255;\red43\green145\blue175;\red163\green21\blue21;}??\fs24     \cf3 static\cf0  \cf3 void\cf0  Main(\cf3 string\cf0 [] args)\par ??    \{\par ??        \cf3 try\par ??\cf0         \{\par ??            \cf3 int\cf0  result = \cf4 Win32\cf0 .CoInitializeSecurity(\cf4 IntPtr\cf0 .Zero, -1,\par ??                \cf4 IntPtr\cf0 .Zero, \cf4 IntPtr\cf0 .Zero,\par ??                \cf4 Win32\cf0 .\cf4 RpcAuthnLevel\cf0 .Default, \cf4 Win32\cf0 .\cf4 RpcImpLevel\cf0 .Impersonate,\par ??                \cf4 IntPtr\cf0 .Zero, \cf4 Win32\cf0 .\cf4 EoAuthnCap\cf0 .None, \cf4 IntPtr\cf0 .Zero);\par ??            \cf3 if\cf0  (result != 0)\par ??            \{\par ??                \cf4 Console\cf0 .WriteLine(\cf5 "CoInitializeSecurity failed."\cf0 );\par ??                \cf3 return\cf0 ;\par ??            \}\par ??\par ??            \cf3 string\cf0  descDoc = \cf4 File\cf0 .ReadAllText(\cf5 "DeviceDescription.xml"\cf0 );\par ??            \cf3 object\cf0  myDeviceControl = \cf3 new\cf0  \cf4 MyDeviceControl\cf0 ();\par ??\par ??            \cf4 IUPnPRegistrar\cf0  registrar = (\cf4 IUPnPRegistrar\cf0 )\cf3 new\cf0  \cf4 UPnPRegistrarClass\cf0 ();\par ??\par ??            \cf3 string\cf0  deviceId = registrar.RegisterRunningDevice(\par ??                descDoc, myDeviceControl, \cf5 "Init string..."\cf0 ,\par ??                \cf4 Directory\cf0 .GetCurrentDirectory(), 3200);\par ??\par ??            \cf4 Console\cf0 .WriteLine(\cf5 "Ready, press any key to stop..."\cf0 );\par ??            \cf4 Console\cf0 .ReadLine();\par ??\par ??            registrar.UnregisterDevice(deviceId, 1);\par ??        \}\par ??        \cf3 catch\cf0  (\cf4 Exception\cf0  ex)\par ??        \{\par ??            \cf4 Console\cf0 .WriteLine(ex.ToString());\par ??        \}\par ??    \}\par ??}
--&gt;
&lt;div style="FONT-SIZE: 9pt; BACKGROUND: white; COLOR: black; FONT-FAMILY: Courier New"&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;static&lt;/span&gt; &lt;span style="COLOR: blue"&gt;void&lt;/span&gt; Main(&lt;span style="COLOR: blue"&gt;string&lt;/span&gt;[]
args)
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; {
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;try&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; {
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;int&lt;/span&gt; result
= &lt;span style="COLOR: #2b91af"&gt;Win32&lt;/span&gt;.CoInitializeSecurity(&lt;span style="COLOR: #2b91af"&gt;IntPtr&lt;/span&gt;.Zero,
-1,
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: #2b91af"&gt;IntPtr&lt;/span&gt;.Zero, &lt;span style="COLOR: #2b91af"&gt;IntPtr&lt;/span&gt;.Zero,
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: #2b91af"&gt;Win32&lt;/span&gt;.&lt;span style="COLOR: #2b91af"&gt;RpcAuthnLevel&lt;/span&gt;.Default, &lt;span style="COLOR: #2b91af"&gt;Win32&lt;/span&gt;.&lt;span style="COLOR: #2b91af"&gt;RpcImpLevel&lt;/span&gt;.Impersonate,
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: #2b91af"&gt;IntPtr&lt;/span&gt;.Zero, &lt;span style="COLOR: #2b91af"&gt;Win32&lt;/span&gt;.&lt;span style="COLOR: #2b91af"&gt;EoAuthnCap&lt;/span&gt;.None, &lt;span style="COLOR: #2b91af"&gt;IntPtr&lt;/span&gt;.Zero);
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;if&lt;/span&gt; (result
!= 0)
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; {
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: #2b91af"&gt;Console&lt;/span&gt;.WriteLine(&lt;span style="COLOR: #a31515"&gt;"CoInitializeSecurity
failed."&lt;/span&gt;);
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;return&lt;/span&gt;;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; }
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;string&lt;/span&gt; descDoc
= &lt;span style="COLOR: #2b91af"&gt;File&lt;/span&gt;.ReadAllText(&lt;span style="COLOR: #a31515"&gt;"DeviceDescription.xml"&lt;/span&gt;);
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;object&lt;/span&gt; myDeviceControl
= &lt;span style="COLOR: blue"&gt;new&lt;/span&gt; &lt;span style="COLOR: #2b91af"&gt;MyDeviceControl&lt;/span&gt;();
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: #2b91af"&gt;IUPnPRegistrar&lt;/span&gt; registrar
= (&lt;span style="COLOR: #2b91af"&gt;IUPnPRegistrar&lt;/span&gt;)&lt;span style="COLOR: blue"&gt;new&lt;/span&gt; &lt;span style="COLOR: #2b91af"&gt;UPnPRegistrarClass&lt;/span&gt;();
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;string&lt;/span&gt; deviceId
= registrar.RegisterRunningDevice(
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; descDoc,
myDeviceControl, &lt;span style="COLOR: #a31515"&gt;"Init string..."&lt;/span&gt;,
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: #2b91af"&gt;Directory&lt;/span&gt;.GetCurrentDirectory(),
3200);
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: #2b91af"&gt;Console&lt;/span&gt;.WriteLine(&lt;span style="COLOR: #a31515"&gt;"Ready,
press any key to stop..."&lt;/span&gt;);
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: #2b91af"&gt;Console&lt;/span&gt;.ReadLine();
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; registrar.UnregisterDevice(deviceId,
1);
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; }
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;catch&lt;/span&gt; (&lt;span style="COLOR: #2b91af"&gt;Exception&lt;/span&gt; ex)
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; {
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: #2b91af"&gt;Console&lt;/span&gt;.WriteLine(ex.ToString());
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; }
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; }
&lt;/p&gt;
&lt;/div&gt;
&lt;p&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;strong&gt;Testing the UPnP device and service&lt;/strong&gt;
&lt;/p&gt;
&lt;p&gt;
Now we can build and start the program
&lt;/p&gt;
&lt;p&gt;
&lt;img src="http://www.baekdorf.dk/christian/content/binary/05_RunningApp.png" border=0&gt;
&lt;/p&gt;
&lt;p&gt;
To test the UPnP device and service we will use Intel Device Spy for UPnP, this way
we can test the HelloWorld method without having to implement a UPnP client.
&lt;/p&gt;
&lt;p&gt;
&lt;img src="http://www.baekdorf.dk/christian/content/binary/06_DeviceSpy.png" border=0&gt;
&lt;/p&gt;
&lt;p&gt;
If our new UPnP device is running, we should see it in the UPnP Device Spy with the
name MyDevice and should be able to find the service and HelloWorld method. Try invoking
the HelloWorld method by right-clicking it.
&lt;/p&gt;
&lt;p&gt;
&lt;strong&gt;Downloadable code&lt;/strong&gt;
&lt;/p&gt;
&lt;p&gt;
You can download the sample code here: &lt;a href="http://www.baekdorf.dk/christian/content/binary/MyUPnP-Tutorial-01.zip"&gt;MyUPnP-Tutorial-01.zip
(33,37 KB)&lt;/a&gt;
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.baekdorf.dk/christian/aggbug.ashx?id=f82d01d7-2ff5-4bde-914a-be2cabef315c" /&gt;</description>
      <comments>http://www.baekdorf.dk/christian/CommentView,guid,f82d01d7-2ff5-4bde-914a-be2cabef315c.aspx</comments>
    </item>
  </channel>
</rss>
