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

<channel>
	<title>David DeWinter</title>
	<atom:link href="http://blogs.rev-net.com/ddewinter/feed/" rel="self" type="application/rss+xml" />
	<link>http://blogs.rev-net.com/ddewinter</link>
	<description>A Developer's Melting Pot</description>
	<pubDate>Mon, 25 Aug 2008 03:50:05 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.6</generator>
	<language>en</language>
			<item>
		<title>DBML Fixup Preview</title>
		<link>http://blogs.rev-net.com/ddewinter/2008/08/24/dbml-fixup-preview/</link>
		<comments>http://blogs.rev-net.com/ddewinter/2008/08/24/dbml-fixup-preview/#comments</comments>
		<pubDate>Mon, 25 Aug 2008 03:41:44 +0000</pubDate>
		<dc:creator>David DeWinter</dc:creator>
		
		<category><![CDATA[C# .NET]]></category>

		<category><![CDATA[DBML Fixup]]></category>

		<category><![CDATA[LINQ to SQL]]></category>

		<category><![CDATA[VSX]]></category>

		<category><![CDATA[Visual Studio 2008]]></category>

		<category><![CDATA[C#]]></category>

		<category><![CDATA[DBML]]></category>

		<category><![CDATA[DBML Sync]]></category>

		<category><![CDATA[LINQ]]></category>

		<category><![CDATA[LINQ to SQL Designer]]></category>

		<category><![CDATA[Schema Sync]]></category>

		<category><![CDATA[Visual Studio]]></category>

		<guid isPermaLink="false">http://blogs.rev-net.com/ddewinter/2008/08/24/dbml-fixup-preview/</guid>
		<description><![CDATA[Back in February I blogged about DBML Fixup&#8212;a tool whose goal was to sync LINQ to SQL models with their respective database schemas from within the Visual Studio environment, as well as to handle running various fixup tasks on models. Now it&#8217;s six months later, and I have a much clearer vision of what the [...]]]></description>
			<content:encoded><![CDATA[<p>Back in <a href="http://blogs.rev-net.com/ddewinter/2008/02/16/linq-to-sql-and-database-schema-sync/">February</a> I blogged about DBML Fixup&#8212;a tool whose goal was to sync LINQ to SQL models with their respective database schemas from within the Visual Studio environment, as well as to handle running various fixup tasks on models. Now it&#8217;s six months later, and I have a much clearer vision of what the tool is meant to be as well as a firmer command on VSX. The following screencast is a preview of the features of DBML Fixup.</p>
<p>&#160;</p>
<div id="media"><object id="csSWF" codebase="http://active.macromedia.com/flash7/cabs/ swflash.cab#version=9,0,28,0" height="498" width="640" classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"><param name="_cx" value="16933"><param name="_cy" value="13176"><param name="FlashVars" value=""><param name="Movie" value="http://blogs.rev-net.com/ddewinter/wp-content/screencasts/dbmlfixup/DBMLFixupAug08.swf"><param name="Src" value="http://blogs.rev-net.com/ddewinter/wp-content/screencasts/dbmlfixup/DBMLFixupAug08.swf"><param name="WMode" value="Window"><param name="Play" value="0"><param name="Loop" value="-1"><param name="Quality" value="High"><param name="SAlign" value=""><param name="Menu" value="-1"><param name="Base" value=""><param name="AllowScriptAccess" value="always"><param name="Scale" value="ShowAll"><param name="DeviceFont" value="0"><param name="EmbedMovie" value="0"><param name="BGColor" value="1A1A1A"><param name="SWRemote" value=""><param name="MovieData" value=""><param name="SeamlessTabbing" value="1"><param name="Profile" value="0"><param name="ProfileAddress" value=""><param name="ProfilePort" value="0"><param name="AllowNetworking" value="all"><param name="AllowFullScreen" value="true"><embed name="csSWF" src="http://blogs.rev-net.com/ddewinter/wp-content/screencasts/dbmlfixup/DBMLFixupAug08.swf" width="640" height="498" bgcolor="#1a1a1a" quality="best" allowscriptaccess="always" allowfullscreen="true" scale="showall" flashvars="autostart=false" pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash"></embed></object></div>
<p>&#160;</p>
<p>Here are some previous posts which (briefly) describe the domain:</p>
<p><a title="http://blogs.rev-net.com/ddewinter/2008/02/16/the-linq-to-sql-model/" href="http://blogs.rev-net.com/ddewinter/2008/02/16/the-linq-to-sql-model/">http://blogs.rev-net.com/ddewinter/2008/02/16/the-linq-to-sql-model/</a></p>
<p><a title="http://blogs.rev-net.com/ddewinter/2008/02/16/linq-to-sql-and-database-schema-sync/" href="http://blogs.rev-net.com/ddewinter/2008/02/16/linq-to-sql-and-database-schema-sync/">http://blogs.rev-net.com/ddewinter/2008/02/16/linq-to-sql-and-database-schema-sync/</a></p>
<p>&#160;</p>
<p>Any ideas about directions for the tool? Or maybe something that wasn&#8217;t covered in the screencast? I&#8217;d love to hear your ideas.</p>
]]></content:encoded>
			<wfw:commentRss>http://blogs.rev-net.com/ddewinter/2008/08/24/dbml-fixup-preview/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Generate Serialization Classes As Part of Your Build (Part 1)</title>
		<link>http://blogs.rev-net.com/ddewinter/2008/07/08/generate-serialization-classes-as-part-of-your-build-part-1/</link>
		<comments>http://blogs.rev-net.com/ddewinter/2008/07/08/generate-serialization-classes-as-part-of-your-build-part-1/#comments</comments>
		<pubDate>Tue, 08 Jul 2008 12:58:56 +0000</pubDate>
		<dc:creator>David DeWinter</dc:creator>
		
		<category><![CDATA[C# .NET]]></category>

		<category><![CDATA[MSBuild]]></category>

		<category><![CDATA[Visual Studio 2008]]></category>

		<category><![CDATA[.NET]]></category>

		<category><![CDATA[Automating]]></category>

		<category><![CDATA[C#]]></category>

		<category><![CDATA[Serialization]]></category>

		<category><![CDATA[XML]]></category>

		<category><![CDATA[xsd.exe]]></category>

		<guid isPermaLink="false">http://blogs.rev-net.com/ddewinter/2008/07/08/generate-serialization-classes-as-part-of-your-build-part-1/</guid>
		<description><![CDATA[Yes, I am back from the grave. The past two months have been infuriatingly busy for me (and you&#8217;ll see why in a later post), but I finally have some time to write again. The topic? Generating serialization classes as part of your build process (Part 1) and in your own way (Part 2).
I might [...]]]></description>
			<content:encoded><![CDATA[<p>Yes, I <em>am</em> back from the grave. The past two months have been infuriatingly busy for me (and you&#8217;ll see why in a later post), but I finally have some time to write again. The topic? Generating serialization classes <em>as part of your build process </em>(Part 1) and <em>in your own way </em>(Part 2).</p>
<p>I might reach only a niche of .NET developers with this post, but it&#8217;s something that niche should be aware of. There is a tool in the .NET framework called <a href="http://msdn.microsoft.com/en-us/library/x6c1kb0s(VS.71).aspx">xsd.exe</a>, and one of its functions is to generate code, specifically .NET classes, from an XML Schema file (XSD). The tool decorates these classes with XML serialization attributes such that when .NET serializes an instance of the generated class that represents the root element, the output conforms to that XML schema. Often, developers using XML schemas will need to change them throughout the course of a project. Leveraging xsd.exe in a project thus requires the generated classes to be updated when an XML schema is updated. This is a bit dangerous in larger projects because not all developers may realize that the tool must be re-run, especially in the case of extremely minor changes to the schema.</p>
<p>Wouldn&#8217;t it be better to have a tighter integration among the XML schema, the generated classes, and the build environment? Fortunately, we can achieve this with a few simple steps, thanks to the MSBuild system for projects inside Visual Studio.</p>
<p><span id="more-105"></span></p>
<p>We&#8217;ll start from scratch here, so first things first: create a new project. Here I&#8217;ll just create a class library called &quot;DeWinterXsd&quot;. Then add a new XML Schema file to the project. (You can find it under the Data category of items.)</p>
<p style="list-style-type: none"><a href="http://blogs.rev-net.com/ddewinter/wp-content/uploads/2008/07/image.png"><img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="486" alt="image" src="http://blogs.rev-net.com/ddewinter/wp-content/uploads/2008/07/image-thumb.png" width="808" border="0" /></a></p>
<p>Replace the contents of the schema file with the following snippet. It&#8217;s a very simple schema, featuring a root element and two child elements with three attributes among them.</p>
<div style="font-size: 8pt; background: white; margin-bottom: 10px; 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>&quot;<span style="color: blue">1.0</span>&quot;<span style="color: blue"> </span><span style="color: red">encoding</span><span style="color: blue">=</span>&quot;<span style="color: blue">utf-8</span>&quot;<span style="color: blue">?&gt;</span></p>
<p style="margin: 0px"><span style="color: blue">&lt;</span><span style="color: #a31515">xs:schema</span><span style="color: blue"> </span><span style="color: red">id</span><span style="color: blue">=</span>&quot;<span style="color: blue">SampleSchema</span>&quot;</p>
<p style="margin: 0px"><span style="color: blue">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span><span style="color: red">targetNamespace</span><span style="color: blue">=</span>&quot;<span style="color: blue">http://schemas.example.com/SampleSchema.xsd</span>&quot;</p>
<p style="margin: 0px"><span style="color: blue">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span><span style="color: red">elementFormDefault</span><span style="color: blue">=</span>&quot;<span style="color: blue">qualified</span>&quot;</p>
<p style="margin: 0px"><span style="color: blue">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span><span style="color: red">xmlns</span><span style="color: blue">=</span>&quot;<span style="color: blue">http://schemas.example.com/SampleSchema.xsd</span>&quot;</p>
<p style="margin: 0px"><span style="color: blue">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span><span style="color: red">xmlns:xs</span><span style="color: blue">=</span>&quot;<span style="color: blue">http://www.w3.org/2001/XMLSchema</span>&quot;<span style="color: blue">&gt;</span></p>
<p style="margin: 0px"><span style="color: blue">&#160; &lt;</span><span style="color: #a31515">xs:element</span><span style="color: blue"> </span><span style="color: red">name</span><span style="color: blue">=</span>&quot;<span style="color: blue">root</span>&quot;<span style="color: blue">&gt;</span></p>
<p style="margin: 0px"><span style="color: blue">&#160;&#160;&#160; &lt;</span><span style="color: #a31515">xs:complexType</span><span style="color: blue">&gt;</span></p>
<p style="margin: 0px"><span style="color: blue">&#160;&#160;&#160;&#160;&#160; &lt;</span><span style="color: #a31515">xs:sequence</span><span style="color: blue">&gt;</span></p>
<p style="margin: 0px"><span style="color: blue">&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;</span><span style="color: #a31515">xs:element</span><span style="color: blue"> </span><span style="color: red">name</span><span style="color: blue">=</span>&quot;<span style="color: blue">first</span>&quot;<span style="color: blue">&gt;</span></p>
<p style="margin: 0px"><span style="color: blue">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;</span><span style="color: #a31515">xs:complexType</span><span style="color: blue">&gt;</span></p>
<p style="margin: 0px"><span style="color: blue">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;</span><span style="color: #a31515">xs:attribute</span><span style="color: blue"> </span><span style="color: red">name</span><span style="color: blue">=</span>&quot;<span style="color: blue">name</span>&quot;<span style="color: blue"> </span><span style="color: red">type</span><span style="color: blue">=</span>&quot;<span style="color: blue">xs:token</span>&quot;<span style="color: blue"> /&gt;</span></p>
<p style="margin: 0px"><span style="color: blue">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;</span><span style="color: #a31515">xs:attribute</span><span style="color: blue"> </span><span style="color: red">name</span><span style="color: blue">=</span>&quot;<span style="color: blue">value</span>&quot;<span style="color: blue"> </span><span style="color: red">type</span><span style="color: blue">=</span>&quot;<span style="color: blue">xs:token</span>&quot;<span style="color: blue"> /&gt;</span></p>
<p style="margin: 0px"><span style="color: blue">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;/</span><span style="color: #a31515">xs:complexType</span><span style="color: blue">&gt;</span></p>
<p style="margin: 0px"><span style="color: blue">&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;/</span><span style="color: #a31515">xs:element</span><span style="color: blue">&gt;</span></p>
<p style="margin: 0px"><span style="color: blue">&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;</span><span style="color: #a31515">xs:element</span><span style="color: blue"> </span><span style="color: red">name</span><span style="color: blue">=</span>&quot;<span style="color: blue">second</span>&quot;<span style="color: blue">&gt;</span></p>
<p style="margin: 0px"><span style="color: blue">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;</span><span style="color: #a31515">xs:complexType</span><span style="color: blue">&gt;</span></p>
<p style="margin: 0px"><span style="color: blue">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;</span><span style="color: #a31515">xs:attribute</span><span style="color: blue"> </span><span style="color: red">name</span><span style="color: blue">=</span>&quot;<span style="color: blue">origin</span>&quot;<span style="color: blue"> </span><span style="color: red">type</span><span style="color: blue">=</span>&quot;<span style="color: blue">xs:token</span>&quot;<span style="color: blue"> /&gt;</span></p>
<p style="margin: 0px"><span style="color: blue">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;/</span><span style="color: #a31515">xs:complexType</span><span style="color: blue">&gt;</span></p>
<p style="margin: 0px"><span style="color: blue">&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;/</span><span style="color: #a31515">xs:element</span><span style="color: blue">&gt;</span></p>
<p style="margin: 0px"><span style="color: blue">&#160;&#160;&#160;&#160;&#160; &lt;/</span><span style="color: #a31515">xs:sequence</span><span style="color: blue">&gt;</span></p>
<p style="margin: 0px"><span style="color: blue">&#160;&#160;&#160; &lt;/</span><span style="color: #a31515">xs:complexType</span><span style="color: blue">&gt;</span></p>
<p style="margin: 0px"><span style="color: blue">&#160; &lt;/</span><span style="color: #a31515">xs:element</span><span style="color: blue">&gt;</span></p>
<p style="margin: 0px"><span style="color: blue">&lt;/</span><span style="color: #a31515">xs:schema</span><span style="color: blue">&gt;</span></p>
</p></div>
<p>Now that you have the schema, add a new class to your project with the same name as your XML schema file. For example, the name of my schema file is &quot;SampleSchema.xsd&quot;, and the name of the class is &quot;SampleSchema.cs&quot;. This should nest the .cs file underneath the schema file, akin to how code-behind files are nested under UI files (<em>e.g.</em> Windows Forms, XAML). So how do we generate serialization classes? Right click on your project file and select &quot;Unload Project&quot;.</p>
<p><a href="http://blogs.rev-net.com/ddewinter/wp-content/uploads/2008/07/image1.png"><img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="519" alt="image" src="http://blogs.rev-net.com/ddewinter/wp-content/uploads/2008/07/image-thumb1.png" width="312" border="0" /></a></p>
<p>And then right click on the project again and click &quot;Edit <em>xxx</em>.csproj&quot;.</p>
<p><a href="http://blogs.rev-net.com/ddewinter/wp-content/uploads/2008/07/image2.png"><img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="169" alt="image" src="http://blogs.rev-net.com/ddewinter/wp-content/uploads/2008/07/image-thumb2.png" width="281" border="0" /></a></p>
<p>Now you&#8217;ll see the contents of the .csproj file itself. If you&#8217;re not familiar with the MSBuild system, then here&#8217;s the gist of it. Building a project in your solution executes a series of tasks, which are logically grouped into <em>targets</em>. Building will actually run only one target, <em>Compile</em>. However, the Compile target can depend on other targets in order to run correctly, so those targets are run before Compile, and so on. Take a look at your output window sometime while building; it will show you the tasks being executed by each target. For more information, read an MSBuild tutorial, like <a href="http://www.codeplex.com/msbuildshellex/Wiki/View.aspx?title=MSBuild%20Tutorial&amp;referringTitle=Manual">this one</a>.</p>
<p>What we&#8217;ll do now is say that before the compilation target occurs, we want to generate serialization classes using xsd.exe. Scroll to the bottom of the file and you should see this:</p>
<div style="font-size: 8pt; background: white; margin-bottom: 10px; color: black; font-family: courier new">
<p style="margin: 0px"><span style="color: blue">&lt;!&#8211;</span><span style="color: green"> To modify your build process, add your task inside one of the targets below and uncomment it.</span></p>
<p style="margin: 0px"><span style="color: green">Other similar extension points exist, see Microsoft.Common.targets.</span></p>
<p style="margin: 0px"><span style="color: green">&lt;Target Name=&quot;BeforeBuild&quot;&gt;</span></p>
<p style="margin: 0px"><span style="color: green">&lt;/Target&gt;</span></p>
<p style="margin: 0px"><span style="color: green">&lt;Target Name=&quot;AfterBuild&quot;&gt;</span></p>
<p style="margin: 0px"><span style="color: green">&lt;/Target&gt;</span></p>
<p style="margin: 0px"><span style="color: blue">&#8211;&gt;</span></p>
</p></div>
<p>For now, we&#8217;ll uncomment the BeforeBuild target and insert a task to run xsd.exe. But since this is logically better off as its own target (<em>e.g.</em> GenerateSerializationClasses), we&#8217;ll specify that the BeforeBuild target depends on another target of our creation.</p>
<div style="font-size: 8pt; background: white; margin-bottom: 10px; 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>&quot;<span style="color: blue">GenerateSerializationClasses</span>&quot;<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>
<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>&quot;<span style="color: blue">BeforeBuild</span>&quot;<span style="color: blue"> </span><span style="color: red">DependsOnTargets</span><span style="color: blue">=</span>&quot;<span style="color: blue">GenerateSerializationClasses</span>&quot;<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>
</p></div>
<p>I&#8217;ve placed the above lines right above the comments that discuss the BeforeBuild and AfterBuild targets (&quot;To modify your build process, add your task&#8230;&quot;). Now&#8230;to actually do something inside GenerateSerializationClasses requires the use of the Exec task, which as its name implies, will execute a task as if running it from the command line. Here we need to run xsd.exe, so we need to find where this tool is located. To do this easily, run &quot;where xsd.exe&quot; from a Visual Studio Command Prompt. My xsd.exe is in one of the Windows SDK directories, so I&#8217;ll add it to the Exec task like this:</p>
<div style="font-size: 8pt; background: white; margin-bottom: 10px; 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>&quot;<span style="color: blue">GenerateSerializationClasses</span>&quot;<span style="color: blue">&gt;</span></p>
<p style="margin: 0px"><span style="color: blue">&#160; &lt;</span><span style="color: #a31515">Exec</span><span style="color: blue"> </span><span style="color: red">Command</span><span style="color: blue">=</span>&quot;<span style="color: red">&amp;quot;</span><span style="color: blue">C:\Program Files\Microsoft SDKs\Windows\v6.0\Bin\xsd.exe</span><span style="color: red">&amp;quot;</span><span style="color: blue"> SampleSchema.xsd /classes</span>&quot;<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>
</p></div>
<p>Straightforward, right? The Exec task tells MSBuild to run xsd.exe using the specified command parameters, which will generate serialization classes based off my XSD file (SampleSchema.xsd). If you reload and rebuild your project, then you&#8217;ll see the serialization classes appear in the .cs file you provided. But there&#8217;s one more thing we can do here first! It makes sense that we want to generate classes only when the schema file has actually changed, so we&#8217;ll need a few more attributes to the GenerateSerializationClasses target. The <em>Inputs</em> attribute specifies the inputs to consider for the target, and the <em>Outputs</em> attribute specifies the outputs to consider for the target. MSBuild will use this data to determine whether to run the target at all. Here, our logic is simple: if the schema file has been modified after the last modified time of the class file, then run the target, and that&#8217;s exactly what MSBuild will do. The final XML snippet:</p>
<div style="font-size: 8pt; background: white; margin-bottom: 10px; 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>&quot;<span style="color: blue">GenerateSerializationClasses</span>&quot;<span style="color: blue"> </span><span style="color: red">Inputs</span><span style="color: blue">=</span>&quot;<span style="color: blue">SampleSchema.xsd</span>&quot;<span style="color: blue"> </span><span style="color: red">Outputs</span><span style="color: blue">=</span>&quot;<span style="color: blue">SampleSchema.cs</span>&quot;<span style="color: blue">&gt;</span></p>
<p style="margin: 0px"><span style="color: blue">&#160; &lt;</span><span style="color: #a31515">Exec<span style="color: #0000ff"> </span></span><span style="color: red">Command</span><span style="color: blue">=</span>&quot;<span style="color: red">&amp;quot;</span><span style="color: blue">C:\Program Files\Microsoft SDKs\Windows\v6.0\Bin\xsd.exe</span><span style="color: red">&amp;quot;</span><span style="color: blue"> SampleSchema.xsd /classes</span>&quot;<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>
<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>&quot;<span style="color: blue">BeforeBuild</span>&quot;<span style="color: blue"> </span><span style="color: red">DependsOnTargets</span><span style="color: blue">=</span>&quot;<span style="color: blue">GenerateSerializationClasses</span>&quot;<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>
<p style="margin: 0px"><span style="color: blue">&lt;!&#8211;</span><span style="color: green"> To modify your build process, add your task inside one of the targets below and uncomment it. </span></p>
<p style="margin: 0px"><span style="color: green">Other similar extension points exist, see Microsoft.Common.targets.</span></p>
<p style="margin: 0px"><span style="color: green">&lt;Target Name=&quot;BeforeBuild&quot;&gt;</span></p>
<p style="margin: 0px"><span style="color: green">&lt;/Target&gt;</span></p>
<p style="margin: 0px"><span style="color: green">&lt;Target Name=&quot;AfterBuild&quot;&gt;</span></p>
<p style="margin: 0px"><span style="color: green">&lt;/Target&gt;</span></p>
<p style="margin: 0px"><span style="color: blue">&#8211;&gt;</span></p>
</p></div>
<p>Now, if you reload and rebuild your project, you can see the fruits of your labor:</p>
<p><a href="http://blogs.rev-net.com/ddewinter/wp-content/uploads/2008/07/image3.png"><img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="544" alt="image" src="http://blogs.rev-net.com/ddewinter/wp-content/uploads/2008/07/image-thumb3.png" width="648" border="0" /></a></p>
<p>We&#8217;ve generated the code, but it&#8217;s not the nicest output. Our classes have camel-cased names to match our element names, and the comments are non-existent for classes and publicly exposed members. Of course, we didn&#8217;t add any comments in our XML schema, but even if we used the xs:documentation element to document our elements and attributes, those comments <em>would not</em> be carried across to the generated code.</p>
<p>Next time, I&#8217;ll show you how to remedy these and other problems by building your own MSBuild task that can generate the same quality of code as xsd.exe but with a few custom enhancements.</p>
]]></content:encoded>
			<wfw:commentRss>http://blogs.rev-net.com/ddewinter/2008/07/08/generate-serialization-classes-as-part-of-your-build-part-1/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Entity Framework Stored Procedure Generation</title>
		<link>http://blogs.rev-net.com/ddewinter/2008/04/26/entity-framework-stored-procedure-generation/</link>
		<comments>http://blogs.rev-net.com/ddewinter/2008/04/26/entity-framework-stored-procedure-generation/#comments</comments>
		<pubDate>Sat, 26 Apr 2008 21:24:13 +0000</pubDate>
		<dc:creator>David DeWinter</dc:creator>
		
		<category><![CDATA[Entity Framework]]></category>

		<category><![CDATA[SQL Server 2005]]></category>

		<category><![CDATA[Code Generation]]></category>

		<category><![CDATA[SMO]]></category>

		<category><![CDATA[Sproc]]></category>

		<category><![CDATA[Stored Procedure]]></category>

		<category><![CDATA[T4]]></category>

		<category><![CDATA[Text Template]]></category>

		<guid isPermaLink="false">http://blogs.rev-net.com/ddewinter/index.php/2008/04/26/entity-framework-stored-procedure-generation/</guid>
		<description><![CDATA[At work my team and I are utilizing the ADO.NET Entity Framework as a means to mitigate the object-relational impedance mismatch. Simply put, we&#8217;re utilizing it as an object-relational mapper for our latest project. So far we have been really impressed with the flexibility it provides us, especially surrounding the area of mapping the same [...]]]></description>
			<content:encoded><![CDATA[<p>At work my team and I are utilizing the <a href="http://msdn2.microsoft.com/en-us/library/aa697427(VS.80).aspx">ADO.NET Entity Framework</a> as a means to mitigate the <a href="http://en.wikipedia.org/wiki/Object-Relational_impedance_mismatch">object-relational impedance mismatch</a>. Simply put, we&#8217;re utilizing it as an object-relational mapper for our latest project. So far we have been really impressed with the flexibility it provides us, especially surrounding the area of mapping the same table to multiple entity types and creating inheritance relationships among those entity types. It has proven itself as a much more viable candidate than .netTiers or LINQ to SQL for us.</p>
<p>While I have a lot of praise for the Entity Framework, there are some quirks that take getting used to. For example, you can&#8217;t update properties that are part of a primary key, even though you can update (non-identity) columns that are part of the primary key in SQL Server 2005. Another is the requirement that if an entity will be inserted into the database using a stored procedure, it must also be updated and deleted through a stored procedure. Yet another is that each stored procedure mapped to a particular entity type must have parameters mapped to every association key, regardless of the type of stored procedure (INSERT, UPDATE, or DELETE). For example, consider the following model:</p>
<p><a href="http://blogs.rev-net.com/ddewinter/wp-content/uploads/2008/04/image23.png"><img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="378" alt="image" src="http://blogs.rev-net.com/ddewinter/wp-content/uploads/2008/04/image-thumb5.png" width="511" border="0" /></a>&#160;</p>
<p>If I created stored procedures for the Account entity to use in my EF model, they&#8217;d look like this:</p>
<div style="font-size: 8pt; background: white; margin-bottom: 10px; color: black; font-family: courier new">
<p style="margin: 0px; text-align: left"><span style="color: blue">CREATE PROC </span>dbo.Account_Insert</p>
<p style="margin: 0px; text-align: left">(</p>
<p style="margin: 0px; text-align: left">&#160;&#160;&#160; @customerId <span style="color: blue">INT</span></p>
<p style="margin: 0px; text-align: left">)</p>
<p style="margin: 0px; text-align: left"><span style="color: blue">AS</span></p>
<p style="margin: 0px; text-align: left"><span style="color: blue">BEGIN</span></p>
<p style="margin: 0px; text-align: left">&#160;&#160;&#160; <span style="color: blue">INSERT INTO </span>Account (customerId)</p>
<p style="margin: 0px; text-align: left">&#160;&#160;&#160; <span style="color: blue">VALUES </span>(@customerId)</p>
<p style="margin: 0px; text-align: left">&#160;</p>
<p style="margin: 0px; text-align: left">&#160;&#160;&#160; <span style="color: blue">SELECT SCOPE_IDENTITY</span>() <span style="color: blue">as </span>accountId</p>
<p style="margin: 0px; text-align: left"><span style="color: blue">END</span></p>
<p style="margin: 0px; text-align: left">GO</p>
<p style="margin: 0px; text-align: left">&#160;</p>
<p style="margin: 0px; text-align: left"><span style="color: blue">CREATE PROC </span>dbo.Account_Update</p>
<p style="margin: 0px; text-align: left">(</p>
<p style="margin: 0px; text-align: left">&#160;&#160;&#160; @accountId <span style="color: blue">INT</span>,</p>
<p style="margin: 0px; text-align: left">&#160;&#160;&#160; @customerId <span style="color: blue">INT</span></p>
<p style="margin: 0px; text-align: left">)</p>
<p style="margin: 0px; text-align: left"><span style="color: blue">AS</span></p>
<p style="margin: 0px; text-align: left"><span style="color: blue">BEGIN</span></p>
<p style="margin: 0px; text-align: left">&#160;&#160;&#160; <span style="color: blue">UPDATE </span>Account</p>
<p style="margin: 0px; text-align: left">&#160;&#160;&#160; <span style="color: blue">SET </span>customerId = @customerId</p>
<p style="margin: 0px; text-align: left">&#160;&#160;&#160; <span style="color: blue">WHERE </span>accountId = @accountId</p>
<p style="margin: 0px; text-align: left"><span style="color: blue">END</span></p>
<p style="margin: 0px; text-align: left">&#160;</p>
<p style="margin: 0px; text-align: left"><span style="color: blue">CREATE PROC </span>dbo.Account_Delete</p>
<p style="margin: 0px; text-align: left">(</p>
<p style="margin: 0px; text-align: left">&#160;&#160;&#160; @accountId <span style="color: blue">INT</span>,</p>
<p style="margin: 0px; text-align: left">&#160;&#160;&#160; @customerId <span style="color: blue">INT</span></p>
<p style="margin: 0px; text-align: left">)</p>
<p style="margin: 0px; text-align: left"><span style="color: blue">AS</span></p>
<p style="margin: 0px; text-align: left"><span style="color: blue">BEGIN</span></p>
<p style="margin: 0px; text-align: left">&#160;&#160;&#160; <span style="color: blue">DELETE FROM </span>Account</p>
<p style="margin: 0px; text-align: left">&#160;&#160;&#160; <span style="color: blue">WHERE </span>accountId = @accountId</p>
<p style="margin: 0px; text-align: left"><span style="color: blue">END</span></p>
</p></div>
<p>Notice the delete stored procedure&#8212;it must take in both the ID of the Account and the ID of the Customer it is associated with. Based on <a href="http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=2984204&amp;SiteID=1">Colin Meek&#8217;s post here</a>, I can understand why this is necessitated by the Entity Framework, but I can&#8217;t dispute the fact that it is different from I&#8217;m used to writing stored procedures.</p>
<p>As we moved towards implementing sprocs for our persistence layer to utilize, we ran into a few problems. At first, we thought we could utilize old templates from CodeSmith and .netTiers to generate sprocs, and our EF model would consume them gracefully. Unfortunately, if we used these templates, we would end up with sprocs like this for the Account table:</p>
<div style="font-size: 8pt; background: white; margin-bottom: 10px; color: black; font-family: courier new">
<p style="margin: 0px; text-align: left"><span style="color: blue">CREATE PROC </span>dbo.Account_Insert</p>
<p style="margin: 0px; text-align: left">(</p>
<p style="margin: 0px; text-align: left">&#160;&#160;&#160; @accountId <span style="color: blue">INT OUTPUT</span>,</p>
<p style="margin: 0px; text-align: left">&#160;&#160;&#160; @customerId <span style="color: blue">INT</span></p>
<p style="margin: 0px; text-align: left">)</p>
<p style="margin: 0px; text-align: left"><span style="color: blue">AS</span></p>
<p style="margin: 0px; text-align: left"><span style="color: blue">BEGIN</span></p>
<p style="margin: 0px; text-align: left">&#160;&#160;&#160; <span style="color: blue">INSERT INTO </span>Account (customerId)</p>
<p style="margin: 0px; text-align: left">&#160;&#160;&#160; <span style="color: blue">VALUES </span>(@customerId)</p>
<p style="margin: 0px; text-align: left">&#160;</p>
<p style="margin: 0px; text-align: left">&#160;&#160;&#160; <span style="color: blue">SET </span>@accountId = <span style="color: blue">SCOPE_IDENTITY</span>()</p>
<p style="margin: 0px; text-align: left"><span style="color: blue">END</span></p>
<p style="margin: 0px; text-align: left">GO</p>
<p style="margin: 0px; text-align: left">&#160;</p>
<p style="margin: 0px; text-align: left"><span style="color: blue">CREATE PROC </span>dbo.Account_Update</p>
<p style="margin: 0px; text-align: left">(</p>
<p style="margin: 0px; text-align: left">&#160;&#160;&#160; @accountId <span style="color: blue">INT</span>,</p>
<p style="margin: 0px; text-align: left">&#160;&#160;&#160; @customerId <span style="color: blue">INT</span></p>
<p style="margin: 0px; text-align: left">)</p>
<p style="margin: 0px; text-align: left"><span style="color: blue">AS</span></p>
<p style="margin: 0px; text-align: left"><span style="color: blue">BEGIN</span></p>
<p style="margin: 0px; text-align: left">&#160;&#160;&#160; <span style="color: blue">UPDATE </span>Account</p>
<p style="margin: 0px">&#160;&#160;&#160; <span style="color: blue">SET </span>customerId = @customerId</p>
<p style="margin: 0px; text-align: left">&#160;&#160;&#160; <span style="color: blue">WHERE </span>accountId = @accountId</p>
<p style="margin: 0px; text-align: left"><span style="color: blue">END</span></p>
<p style="margin: 0px; text-align: left">&#160;</p>
<p style="margin: 0px; text-align: left"><span style="color: blue">CREATE PROC </span>dbo.Account_Delete</p>
<p style="margin: 0px; text-align: left">(</p>
<p style="margin: 0px; text-align: left">&#160;&#160;&#160; @accountId <span style="color: blue">INT</span></p>
<p style="margin: 0px; text-align: left">)</p>
<p style="margin: 0px; text-align: left"><span style="color: blue">AS</span></p>
<p style="margin: 0px; text-align: left"><span style="color: blue">BEGIN</span></p>
<p style="margin: 0px; text-align: left">&#160;&#160;&#160; <span style="color: blue">DELETE FROM </span>Account</p>
<p style="margin: 0px; text-align: left">&#160;&#160;&#160; <span style="color: blue">WHERE </span>accountId = @accountId</p>
<p style="margin: 0px; text-align: left"><span style="color: blue">END</span></p>
</p></div>
<p>Notice the slight differences:</p>
<ol>
<li>The INSERT sproc takes in an output parameter for the identity column and then sets the value of that parameter to the ID that was just inserted. The EF version of the sproc does not take in an output parameter; instead it just selects SCOPE_IDENTITY() for the EF to merge back into the Account entity that was inserted. </li>
<li>The DELETE sproc does not take the parameter for the Customer ID, because it is not part of the primary key. </li>
</ol>
<p>This causes some vexation for us because our new business domain houses about forty tables for which we need to write CUD sprocs that fit the Entity Framework&#8217;s rules. We could write them by hand (which would be painful and subject to error), try to modify CodeSmith&#8217;s templates to generate them correctly, or try to generate them using some other way.</p>
<p>From the title of this blog entry, you can probably infer that we didn&#8217;t write them by hand. Furthermore, <a href="http://www.ryanhauert.com">Ryan Hauert</a> and I were toying around with the idea of using <a href="http://dotnet.org.za/hiltong/archive/2008/02/18/t4-template-items.aspx">T4</a>&#160;<a href="http://www.olegsych.com/2007/12/text-template-transformation-toolkit/">Templates</a> to generate the SQL we needed. In all honesty, we didn&#8217;t even consider modifying the CodeSmith templates; I don&#8217;t think this was a bad choice, as T4 templates can benefit people who don&#8217;t want to purchase CodeSmith, but it may&#8217;ve been easier for our particular situation. But I digress&#8230;</p>
<p>The T4 template we created is designed to be a general purpose way to generate CUD procedures for an Entity Framework model. In case you didn&#8217;t read the links I provided on the templates, they are code-generation files which are intrinsically recognized by Visual Studio 2008. (They required the VS SDK in VS2005.) They have a .tt extension, and Visual Studio will nested generated code files underneath them in the Solution Explorer, similar to how designer files are nested under Entity Framework and LINQ to SQL models.</p>
<p><a href="http://blogs.rev-net.com/ddewinter/wp-content/uploads/2008/04/image24.png"><img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="659" alt="image" src="http://blogs.rev-net.com/ddewinter/wp-content/uploads/2008/04/image-thumb6.png" width="814" border="0" /></a></p>
<p>It&#8217;s a very simple process to use the T4 template:</p>
<ol>
<li>Add the file into your project. (The file is linked at the end of the blog entry.) </li>
<li>Simply save the template file and CUD sprocs will be generated for <strong>every</strong> EDMX file in the current directory. </li>
</ol>
<p>If you want to change what directory the template looks in or what files it generates sprocs for, look at the configuration parameters on lines 24 and 25 in the picture above. You can specify the directory explicitly by initializing the directoryName variable to anything other than the empty string or null. Furthermore, if you want to match a specific EDMX file only, you can use a regular expression to filter out unwanted files. I could use it like this:</p>
<div style="font-size: 8pt; background: white; margin-bottom: 10px; color: black; font-family: courier new">
<p style="margin: 0px; text-align: left"><span style="color: #2b91af">Regex</span> edmxFileFilter = <span style="color: blue">new</span> <span style="color: #2b91af">Regex</span>(<span style="color: #a31515">@&quot;Entities\.edmx&quot;</span>);</p>
</p></div>
<p>Then only the Entities.edmx file would be processed.</p>
<p>The template not only generates EF-compliant sprocs, but it also considers only the tables that are in the SSDL of the model file. Unfortunately, the template must query the database (SQL Server 2005 only!) in order to make all the decisions necessary to create the output file. However, this is usually quite fast on generations other than the first one.</p>
<p>As you can see from the picture above, the template requires a few different assemblies to be installed. Most of them shouldn&#8217;t be a problem when generating EF sprocs, because it strongly suggests that you have the <a href="http://www.microsoft.com/downloads/details.aspx?FamilyID=333325FD-AE52-4E35-B531-508D977D32A6&amp;displaylang=en">.NET Framework 3.5</a> installed. Something you may not have are the SQL Server Server Management Objects (SMO), which offer an abstraction layer over the metadata of a SQL Server instance (e.g. databases, tables, columns, keys, indexes, data types), and keep the template cleaner than if we had to make ad hoc queries directly. The SMO installation is available on <a href="http://www.microsoft.com/downloads/details.aspx?familyid=DF0BA5AA-B4BD-4705-AA0A-B477BA72A9CB&amp;displaylang=en">this page</a>, where its installer is called &quot;SQLServer2005_XMO.msi.&quot; There are other installers for 64-bit and Itanium 64-bit.</p>
<p>Once that is installed the template is very simple to run and gives us output like this:</p>
<p><a href="http://blogs.rev-net.com/ddewinter/wp-content/uploads/2008/04/image25.png"><img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="689" alt="image" src="http://blogs.rev-net.com/ddewinter/wp-content/uploads/2008/04/image-thumb7.png" width="792" border="0" /></a></p>
<p>Now we can take this script and run it against SQL Server and then import the sprocs into our Entity Framework model. Finally we can map the stored procedures to the entity types they encapsulate and voil&#224;! We&#8217;re done.</p>
<p>There are a few limitations with the template the moment, but it will account for most cases:</p>
<ol>
<li>No stored procedures are generated for tables that do not have primary keys (in the database, not in the EF model). There is no way we can infer what you meant for the key to be for the update and delete sprocs; while we could generate insert procedures, it wouldn&#8217;t help the end user because the EF requires that an entity type be mapped to all three, or none at all. </li>
<li>The template is available only in C# at the moment. </li>
<li>It has not been tested in all scenarios, so any feedback you have would be great. <img src='http://blogs.rev-net.com/ddewinter/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </li>
<li><strong>It does not account for entity inheritance.</strong> </li>
</ol>
<p><a style="font-size: 200%" href="http://blogs.rev-net.com/ddewinter/wp-content/uploads/2008/04/EntitySprocsb3.tt">T4 Template</a></p>
<p>Special thanks to Bob Pace for giving Ryan and me the idea and providing helpful resources on T4.</p>
<p>Also, if you want to get started writing your own T4 templates, check out <a href="http://dotnet.org.za/hiltong/">Hilton Giesenow</a>&#8217;s excellent video <a href="http://msdn2.microsoft.com/en-gb/vstudio/cc308634.aspx">here</a>.</p>
<p><strong>May 22, 2008 - Updates:</strong></p>
<p>Ryan and I ran into an issue recently where we were accidentally comparing all of the parameters against values in database rows for the delete stored procedures. This was a mistake, because we really only need to check for equality on the primary key columns. The new template has been uploaded.</p>
]]></content:encoded>
			<wfw:commentRss>http://blogs.rev-net.com/ddewinter/2008/04/26/entity-framework-stored-procedure-generation/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Interact 2008 - Day 3</title>
		<link>http://blogs.rev-net.com/ddewinter/2008/04/14/interact-2008-day-3/</link>
		<comments>http://blogs.rev-net.com/ddewinter/2008/04/14/interact-2008-day-3/#comments</comments>
		<pubDate>Mon, 14 Apr 2008 15:48:32 +0000</pubDate>
		<dc:creator>David DeWinter</dc:creator>
		
		<category><![CDATA[Interact 2008]]></category>

		<category><![CDATA[Unified Communications]]></category>

		<guid isPermaLink="false">http://blogs.rev-net.com/ddewinter/index.php/2008/04/14/interact-2008-day-3/</guid>
		<description><![CDATA[The final day at Interact 2008 was a fitting end to the conference; for me it was definitely more mellow because there wasn&#8217;t a keynote, and I didn&#8217;t attend as many breakout sessions. On the other hand, I would be lying if I said I didn&#8217;t learn anything.
To replace the keynote the conference organizers had [...]]]></description>
			<content:encoded><![CDATA[<p>The final day at Interact 2008 was a fitting end to the conference; for me it was definitely more mellow because there wasn&#8217;t a keynote, and I didn&#8217;t attend as many breakout sessions. On the other hand, I would be lying if I said I didn&#8217;t learn anything.</p>
<p>To replace the keynote the conference organizers had planned a &quot;Birds of a Feather&quot; sessions, small gatherings of about five to fifteen people each that focused on certain topics of discussion, such as &quot;Mobilizing Unified Communications,&quot; &quot;Voice Infrastructure,&quot; and &quot;Architecting for a UC World.&quot; This morning Mark and I attended the &quot;Blogging and Other Online Activities&quot; group (you can probably guess why). There were a lot of great ideas floated not just about blogging, but also about other online collaboration tools like forums, wikis, and newsgroups.</p>
<p>The most interesting discussion was around forums, because there was a lot of debate concerning their effectiveness. I use forums for both technical and interpersonal reasons, so it was interesting to see that the issues of contention apply to both types of forums:</p>
<ul>
<li>They are not effective tools for finding answers to questions. </li>
</ul>
<blockquote><p>The forums at MSDN are currently the only forums that I know of that allow users to mark posts as answers. Even so, what if threads have tens or even hundreds of pages? It is not easy to sift through that much content just to find an answer to your question. The forum and thread format, however, does facilitate general discussion threads, but with large threads it&#8217;s still not easy to keep track of all that&#8217;s been said.</p>
</blockquote>
<ul>
<li>Put up an FAQ list? Nobody reads it. </li>
</ul>
<blockquote><p>One thing I&#8217;ve noticed in both sets of forums is that nobody reads the FAQ. Most people just rush in and post because they want their question to receive special attention (maybe that means their question will be answered more quickly?). One brilliant idea I heard that combats this approach and steers more focus toward the FAQ is for moderators to delete threads that ask questions that are already in the FAQ.</p>
</blockquote>
<p>Afterwards, I headed to the Developer Code Camp, where <a href="http://www.robichaux.net/blog/">Paul Robicheaux</a> presented the basics of the UCMA and Albert Kooiman did a short demo of Speech Server 2007&#8217;s capabilities. I was already familiar with Speech Server 2007, but it was very valuable to understand the purpose of the UCMA and how developers could utilize it (which I discussed <a href="http://blogs.rev-net.com/ddewinter/index.php/2008/04/12/interact-2008-day-2/">yesterday</a>). The code camp at this conference was a little rushed to cover all of the APIs we wanted to, but there was still time before the close of the conference to get hands-on experience with the APIs in the hands-on lab area.</p>
<p><span id="more-95"></span></p>
<p>The hands-on labs were divided into two sets depending on your interest: IT professional labs for learning about various deployment and administration scenarios for OCS and its roles, as well as and developer professional labs for developers to experiment with the various APIs (excluding the UCC API). As you can probably guess, I participated only in the developer labs. Unfortunately there was not enough to time to complete all of the labs, but the proctors allowed us to take copies of the lab manuals so we could use them later on. The three APIs I tinkered with were the OC SDK, the UCMA, and the UC AJAX SDK. My impressions? I definitely am not a fan of the AJAX SDK&#8212;it is a bit of a pain to have to type out all the XML to communicate with the CWA server role. The OC SDK and the UCMA are higher-level abstractions which are fairly easy to use. But after two days of learning about these APIs I have enough understanding to be able to build more effective applications, which I believe was the point of the code camp.</p>
<p>The last session I attended was a panel on planning voice architecture and deployment in Microsoft OCS; it turned out to a great opportunity to hear common deployment and administration concerns on a melange of topics like OCS interoperability with products from other vendors, 64-bit support, and Windows Server 2008 support.</p>
<p>Overall, Interact 2008 was a fantastic event, ripe with opportunity for everyone who attended. Through these blog posts I have highlighted the sessions themselves, but I didn&#8217;t talk much about the many connections that both of us have made through the event, who will be invaluable as develop and deploy OCS at Extend Health later this year. The conference was well worth the effort, and I will likely attend next year&#8217;s Interact as well.</p>
<p>The closing event was in a live music venue called <a href="http://www.anthologysd.com/pages/Info.html">Anthology</a>, located in the Little Italy district of San Diego. As always, I&#8217;ll let the pictures do the talking (toward the bottom), but I&#8217;ll say that there are few things better than watching the Interact 2008 attendees performing karaoke. <img src='http://blogs.rev-net.com/ddewinter/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<h4>The Dock Behind the Sheraton</h4>
<p><a href="http://blogs.rev-net.com/ddewinter/wp-content/uploads/2008/04/pict0908.jpg"><img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="484" alt="PICT0908" src="http://blogs.rev-net.com/ddewinter/wp-content/uploads/2008/04/pict0908-thumb.jpg" width="644" border="0" /></a></p>
<p><a href="http://blogs.rev-net.com/ddewinter/wp-content/uploads/2008/04/pict0911.jpg"><img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="484" alt="PICT0911" src="http://blogs.rev-net.com/ddewinter/wp-content/uploads/2008/04/pict0911-thumb.jpg" width="644" border="0" /></a></p>
<p><a href="http://blogs.rev-net.com/ddewinter/wp-content/uploads/2008/04/pict0912.jpg"><img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="484" alt="PICT0912" src="http://blogs.rev-net.com/ddewinter/wp-content/uploads/2008/04/pict0912-thumb.jpg" width="644" border="0" /></a></p>
<p><a href="http://blogs.rev-net.com/ddewinter/wp-content/uploads/2008/04/pict0915.jpg"><img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="484" alt="PICT0915" src="http://blogs.rev-net.com/ddewinter/wp-content/uploads/2008/04/pict0915-thumb.jpg" width="644" border="0" /></a> </p>
<h4>Anthology</h4>
<p><a href="http://blogs.rev-net.com/ddewinter/wp-content/uploads/2008/04/pict0925.jpg"><img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="484" alt="PICT0925" src="http://blogs.rev-net.com/ddewinter/wp-content/uploads/2008/04/pict0925-thumb.jpg" width="644" border="0" /></a></p>
<p><a href="http://blogs.rev-net.com/ddewinter/wp-content/uploads/2008/04/pict0927.jpg"><img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="484" alt="PICT0927" src="http://blogs.rev-net.com/ddewinter/wp-content/uploads/2008/04/pict0927-thumb.jpg" width="644" border="0" /></a></p>
<p>&#160;<a href="http://blogs.rev-net.com/ddewinter/wp-content/uploads/2008/04/pict0934.jpg"><img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="484" alt="PICT0934" src="http://blogs.rev-net.com/ddewinter/wp-content/uploads/2008/04/pict0934-thumb.jpg" width="644" border="0" /></a> </p>
<h4>Other Articles In Series</h4>
<ul style="margin-top: 10px">
<li><a href="http://blogs.rev-net.com/ddewinter/index.php/2008/04/10/interact-2008-day-1/">Day 1</a> </li>
<li><a href="http://blogs.rev-net.com/ddewinter/index.php/2008/04/12/interact-2008-day-2/">Day 2</a> </li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://blogs.rev-net.com/ddewinter/2008/04/14/interact-2008-day-3/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Interact 2008 - Day 2</title>
		<link>http://blogs.rev-net.com/ddewinter/2008/04/12/interact-2008-day-2/</link>
		<comments>http://blogs.rev-net.com/ddewinter/2008/04/12/interact-2008-day-2/#comments</comments>
		<pubDate>Sat, 12 Apr 2008 17:49:51 +0000</pubDate>
		<dc:creator>David DeWinter</dc:creator>
		
		<category><![CDATA[Interact 2008]]></category>

		<category><![CDATA[Unified Communications]]></category>

		<guid isPermaLink="false">http://blogs.rev-net.com/ddewinter/index.php/2008/04/12/interact-2008-day-2/</guid>
		<description><![CDATA[The second day at Interact opened with a keynote by Terry Myerson, the Corporate Vice President of Exchange, who approached the idea of Unified Communications from the email (specifically, Exchange) perspective. The previous day&#8217;s keynote covered a lot of Terry&#8217;s points, but it was interesting to hear how the Exchange team viewed their role in [...]]]></description>
			<content:encoded><![CDATA[<p>The second day at Interact opened with a keynote by Terry Myerson, the Corporate Vice President of Exchange, who approached the idea of Unified Communications from the email (specifically, Exchange) perspective. <a href="http://blogs.rev-net.com/ddewinter/index.php/2008/04/10/interact-2008-day-1/">The previous day&#8217;s keynote</a> covered a lot of Terry&#8217;s points, but it was interesting to hear how the Exchange team viewed their role in Microsoft&#8217;s UC platform. Even though Exchange has <a href="http://www.microsoft.com/exchange/evaluation/um.mspx">Unified Messaging</a>, the team wants to move the focus to UC, not just UM, because the business problem that Microsoft is addressing is achieving people-centric communication. Thus it follows that in any UC solution, it&#8217;s people first and tools second.</p>
<p>Terry then touched on the topic of interoperability, discussing how Exchange ActiveSync would be leveraged by the iPhone Enterprise edition. But perhaps the most interesting part of the presentation was the demonstration of <a href="https://www.exchangelabs.com/">Exchange Labs</a>, a new program geared to test the next version of Exchange. In this inaugural rollout, its target audience is select schools and universities as part of <a href="http://get.live.com/edu">Windows Live @ edu</a>, allowing them to connect students, alumni, faculty, and staff through email. There were two individuals who had overseen the deployment of Exchange Labs to their respective school districts with amazing results.</p>
<p>Terry concluded with a quotation from Thomas Jefferson: &quot;Every generation needs a new revolution.&quot; I personally think we are seeing great advancements in the area of unified communications&#8212;this is our revolution.</p>
<p style="margin-bottom: 10px">Day 2 featured more sessions that appealed to developers than the previous day, so it was right up my alley. Here are the sessions I attended:</p>
<ul>
<li>
<div style="margin-bottom: 10px"><strong>Microsoft Unified Communications for Developers: Building Communications into Your Applications (Albert Kooiman, Paul Robichaux)</strong></div>
</li>
</ul>
<blockquote style="list-style-type: none"><p style="margin-bottom: 10px">The Microsoft Unified Communications platform enables developers to easily build secure and productivity enhancing applications atop a extensible foundation. This session will explore the concept of communications as a first class feature in Windows and Web applications through sample applications that demonstrate how to build voice, video and messaging communications into your applications along with speech and messaging based UIs. It will give an overview of the types of applications that can be built using messaging as well as software-based Voice over IP (VoIP) and will explain which APIs and SDKs are available to build those applications.</p>
</blockquote>
<ul>
<li>
<div style="margin-bottom: 10px"><strong>Developing with Exchange Web Services (Paul Robichaux, Albert Kooiman)</strong></div>
</li>
</ul>
<blockquote><p>Exchange Server 2007 introduces new Web Services APIs to integrate information stored in Exchange into line-of-business applications. Examples include calendaring applications, contact management applications, or applications that access other content from the Exchange store, like creating editing and sending messages, handling tasks or managing contacts, etc. This session gives an overview of the Exchange Web Services APIs, and focuses on specific illustrations of how to use Exchange Web Services in your line-of-business applications. This session includes walk-throughs of code examples of how to integrate data from the store into LOB applications and third party solutions.</p>
</blockquote>
<p><span id="more-94"></span></p>
<p>Both sessions were very interesting as they revealed the life cycle of the current menagerie of UC APIs (UC Client API, UC Managed API, Speech Server 2007 API, UC AJAX SDK, Office Communicator SDK, and Exchange Web Services). The first session gave an overview of the different APIs and how they interoperate with each other and which APIs are appropriate for which scenarios. Here is a very simplified version of a diagram they showed.</p>
<p><a href="http://blogs.rev-net.com/ddewinter/wp-content/uploads/2008/04/image4.png"><img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="266" alt="image" src="http://blogs.rev-net.com/ddewinter/wp-content/uploads/2008/04/image-thumb4.png" width="644" border="0" /></a> </p>
<p>One thing that may not be familiar to you is the Media Stack component of the architecture. Speech Server 2007 obviously needs media to be able to simulate an IVR or call workflow, but UCMA doesn&#8217;t provide those capabilities. Consequently, Speech Server is built on both UCMA and the media stack (which I believe is undocumented).</p>
<p>There are five different platforms on which you can decide to build your application to integrate OCS and its features like presence, audio/video, conferencing, IM, and so on. Here&#8217;s a brief summary of what each platform offers:</p>
<ul>
<li><strong><a href="http://www.microsoft.com/downloads/details.aspx?FamilyID=ed1cce45-cc22-46e1-bd50-660fe6d2c98c&amp;displaylang=en">Office Communicator SDK</a></strong> </li>
</ul>
<blockquote><p>The Office Communicator SDK is appropriate in scenarios where Office Communicator is already deployed to your end users, because the SDK is essentially a COM Automation API. You can sign in, sign out, and get contacts, groups, and presence information without exposing the OC UI, but if you actually want to initiate IM, audio, or video conversations, then using this SDK will launch the appropriate Communicator window. This is great in the case where your users are familiar with Communicator, because your application will then expose the same level of power that Communicator does with minimal development effort.</p>
</blockquote>
<ul>
<li><strong><a href="http://www.microsoft.com/downloads/details.aspx?FamilyID=82c468da-3294-4ca9-bbcc-d455cfd06af2&amp;displaylang=en">UCC API</a></strong> </li>
</ul>
<blockquote><p>The Unified Communications Client API is a much lower level API than the OC SDK and should be used in client scenarios where deploying Communicator is not an option, or you want to expose everything (e.g. IM, audio, video) through your own application&#8217;s interface. It is a COM API that is wrapped with a simple PIA. Fortunately the documentation is fairly thorough, but it has a steep learning curve (especially for .NET-only developers).</p>
</blockquote>
<ul>
<li><strong><a href="http://www.microsoft.com/downloads/details.aspx?FamilyID=d5a36cc7-9b94-4082-ab55-22feffce6b80&amp;displaylang=en">UC AJAX SDK</a></strong> </li>
</ul>
<blockquote><p>The UC AJAX SDK is perfect for integrating your web sites with presence and IM capabilities. As its name implies, it is an AJAX-based API, and it communicates directly with the Communicator Web Access Server role (which in turn . It is definitely tedious to craft requests (as it is all XML-based) but it is the best option at this point for web-based integration.</p>
</blockquote>
<ul>
<li><strong><a href="http://www.microsoft.com/downloads/details.aspx?FamilyID=b30306e4-7dc1-44d2-9a68-9b4a6fc5c2df&amp;displaylang=en">UCMA</a></strong> </li>
</ul>
<blockquote><p>This is what the UC AJAX SDK and part of the Speech Server API rely on to do their dirty work. This API is appropriate for server-side applications to enable scenarios like message broadcasting and IM bots that can interact with end users. Contrary to popular belief, UCMA does support <a href="http://207.46.196.83/MSDN/ShowPost.aspx?PostID=2376845&amp;SiteID=1">publishing</a> and <a href="http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=2931478&amp;SiteID=1">querying for presence</a>, but it is a bit lower level than the rest of the API.</p>
</blockquote>
<ul>
<li><strong><a href="http://www.microsoft.com/downloads/details.aspx?FamilyId=BB183640-4B8F-4828-80C9-E83C3B2E7A2C&amp;displaylang=en">Speech Server 2007</a></strong> </li>
</ul>
<blockquote><p>Speech Server 2007 is in its own niche area, and its goal is to provide <a href="http://en.wikipedia.org/wiki/IVR">IVR</a> solutions for customers. It is based entirely off Windows Workflow Foundation, and there is a superb set of tools that assist you with building and debugging your IVR solutions.</p>
</blockquote>
<p>The pictures today are not from an evening event (because there was none), but rather just from the day as a whole.</p>
<h4>The Beach Near the Hotel</h4>
<p><a href="http://blogs.rev-net.com/ddewinter/wp-content/uploads/2008/04/pict0866.jpg"><img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="484" alt="PICT0866" src="http://blogs.rev-net.com/ddewinter/wp-content/uploads/2008/04/pict0866-thumb.jpg" width="644" border="0" /></a> </p>
<p><a href="http://blogs.rev-net.com/ddewinter/wp-content/uploads/2008/04/pict0869.jpg"><img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="484" alt="PICT0869" src="http://blogs.rev-net.com/ddewinter/wp-content/uploads/2008/04/pict0869-thumb.jpg" width="644" border="0" /></a> </p>
<h4>The Sheraton Hotel (Conference Host)</h4>
<p><a href="http://blogs.rev-net.com/ddewinter/wp-content/uploads/2008/04/pict0872.jpg"><img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="484" alt="PICT0872" src="http://blogs.rev-net.com/ddewinter/wp-content/uploads/2008/04/pict0872-thumb.jpg" width="644" border="0" /></a></p>
<p><a href="http://blogs.rev-net.com/ddewinter/wp-content/uploads/2008/04/pict0878.jpg"><img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="484" alt="PICT0878" src="http://blogs.rev-net.com/ddewinter/wp-content/uploads/2008/04/pict0878-thumb.jpg" width="644" border="0" /></a></p>
<p><a href="http://blogs.rev-net.com/ddewinter/wp-content/uploads/2008/04/pict0879.jpg"><img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="484" alt="PICT0879" src="http://blogs.rev-net.com/ddewinter/wp-content/uploads/2008/04/pict0879-thumb.jpg" width="644" border="0" /></a></p>
<p><a href="http://blogs.rev-net.com/ddewinter/wp-content/uploads/2008/04/pict0881.jpg"><img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="484" alt="PICT0881" src="http://blogs.rev-net.com/ddewinter/wp-content/uploads/2008/04/pict0881-thumb.jpg" width="644" border="0" /></a>&#160;</p>
<h4>Terry Myerson (<em>Right</em>) During Keynote</h4>
<p><a href="http://blogs.rev-net.com/ddewinter/wp-content/uploads/2008/04/pict0884.jpg"><img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="484" alt="PICT0884" src="http://blogs.rev-net.com/ddewinter/wp-content/uploads/2008/04/pict0884-thumb.jpg" width="644" border="0" /></a></p>
<h4>Exchange Labs</h4>
<p><img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="484" alt="PICT0885" src="http://blogs.rev-net.com/ddewinter/wp-content/uploads/2008/04/pict0885-thumb.jpg" width="644" border="0" /></p>
<h4>The &quot;Coffee Chat&quot; Area</h4>
<p><a href="http://blogs.rev-net.com/ddewinter/wp-content/uploads/2008/04/pict0888.jpg"><img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="484" alt="PICT0888" src="http://blogs.rev-net.com/ddewinter/wp-content/uploads/2008/04/pict0888-thumb.jpg" width="644" border="0" /></a></p>
<h4>One of the Breakout Sessions</h4>
<p><a href="http://blogs.rev-net.com/ddewi<br />
nter/wp-content/uploads/2008/04/pict0889.jpg"><img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="484" alt="PICT0889" src="http://blogs.rev-net.com/ddewinter/wp-content/uploads/2008/04/pict0889-thumb.jpg" width="644" border="0" /></a></p>
<h4>Beach at Night</h4>
<p><a href="http://blogs.rev-net.com/ddewinter/wp-content/uploads/2008/04/pict0893.jpg"><img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="484" alt="PICT0893" src="http://blogs.rev-net.com/ddewinter/wp-content/uploads/2008/04/pict0893-thumb.jpg" width="644" border="0" /></a> </p>
<h4>Other Articles In Series</h4>
<ul style="margin-top: 10px">
<li><a href="http://blogs.rev-net.com/ddewinter/index.php/2008/04/10/interact-2008-day-1/">Day 1</a> </li>
<li><a href="http://blogs.rev-net.com/ddewinter/index.php/2008/04/14/interact-2008-day-3/">Day 3</a> </li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://blogs.rev-net.com/ddewinter/2008/04/12/interact-2008-day-2/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Interact 2008 - Day 1</title>
		<link>http://blogs.rev-net.com/ddewinter/2008/04/10/interact-2008-day-1/</link>
		<comments>http://blogs.rev-net.com/ddewinter/2008/04/10/interact-2008-day-1/#comments</comments>
		<pubDate>Thu, 10 Apr 2008 19:24:32 +0000</pubDate>
		<dc:creator>David DeWinter</dc:creator>
		
		<category><![CDATA[Interact 2008]]></category>

		<category><![CDATA[Unified Communications]]></category>

		<category><![CDATA[Gurdeep Pall]]></category>

		<category><![CDATA[Gurdeep Singh Pall]]></category>

		<category><![CDATA[Keynote]]></category>

		<category><![CDATA[OC]]></category>

		<category><![CDATA[OCS]]></category>

		<category><![CDATA[Office Communications Server]]></category>

		<category><![CDATA[Office Communicator]]></category>

		<category><![CDATA[Wave House]]></category>

		<guid isPermaLink="false">http://blogs.rev-net.com/ddewinter/index.php/2008/04/10/interact-2008-day-1/</guid>
		<description><![CDATA[The first day of Interact 2008 was a superb opening to the conference. The day started with a keynote from Gurdeep Singh Pall, who is the &#34;corporate vice president in the Unified Communications Group at Microsoft Corp. He is responsible for vision, product strategy and R&#38;D for Microsoft&#8217;s Unified Communications including voice over Internet protocol [...]]]></description>
			<content:encoded><![CDATA[<p>The first day of Interact 2008 was a superb opening to the conference. The day started with a keynote from <a href="http://www.microsoft.com/presspass/exec/gurdeep/default.mspx">Gurdeep Singh Pall</a>, who is the &quot;corporate vice president in the Unified Communications Group at Microsoft Corp. He is responsible for vision, product strategy and R&amp;D for Microsoft&#8217;s Unified Communications including voice over Internet protocol (VoIP).&quot;<sup>1</sup> From there we had the opportunity to attend &quot;breakout sessions,&quot; seminars led by Microsoft employees or MVPs on abstruse topics for OCS, Office Communicator (OC), and Exchange, or participate in hands-on labs&#8212;exercises also related to OCS, OC, and Exchange, aimed at developers and IT professionals.</p>
<p>Gurdeep&#8217;s keynote stressed three points. The first was the future of software communications. Telephony is an industry that has been dominated by hardware, and the evolution of communication systems has traditionally coincided with the evolution of phones. However, what about other means of communication such as email and IM? It is becoming apparent that software has a place in the communication industry; some would even argue that it plays a major role. By building a platform for software developers to build off in the unified communications area, Microsoft&#8217;s UC solution brings the focus away from the presence of a machine (such as a phone or a laptop) to the presence of a human being.</p>
<p>Gurdeep went on to explain his own version of <a href="http://en.wikipedia.org/wiki/Maslow's_hierarchy_of_needs">Maslow&#8217;s Hierarchy of Needs</a> (called Gurdeep&#8217;s Hierarchy of Needs) which addresses the needs of telecom managers. The four lower levels of the pyramid were needs analogous to Maslow&#8217;s deficiency needs. If you have them, you don&#8217;t think about them; for example, you don&#8217;t go around the office exclaiming that you have email&#8212;similarly, you don&#8217;t think about physiological needs if you have met them. The point was that once the deficiency needs are met, you can self-actualize, which encourages spontaneity and creativity for innovating solutions to business problems.</p>
<p>Finally, Gurdeep discussed the perspective that Microsoft brings to the UC table&#8212;moving IT into the &quot;business zone&quot; using three core concepts:</p>
<ul>
<li><strong>Interoperate (1 + 1 = 2)</strong> </li>
</ul>
<blockquote><p>Previously, the model for UC has been vertically integrated communications, where vendors offer their own stack of technologies to provide a comprehensive telephony solution. Microsoft wants to turn that model on its side by identifying various layers of telephony (hardware, software, devices, etc.) for which multiple vendors can offer a number of different solutions. Microsoft knows it can make advances by providing a software platform which can interoperate with existing vendors&#8217; hardware and devices. This model will allow for industry- and enterprise-specific development and innovation&#8212;in essence, self-actualization.</p>
</blockquote>
<ul>
<li><strong>Integrate (1 + 1 = 3)</strong> </li>
</ul>
<blockquote><p>Whereas interoperability is about making sure your platform is compatible with other platform, integration is about achieving synergy across disparate systems in an architecture. At this point, Gurdeep let Albert Kooiman and members of Clarity Consulting to demonstrate how they developed a pilot project which integrated their CRM application with the presence and communication features within Office Communicator and OCS. (This sort of integration is also what we are very attracted to for our own telephony solution.)</p>
</blockquote>
<ul>
<li><strong>Impact</strong> </li>
</ul>
<blockquote><p>Sometimes it&#8217;s about more than just ROI. (And I&#8217;m sure some of you will disagree.) Gurdeep played a video about children at St. Luke&#8217;s Hospital who are getting a second chance at school and education through Microsoft RoundTable. There is an abridged article about the story <a href="vhttp://mozatwork.spaces.live.com/blog/cns!75EB7F583192DA76!2154.entry">here</a>.</p>
</blockquote>
<p><span id="more-93"></span></p>
<p style="margin-bottom: 10px">The rest of the day was filled with a variety of sessions on OCS, OC, Exchange, and various other topics. Here are the choices I made:</p>
<ul>
<li><strong>Microsoft Office Communicator 2007 Internals and Troubleshooting (Nikhil Bobde, Sam Bedekar)</strong> </li>
</ul>
<blockquote style="list-style-type: none"><p style="margin-bottom: 10px">Microsoft Office Communicator 2007 offers the rich client experience and brings together all exciting features that are part of the our [sic] UC offering. Understand the internals of how OC 2007 is built and the various technologies behind it. This session would cover how the client ties together the information from a variety of servers (OCS, MCUs, Edge servers, mediation server, exchange, AD and a host of other web services) to built [sic] the compelling UC scenarios. The session will cover deployment and setup of Office communicator clients and also the integration of OC into other office clients and SPS. We will walk through how to troubleshoot the most common errors/failures seen by the end user in OC UX and quickly pin point the source of failure. The session would help the attendees to gain some valuable insight into the overall client architecture.</p>
</blockquote>
<ul>
<li><strong>Setup and Configuration Automation for Microsoft Office Communications Server 2007 (Thomas Theiner)</strong> </li>
</ul>
<blockquote><p>The planning, preparation and rollout of a system like Office Communications Server with its many components is a challenging project. Learn about the different parts and tools you can use to make this easier.</p>
</blockquote>
<ul>
<li><strong>Advanced Validation and Troubleshooting for OCS 2007 (Byron Spurlock, Tom Laciano)</strong> </li>
</ul>
<blockquote><p style="margin-bottom: 10px">OCS 2007 troubleshooting is to provide the person(s) involved in deploying OCS an in depth insight to the tools that are available and articulate when, where, and how to use them. Leveraging the right tools and knowing what to look for can expedite troubleshooting immensely. We will take a deep dive into logs, validation tools, and diagnostic reports to view the environment from a core level. The following are just a few of areas that we will take a look at in the session: Federation issues, external users not able to connect to the internal environment, validation of the correct ports needed for remote and internal access for Voice, Video, Web Conferencing, and IM functions.</p>
</blockquote>
<p style="margin-bottom: 10px">My choices may seem a bit strange knowing that I&#8217;m more of a developer than a network administrator, but I have to say that being out of my comfort zone was a great learning experience about the OCS and OC infrastructures. The troubleshooting sessions were the most helpful for me because the speakers discussed the exact steps to take when diagnosing problems both in Office Communicator and in OCS itself. Being able to recognize the problems that come up in this environment as well as knowing how to handle them is invaluable from the developer&#8217;s point-of-view, partly because the business side does not usually see the difference between the front-end components like the IVR and CRM application and the back-end servers which comprise the OCS infrastructure.</p>
<p style="margin-bottom: 10px">The session on the automated configuration of OCS was not as useful to me; it is interesting to know how to do it, but it&#8217;s probably not a scenario I will come up against soon.</p>
<p style="margin-bottom: 10px">For the closing event, Microsoft planned a night of beachside entertainment at the San Diego Wave House. I had a great time, even though I did not try to surf. (Mark did though!) It was the first time I&#8217;d been to the beach in a ong time, too. Here are some shots from the event.</p>
<h4>The Pub World Pavilion</h4>
<p style="margin-bottom: 10px"><a href="http://blogs.rev-net.com/ddewinter/wp-content/uploads/2008/04/pict0842.jpg"><img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="484" alt="PICT0842" src="http://blogs.rev-net.com/ddewinter/wp-content/uploads/2008/04/pict0842-thumb.jpg" width="644" border="0" /></a></p>
<h4>The Wave House</h4>
<p style="margin-bottom: 10px"><a href="http://blogs.rev-net.com/ddewinter/wp-content/uploads/2008/04/pict0844.jpg"><img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="484" alt="PICT0844" src="http://blogs.rev-net.com/ddewinter/wp-content/uploads/2008/04/pict0844-thumb.jpg" width="644" border="0" /></a></p>
<h4>Sunset at the Beach</h4>
<p style="margin-bottom: 10px"><a href="http://blogs.rev-net.com/ddewinter/wp-content/uploads/2008/04/pict0845.jpg"><img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="484" alt="PICT0845" src="http://blogs.rev-net.com/ddewinter/wp-content/uploads/2008/04/pict0845-thumb.jpg" width="644" border="0" /></a></p>
<p style="margin-bottom: 10px"><a href="http://blogs.rev-net.com/ddewinter/wp-content/uploads/2008/04/pict0846.jpg"><img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="484" alt="PICT0846" src="http://blogs.rev-net.com/ddewinter/wp-content/uploads/2008/04/pict0846-thumb.jpg" width="644" border="0" /></a></p>
<h4>The Beach</h4>
<p style="margin-bottom: 10px"><a href="http://blogs.rev-net.com/ddewinter/wp-content/uploads/2008/04/pict0847.jpg"><img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="484" alt="PICT0847" src="http://blogs.rev-net.com/ddewinter/wp-content/uploads/2008/04/pict0847-thumb.jpg" width="644" border="0" /></a></p>
<h4>Mark Surfing</h4>
<p style="margin-bottom: 10px"><a href="http://blogs.rev-net.com/ddewinter/wp-content/uploads/2008/04/pict0851.jpg"><img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="484" alt="PICT0851" src="http://blogs.rev-net.com/ddewinter/wp-content/uploads/2008/04/pict0851-thumb.jpg" width="644" border="0" /></a></p>
<h4>The Pros at &quot;Bruticus Maximus&quot;</h4>
<p style="margin-bottom: 10px"><a href="http://blogs.rev-net.com/ddewinter/wp-content/uploads/2008/04/pict0859.jpg"><img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="484" alt="PICT0859" src="http://blogs.rev-net.com/ddewinter/wp-content/uploads/2008/04/pict0859-thumb.jpg" width="644" border="0" /></a></p>
<p style="margin-bottom: 10px"><a href="http://blogs.rev-net.com/ddewinter/wp-content/uploads/2008/04/pict0864.jpg"><img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="484" alt="PICT0864" src="http://blogs.rev-net.com/ddewinter/wp-content/uploads/2008/04/pict0864-thumb.jpg" width="644" border="0" /></a></p>
<h2 style="margin-bottom: 10px">References</h2>
<ol>
<li><a href="http://www.microsoft.com/presspass/exec/gurdeep/default.mspx">http://www.microsoft.com/presspass/exec/gurdeep/default.mspx</a> </li>
<li><a title="https://www.interact08.com/abstracts.aspx" href="https://www.interact08.com/abstracts.aspx">https://www.interact08.com/abstracts.aspx</a> </li>
</ol>
<h4>Other Articles In Series</h4>
<ul style="margin-top: 10px">
<li><a href="http://blogs.rev-net.com/ddewinter/index.php/2008/04/12/interact-2008-day-2/">Day 2</a> </li>
<li><a href="http://blogs.rev-net.com/ddewinter/index.php/2008/04/14/interact-2008-day-3/">Day 3</a> </li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://blogs.rev-net.com/ddewinter/2008/04/10/interact-2008-day-1/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Interact 2008 - Pre-Game Show</title>
		<link>http://blogs.rev-net.com/ddewinter/2008/04/07/interact-2008-pre-game-show/</link>
		<comments>http://blogs.rev-net.com/ddewinter/2008/04/07/interact-2008-pre-game-show/#comments</comments>
		<pubDate>Tue, 08 Apr 2008 05:10:24 +0000</pubDate>
		<dc:creator>David DeWinter</dc:creator>
		
		<category><![CDATA[Interact 2008]]></category>

		<category><![CDATA[NCAA Finals]]></category>

		<category><![CDATA[Pub World]]></category>

		<guid isPermaLink="false">http://blogs.rev-net.com/ddewinter/index.php/2008/04/07/interact-2008-pre-game-show/</guid>
		<description><![CDATA[Mark and I flew into San Diego tonight, and wow, if you&#8217;ve never been here, prepare for some really beautiful scenery! Unfortunately I didn&#8217;t get much of a chance to take pictures outside, but I did once we got inside the &#34;Pub World&#34; pavilion. The first night here was phenomenal&#8212;I have never been to a [...]]]></description>
			<content:encoded><![CDATA[<p>Mark and I flew into San Diego tonight, and wow, if you&#8217;ve never been here, prepare for some really beautiful scenery! Unfortunately I didn&#8217;t get much of a chance to take pictures outside, but I did once we got inside the &quot;Pub World&quot; pavilion. The first night here was phenomenal&#8212;I have never been to a Microsoft event like this before, but I am really impressed at the execution.</p>
<p>The event tonight was a chance for people to just get together and enjoy the evening. The pavilion had XBOX360 (Halo and some other games I didn&#8217;t recognize), pool, darts (!), air hockey, foosball, ping pong, shuffleboard, and of course, a <em>huge</em> screen showing the NCAA finals. Here are some photos from the event.</p>
<p><a href="http://blogs.rev-net.com/ddewinter/wp-content/uploads/2008/04/pict0817.jpg"><img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="484" alt="PICT0817" src="http://blogs.rev-net.com/ddewinter/wp-content/uploads/2008/04/pict0817-thumb.jpg" width="644" border="0" /></a> </p>
<p><a href="http://blogs.rev-net.com/ddewinter/wp-content/uploads/2008/04/pict0824.jpg"><img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="484" alt="PICT0824" src="http://blogs.rev-net.com/ddewinter/wp-content/uploads/2008/04/pict0824-thumb.jpg" width="644" border="0" /></a> </p>
<p><a href="http://blogs.rev-net.com/ddewinter/wp-content/uploads/2008/04/pict0818.jpg"><img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="484" alt="PICT0818" src="http://blogs.rev-net.com/ddewinter/wp-content/uploads/2008/04/pict0818-thumb.jpg" width="644" border="0" /></a> </p>
<p><a href="http://blogs.rev-net.com/ddewinter/wp-content/uploads/2008/04/pict0819.jpg"><img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="484" alt="PICT0819" src="http://blogs.rev-net.com/ddewinter/wp-content/uploads/2008/04/pict0819-thumb.jpg" width="644" border="0" /></a> </p>
<p><a href="http://blogs.rev-net.com/ddewinter/wp-content/uploads/2008/04/pict0820.jpg"><img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="484" alt="PICT0820" src="http://blogs.rev-net.com/ddewinter/wp-content/uploads/2008/04/pict0820-thumb.jpg" width="644" border="0" /></a> </p>
<p>Here&#8217;s to another great day tomorrow!</p>
]]></content:encoded>
			<wfw:commentRss>http://blogs.rev-net.com/ddewinter/2008/04/07/interact-2008-pre-game-show/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Interact 2008</title>
		<link>http://blogs.rev-net.com/ddewinter/2008/04/06/interact-2008/</link>
		<comments>http://blogs.rev-net.com/ddewinter/2008/04/06/interact-2008/#comments</comments>
		<pubDate>Sun, 06 Apr 2008 23:16:49 +0000</pubDate>
		<dc:creator>David DeWinter</dc:creator>
		
		<category><![CDATA[Interact 2008]]></category>

		<category><![CDATA[Unified Communications]]></category>

		<guid isPermaLink="false">http://blogs.rev-net.com/ddewinter/index.php/2008/04/06/interact-2008/</guid>
		<description><![CDATA[Recently my blog posts have focused on Visual Studio Extensibility, but the challenges that I have come up against at work involve vastly different technologies. One of these is in the Unified Communications space, where my team and I recently investigated the feasibility of using Microsoft&#8217;s Office Communications Server (OCS) in a contact center space. [...]]]></description>
			<content:encoded><![CDATA[<p>Recently my blog posts have focused on Visual Studio Extensibility, but the challenges that I have come up against at work involve vastly different technologies. One of these is in the Unified Communications space, where my team and I recently investigated the feasibility of using Microsoft&#8217;s <a href="http://office.microsoft.com/en-us/communicationsserver/FX101729111033.aspx">Office Communications Server</a> (OCS) in a contact center space. During this pilot project, I helped <a href="http://ryanhauert.com/">Ryan Hauert</a> develop a front-end client (a scaled-back CRM application) that utilized the <a href="http://msdn2.microsoft.com/en-us/library/bb878684.aspx">UCC API</a> to interact with OCS. I also created an <a href="http://en.wikipedia.org/wiki/Automatic_call_distributor">ACD</a> that linked that front-end client with an <a href="http://en.wikipedia.org/wiki/Interactive_voice_response">IVR</a> workflow built by <a href="http://hikmatbek.wordpress.com/">Bek Yakvalkhodjiev</a> against Speech Server 2007. Instead of using a queue to manage call routing, I used a prototype version of the algorithm that Mark Stafford explains <a href="http://itdilemma.wordpress.com/2008/04/02/queues-are-for-the-brits-part-2/">here</a>. The entire project took about three weeks, and that includes the time it took for all of us to learn the APIs and to set up the sandbox environment where OCS was hosted. The results were very fruitful not just for our team, but for the company as a whole to see what Microsoft has to offer versus its competitors in the UC space. </p>
<p>The reason I bring this up is because Mark and I will be heading to Microsoft&#8217;s <a href="https://www.interact08.com/main.aspx">Interact 2008</a> conference tomorrow in San Diego, California. This will be a fantastic opportunity not only to learn more about what Microsoft is bringing to the table, but also to make valuable connections with other people interested in OCS who are potentially going through the same evaluation that we are right now! If you&#8217;re interested in the contact-center-building facet of OCS and are heading to Interact &#8216;08, feel free to drop me a line through my blog or through my <a href="http://blogs.rev-net.com/ddewinter/index.php/contact/">email</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://blogs.rev-net.com/ddewinter/2008/04/06/interact-2008/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Dynamic Menu Commands in Visual Studio Packages - Part 3</title>
		<link>http://blogs.rev-net.com/ddewinter/2008/04/05/dynamic-menu-commands-in-visual-studio-packages-part-3/</link>
		<comments>http://blogs.rev-net.com/ddewinter/2008/04/05/dynamic-menu-commands-in-visual-studio-packages-part-3/#comments</comments>
		<pubDate>Sun, 06 Apr 2008 01:33:20 +0000</pubDate>
		<dc:creator>David DeWinter</dc:creator>
		
		<category><![CDATA[VSX]]></category>

		<category><![CDATA[Visual Studio 2008]]></category>

		<category><![CDATA[Context]]></category>

		<category><![CDATA[Custom]]></category>

		<category><![CDATA[Dynamic]]></category>

		<category><![CDATA[IVsMonitorSelection]]></category>

		<category><![CDATA[IVsSelectionEvents]]></category>

		<category><![CDATA[Menu]]></category>

		<category><![CDATA[SVsShellMonitorSelection]]></category>

		<category><![CDATA[UI Context]]></category>

		<category><![CDATA[Visual Studio]]></category>

		<guid isPermaLink="false">http://blogs.rev-net.com/ddewinter/index.php/2008/04/05/dynamic-menu-commands-in-visual-studio-packages-part-3/</guid>
		<description><![CDATA[This is the final post in a series detailing how to build dynamic menu commands in Visual Studio packages. The previous posts are located here:

Part 1 - Discusses UI Contexts and how to utilize the built-in ones for dynamic menu commands. 
Part 2 - Discusses the use of the BeforyQueryStatus event to provide more flexibility [...]]]></description>
			<content:encoded><![CDATA[<p>This is the final post in a series detailing how to build dynamic menu commands in Visual Studio packages. The previous posts are located here:</p>
<ul>
<li><a href="http://blogs.rev-net.com/ddewinter/index.php/2008/03/14/dynamic-menu-commands-in-visual-studio-packages-part-1/">Part 1</a> - Discusses UI Contexts and how to utilize the built-in ones for dynamic menu commands. </li>
<li><a href="http://blogs.rev-net.com/ddewinter/index.php/2008/03/22/dynamic-menu-commands-in-visual-studio-packages-part-2/">Part 2</a> - Discusses the use of the BeforyQueryStatus event to provide more flexibility than built-in UI contexts. </li>
</ul>
<p>What we&#8217;ve explored to date is a way to provide dynamic menu commands (e.g. dynamic visibility, enabled state) in <em>our own</em> package, and the techniques that I&#8217;ve shown thus far have worked well for this scenario. However, if you want to develop multiple menu commands or even multiple packages that rely on a custom condition (as shown in Part 2), then you&#8217;re stuck implementing the same logic in an event handler for the <a href="http://msdn2.microsoft.com/en-us/library/microsoft.visualstudio.shell.olemenucommand.beforequerystatus(VS.80).aspx">BeforeQueryStatus</a> event for each <a href="http://msdn2.microsoft.com/en-us/library/microsoft.visualstudio.shell.olemenucommand(VS.80).aspx">OleMenuCommand</a>.</p>
<p>Wouldn&#8217;t it be great if we could create our own UI Context, similar to the built-in ones like UIContext_NoSolution or UIContext_FullScreenMode? That way we can create multiple menu commands that rely on that context or even multiple packages which rely on it.</p>
<p>And that&#8217;s exactly what this post will cover. We&#8217;ll use the <a href="http://blogs.rev-net.com/ddewinter/wp-content/uploads/2008/03/dynamicmenudevelopment-part-2.zip">solution starting from where we left off at the end of Part 2</a>.</p>
</p>
<p><span id="more-90"></span></p>
<h3 style="margin-bottom: 10px">Step 1: Creating New Commands</h3>
<p>Because <a href="http://blogs.rev-net.com/ddewinter/index.php/2008/03/22/dynamic-menu-commands-in-visual-studio-packages-part-2/">Part 2</a> covered how to create a new menu command from scratch using the VSCT file and the appropriate procedural code, I&#8217;m not going to cover the process in depth here. I&#8217;ll be creating two new menu commands, which will be part of the command set that we created in Part 2 (guidDynamicMenuDevelopmentCmdSetPart2 in the GuidList class). In the snippets that follow, the bold sections indicate what I added to achieve this:</p>
<h4 style="margin-bottom: 10px">PkgCmdIDList Class (in PkgCmdID.cs)</h4>
<div style="font-size: 8pt; background: white; margin-bottom: 10px; color: black; font-family: courier new">
<p style="margin: 0px; text-align: left"><span style="color: blue">static</span> <span style="color: blue">class</span> <span style="color: #2b91af">PkgCmdIDList</span></p>
<p style="margin: 0px; text-align: left">{</p>
<p style="margin: 0px; text-align: left">&#160;&#160;&#160; <span style="color: blue">public</span> <span style="color: blue">const</span> <span style="color: blue">uint</span> cmdidBuiltInUIContext =&#160;&#160;&#160;&#160;&#160;&#160;&#160; 0&#215;100;</p>
<p style="margin: 0px; text-align: left">&#160;&#160;&#160; <span style="color: blue">public</span> <span style="color: blue">const</span> <span style="color: blue">uint</span> cmdidQueryStatus&#160;&#160;&#160;&#160;&#160; =&#160;&#160;&#160;&#160;&#160;&#160;&#160; 0&#215;101;</p>
<p style="margin: 0px; text-align: left">&#160;&#160;&#160; <strong><span style="color: blue">public</span> <span style="color: blue">const</span> <span style="color: blue">uint</span> cmdidCustomUIContext&#160; =&#160;&#160;&#160;&#160;&#160;&#160;&#160; 0&#215;102;</strong></p>
<p style="margin: 0px; text-align: left">&#160;&#160;&#160; <strong><span style="color: blue">public</span> <span style="color: blue">const</span> <span style="color: blue">uint</span> cmdidCustomUIContext2 =&#160;&#160;&#160;&#160;&#160;&#160;&#160; 0&#215;103;</strong></p>
<p style="margin: 0px; text-align: left">};</p>
</p></div>
<h4 style="margin-bottom: 10px">DynamicMenuDevelopment.vsct File - Symbols Element</h4>
<div style="font-size: 8pt; background: white; margin-bottom: 10px; color: black; font-family: courier new">
<p style="margin: 0px; text-align: left"><span style="color: blue">&lt;</span><span style="color: #a31515">GuidSymbol</span><span style="color: blue"> </span><span style="color: red">name</span><span style="color: blue">=</span>&quot;<span style="color: blue">guidDynamicMenuDevelopmentCmdSetPart2</span>&quot;<span style="color: blue"> </span><span style="color: red">value</span><span style="color: blue">=</span>&quot;<span style="color: blue">{9d9046da-94f8-4fd0-8a00-92bf4f6defa8}</span>&quot;<span style="color: blue">&gt;</span></p>
<p style="margin: 0px; text-align: left"><span style="color: blue">&#160; &lt;</span><span style="color: #a31515">IDSymbol</span><span style="color: blue"> </span><span style="color: red">name</span><span style="color: blue">=</span>&quot;<span style="color: blue">menuidQueryStatusGroup</span>&quot;<span style="color: blue"> </span><span style="color: red">value</span><span style="color: blue">=</span>&quot;<span style="color: blue">0&#215;1020</span>&quot;<span style="color: blue">/&gt;</span></p>
<p style="margin: 0px; text-align: left"><span style="color: blue">&#160; &lt;</span><span style="color: #a31515">IDSymbol</span><span style="color: blue"> </span><span style="color: red">name</span><span style="color: blue">=</span>&quot;<span style="color: blue">cmdidQueryStatus</span>&quot;<span style="color: blue"> </span><span style="color: red">value</span><span style="color: blue">=</span>&quot;<span style="color: blue">0&#215;0101</span>&quot;<span style="color: blue"> /&gt;</span></p>
<p style="margin: 0px; text-align: left"><span style="color: blue">&#160; <strong>&lt;</strong></span><strong><span style="color: #a31515">IDSymbol</span><span style="color: blue"> </span><span style="color: red">name</span><span style="color: blue">=</span>&quot;<span style="color: blue">cmdidCustomUIContext</span>&quot;<span style="color: blue"> </span><span style="color: red">value</span><span style="color: blue">=</span>&quot;<span style="color: blue">0&#215;0102</span>&quot;<span style="color: blue"> /&gt;</span></strong></p>
<p style="margin: 0px; text-align: left"><span style="color: blue">&#160; <strong>&lt;</strong></span><strong><span style="color: #a31515">IDSymbol</span><span style="color: blue"> </span><span style="color: red">name</span><span style="color: blue">=</span>&quot;<span style="color: blue">cmdidCustomUIContext2</span>&quot;<span style="color: blue"> </span><span style="color: red">value</span><span style="color: blue">=</span>&quot;<span style="color: blue">0&#215;0103</span>&quot;<span style="color: blue"> /&gt;</span></strong></p>
<p style="margin: 0px; text-align: left"><span style="color: blue">&lt;/</span><span style="color: #a31515">GuidSymbol</span><span style="color: blue">&gt;</span></p>
</p></div>
<h4 style="margin-bottom: 10px">DynamicMenuDevelopment.vsct File - Buttons Element</h4>
<div style="font-size: 8pt; background: white; margin-bottom: 10px; color: black; font-family: courier new">
<p style="margin: 0px; text-align: left"><strong><span style="color: blue">&lt;</span><span style="color: #a31515">Button</span><span style="color: blue"> </span><span style="color: red">guid</span><span style="color: blue">=</span>&quot;<span style="color: blue">guidDynamicMenuDevelopmentCmdSetPart2</span>&quot;<span style="color: blue"> </span><span style="color: red">id</span><span style="color: blue">=</span>&quot;<span style="color: blue">cmdidCustomUIContext</span>&quot;<span style="color: blue"> </span><span style="color: red">priority</span><span style="color: blue">=</span>&quot;<span style="color: blue">0&#215;1</span>&quot;<span style="color: blue"> </span><span style="color: red">type</span><span style="color: blue">=</span>&quot;<span style="color: blue">Button</span>&quot;<span style="color: blue">&gt;</span></strong></p>
<p style="margin: 0px; text-align: left"><strong><span style="color: blue">&#160; &lt;</span><span style="color: #a31515">Parent</span><span style="color: blue"> </span><span style="color: red">guid</span><span style="color: blue">=</span>&quot;<span style="color: blue">guidDynamicMenuDevelopmentCmdSetPart2</span>&quot;<span style="color: blue"> </span><span style="color: red">id</span><span style="color: blue">=</span>&quot;<span style="color: blue">menuidQueryStatusGroup</span>&quot;<span style="color: blue">/&gt;</span></strong></p>
<p style="margin: 0px; text-align: left"><strong><span style="color: blue">&#160; &lt;</span><span style="color: #a31515">Icon</span><span style="color: blue"> </span><span style="color: red">guid</span><span style="color: blue">=</span>&quot;<span style="color: blue">guidImages</span>&quot;<span style="color: blue"> </span><span style="color: red">id</span><span style="color: blue">=</span>&quot;<span style="color: blue">bmpPicSearch</span>&quot;<span style="color: blue">/&gt;</span></strong></p>
<p style="margin: 0px; text-align: left"><strong><span style="color: blue">&#160; &lt;</span><span style="color: #a31515">CommandFlag</span><span style="color: blue">&gt;</span>DynamicVisibility<span style="color: blue">&lt;/</span><span style="color: #a31515">CommandFlag</span><span style="color: blue">&gt;</span></strong></p>
<p style="margin: 0px; text-align: left"><strong><span style="color: blue">&#160; &lt;</span><span style="color: #a31515">Strings</span><span style="color: blue">&gt;</span></strong></p>
<p style="margin: 0px; text-align: left"><strong><span style="color: blue">&#160;&#160;&#160; &lt;</span><span style="color: #a31515">CommandName</span><span style="color: blue">&gt;</span>cmdidCustomUIContext<span style="color: blue">&lt;/</span><span style="color: #a31515">CommandName</span><span style="color: blue">&gt;</span></strong></p>
<p style="margin: 0px; text-align: left"><strong>       <br /><span style="color: blue">&#160;&#160;&#160; &lt;</span><span style="color: #a31515">ButtonText</span><span style="color: blue">&gt;</span>Custom UI Context 1<span style="color: blue">&lt;/</span><span style="color: #a31515">ButtonText</span><span style="color: blue">&gt;</span></strong></p>
<p style="margin: 0px; text-align: left"><strong><span style="color: blue">&#160; &lt;/</span><span style="color: #a31515">Strings</span><span style="color: blue">&gt;</span></strong></p>
<p style="margin: 0px; text-align: left"><strong><span style="color: blue">&lt;/</span><span style="color: #a31515">Button</span><span style="color: blue">&gt;</span></strong></p>
<p style="margin: 0px; text-align: left"><strong><span style="color: blue">&lt;</span><span style="color: #a31515">Button</span><span style="color: blue"> </span><span style="color: red">guid</span><span style="color: blue">=</span>&quot;<span style="color: blue">guidDynamicMenuDevelopmentCmdSetPart2</span>&quot;<span style="color: blue"> </span><span style="color: red">id</span><span style="color: blue">=</span>&quot;<span style="color: blue">cmdidCustomUIContext2</span>&quot;<span style="color: blue"> </span><span style="color: red">priority</span><span style="color: blue">=</span>&quot;<span style="color: blue">0&#215;2</span>&quot;<span style="color: blue"> </span><span style="color: red">type</span><span style="color: blue">=</span>&quot;<span style="color: blue">Button</span>&quot;<span style="color: blue">&gt;</span></strong></p>
<p style="margin: 0px; text-align: left"><strong><span style="color: blue">&#160; &lt;</span><span style="color: #a31515">Parent</span><span style="color: blue"> </span><span style="color: red">guid</span><span style="color: blue">=</span>&quot;<span style="color: blue">guidDynamicMenuDevelopmentCmdSetPart2</span>&quot;<span style="color: blue"> </span><span style="color: red">id</span><span style="color: blue">=</span>&quot;<span style="color: blue">menuidQueryStatusGroup</span>&quot;<span style="color: blue">/&gt;</span></strong></p>
<p style="margin: 0px; text-align: left"><strong><span style="color: blue">&#160; &lt;</span><span style="color: #a31515">Icon</span><span style="color: blue"> </span><span style="color: red">guid</span><span style="color: blue">=</span>&quot;<span style="color: blue">guidImages</span>&quot;<span style="color: blue"> </span><span style="color: red">id</span><span style="color: blue">=</span>&quot;<span style="color: blue">bmpPicX</span>&quot;<span style="color: blue">/&gt;</span></strong></p>
<p style="margin: 0px; text-align: left"><strong><span style="color: blue">&#160; &lt;</span><span style="color: #a31515">CommandFlag</span><span style="color: blue">&gt;</span>DynamicVisibility<span style="color: blue">&lt;/</span><span style="color: #a31515">CommandFlag</span><span style="color: blue">&gt;</span></strong></p>
<p style="margin: 0px; text-align: left"><strong><span style="color: blue">&#160; &lt;</span><span style="color: #a31515">Strings</span><span style="color: blue">&gt;</span></strong></p>
<p style="margin: 0px; text-align: left"><strong><span style="color: blue">&#160;&#160;&#160; &lt;</span><span style="color: #a31515">CommandName</span><span style="color: blue">&gt;</span>cmdidCustomUIContext2<span style="color: blue">&lt;/</span><span style="color: #a31515">CommandName</span><span style="color: blue">&gt;</span></strong></p>
<p style="margin: 0px; text-align: left"><strong><span style="color: blue">&#160;&#160;&#160; &lt;</span><span style="color: #a31515">ButtonText</span><span style="color: blue">&gt;</span>Custom UI Context 2<span style="color: blue">&lt;/</span><span style="color: #a31515">ButtonText</span><span style="color: blue">&gt;</span></strong></p>
<p style="margin: 0px; text-align: left"><strong><span style="color: blue">&#160; &lt;/</span><span style="color: #a31515">Strings</span><span style="color: blue">&gt;</span></strong></p>
<p style="margin: 0px; text-align: left"><strong><span style="color: blue">&lt;/</span><span style="color: #a31515">Button</span><span style="color: blue">&gt;</span></strong></p>
</p></div>
<p>In summary, I added two IDs to the PkgCmdIDList class which specify the IDs of the two new menu commands I&#8217;m going to add. Furthermore, I registered these IDs in the VSCT file using IDSymbol elements in the guidDynamicMenuDevelopmentCmdSetPart2 GuidSymbol (which I mentioned earlier). Finally, I added two buttons to the Buttons element that map directly to the commands we created. At this point, we could create handlers for these commands, but it&#8217;s really not necessary for us to achieve what we want. If you press F5 and open a project that has at least one project item in it, you&#8217;ll see our two new menu commands when right clicking on a project item:</p>
<p><a href="http://dev.rev-net.com/blog/ddewinter/wp-content/uploads/2008/04/image.png"><img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="189" alt="image" src="http://dev.rev-net.com/blog/ddewinter/wp-content/uploads/2008/04/image-thumb.png" width="260" border="0" /></a></p>
<p>(These menu commands appear in the Solution Explorer because we defined their parents as being in the Solution Explorer context menu&#8212;see Post 2 for details.)</p>
<h3 style="margin-bottom: 10px">Step 2: Implementing the Custom UI Context</h3>
<p>For our custom UI context, let&#8217;s re-implement the functionality that the second command we created (in Post 2) did&#8212;display itself when a .dbml file is selected in the Solution Explorer but hide itself when anything else is selected. To do this we&#8217;ll need a way to tell Visual Studio what the current UI Context is. Fortunately, the <a style="color: #2b91af; font-family: courier new" href="http://msdn2.microsoft.com/en-us/library/microsoft.visualstudio.shell.interop.svsshellmonitorselection(VS.80).aspx">SVsShellMonitorSelection</a> service, through the <a style="color: #2b91af; font-family: courier new" href="http://msdn2.microsoft.com/en-us/library/microsoft.visualstudio.shell.interop.ivsmonitorselection(VS.80).aspx">IVsMonitorSelection</a> interface, exposes the functionality to get and set the current UI context (as well as means to track the current selection). This will definitely fit our needs, but how do we receive notifications when the current selection changes?</p>
<p>This is where the <a style="color: #2b91af; font-family: courier new" href="http://msdn2.microsoft.com/en-us/library/microsoft.visualstudio.shell.interop.ivsselectionevents(VS.80).aspx">IVsSelectionEvents</a> interface really comes in handy. It doesn&#8217;t correspond to a specific Visual Studio service; instead, it&#8217;s used in tandem with the <a style="color: #2b91af; font-family: courier new" href="http://msdn2.microsoft.com/en-us/library/microsoft.visualstudio.shell.interop.ivsmonitorselection(VS.80).aspx">IVsMonitorSelection</a> interface to receive notifications when the UI context has changed, when the current selection has changed, and when an element value has changed. The last notification is outside of the scope of this article, but <a href="http://www.sturmnet.org/blog/archives/2005/09/03/vs-window-tracking/">this blog post</a> may help you understand its purpose.</p>
<p>Is what we must do becoming clearer to you? If not, maybe the following steps will help:</p>
<ol>
<li>Create a UI context GUID that we can use for DBML file selection. </li>
<li>Implement the <a style="color: #2b91af; font-family: courier new" href="http://msdn2.microsoft.com/en-us/library/microsoft.visualstudio.shell.interop.ivsselectionevents(VS.80).aspx">IVsSelectionEvents</a> interface. </li>
<li>Use that implementation with the <a style="color: #2b91af; font-family: courier new" href="http://msdn2.microsoft.com/en-us/library/microsoft.visualstudio.shell.interop.svsshellmonitorselection(VS.80).aspx">SVsShellMonitorSelection</a> service to listen for selection events. </li>
<li>When the selection changes to a DBML file, set the UI context that we created in Step 1 as the active UI context. </li>
<li>Of course, the final step is to hook up our      <br />menu commands to this UI context to test our work. </li>
</ol>
<h4 style="margin-bottom: 10px">Creating the UI Context GUID</h4>
<p>This is probably the easiest step out of the five, as all it does is involve our creating a new GUID to put in the GuidList class that we can reference later. I&#8217;ll do this using guidgen.exe, accessible through the Tools &gt; Create GUID option in Visual Studio. The result looks like this:</p>
<div style="font-size: 8pt; background: white; margin-bottom: 10px; color: black; font-family: courier new">
<p style="margin: 0px; text-align: left"><span style="color: blue">static</span> <span style="color: blue">class</span> <span style="color: #2b91af">GuidList</span></p>
<p style="margin: 0px; text-align: left">{</p>
<p style="margin: 0px; text-align: left">&#160;&#160;&#160; <span style="color: blue">public</span> <span style="color: blue">const</span> <span style="color: blue">string</span> guidDynamicMenuDevelopmentPkgString = <span style="color: #a31515">&quot;d626ae3e-6eaa-414f-9a74-4f41fb902a23&quot;</span>;</p>
<p style="margin: 0px; text-align: left">&#160;&#160;&#160; <span style="color: blue">public</span> <span style="color: blue">const</span> <span style="color: blue">string</span> guidDynamicMenuDevelopmentCmdSetString = <span style="color: #a31515">&quot;a9d25ef1-3235-4a08-8c93-f26619635e91&quot;</span>;</p>
<p style="margin: 0px; text-align: left">&#160;&#160;&#160; <span style="color: blue">public</span> <span style="color: blue">const</span> <span style="color: blue">string</span> guidDynamicMenuDevelopmentCmdSetPart2String = <span style="color: #a31515">&quot;9d9046da-94f8-4fd0-8a00-92bf4f6defa8&quot;</span>;</p>
<p style="margin: 0px; text-align: left">&#160;&#160;&#160; <strong><span style="color: blue">public</span> <span style="color: blue">const</span> <span style="color: blue">string</span> UICONTEXT_DbmlFileSelectedString = <span style="color: #a31515">&quot;203116D4-FC70-48d8-A4E8-2467F58B1F65&quot;</span>;</strong></p>
<p style="margin: 0px; text-align: left">&#160;</p>
<p style="margin: 0px; text-align: left">&#160;&#160;&#160; <span style="color: blue">public</span> <span style="color: blue">static</span> <span style="color: blue">readonly</span> <span style="color: #2b91af">Guid</span> guidDynamicMenuDevelopmentCmdSet = <span style="color: blue">new</span> <span style="color: #2b91af">Guid</span>(guidDynamicMenuDevelopmentCmdSetString);</p>
<p style="margin: 0px; text-align: left">&#160;&#160;&#160; <span style="color: blue">public</span> <span style="color: blue">static</span> <span style="color: blue">readonly</span> <span style="color: #2b91af">Guid</span> guidDynamicMenuDevelopmentCmdSetPart2 = <span style="color: blue">new</span> <span style="color: #2b91af">Guid</span>(guidDynamicMenuDevelopmentCmdSetPart2String);</p>
<p style="margin: 0px; text-align: left">&#160;&#160;&#160; <strong><span style="color: blue">public</span> <span style="color: blue">static</span> <span style="color: blue">readonly</span> <span style="color: #2b91af">Guid</span> UICONTEXT_DbmlFileSelected = <span style="color: blue">new</span> <span style="color: #2b91af">Guid</span>(UICONTEXT_DbmlFileSelectedString);</strong></p>
<p style="margin: 0px; text-align: left">};</p>
</p></div>
<h4 style="margin-bottom: 10px">Implementing the IVsSelectionEvents Interface</h4>
<p>This interface is fairly straightforward to implement. Before getting into the code, remember that we are checking what the new selection is when it changes. If it&#8217;s a DBML file in the Solution Explorer, then we activate our UI context. Here&#8217;s what my implementation looks like:</p>
<div style="font-size: 8pt; background: white; margin-bottom: 10px; color: black; font-family: courier new">
<p style="margin: 0px; text-align: left"><span style="color: gray">///</span><span style="color: green"> </span><span style="color: gray">&lt;summary&gt;</span></p>
<p style="margin: 0px; text-align: left"><span style="color: gray">///</span><span style="color: green"> Our implementation of the </span><span style="color: gray">&lt;see cref=&quot;IVsSelectionEvents&quot;/&gt;</span><span style="color: green"> interface,</span></p>
<p style="margin: 0px; text-align: left"><span style="color: gray">///</span><span style="color: green"> used to set a custom UI context GUID.</span></p>
<p style="margin: 0px; text-align: left"><span style="color: gray">///</span><span style="color: green"> </span><span style="color: gray">&lt;/summary&gt;</span></p>
<p style="margin: 0px; text-align: left"><span style="color: blue">private</span> <span style="color: blue">class</span> <span style="color: #2b91af">SelectionEvents</span> : <span style="color: #2b91af">IVsSelectionEvents</span></p>
<p style="margin: 0px; text-align: left">{</p>
<p style="margin: 0px; text-align: left">&#160;&#160;&#160; <span style="color: blue">private</span> <span style="color: blue">static</span> <span style="color: #2b91af">IVsMonitorSelection</span> SelectionService;</p>
<p style="margin: 0px; text-align: left">&#160;&#160;&#160; <span style="color: blue">private</span> <span style="color: blue">static</span> <span style="color: blue">uint</span> ContextCookie = RegisterContext();</p>
<p style="margin: 0px; text-align: left">&#160;</p>
<p style="margin: 0px; text-align: left">&#160;&#160;&#160; <span style="color: blue">private</span> <span style="color: blue">static</span> <span style="color: blue">uint</span> RegisterContext()</p>
<p style="margin: 0px; text-align: left">&#160;&#160;&#160; {</p>
<p style="margin: 0px; text-align: left">&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: green">// Initialize the selection service</span></p>
<p style="margin: 0px; text-align: left">&#160;&#160;&#160;&#160;&#160;&#160;&#160; SelectionService = (<span style="color: #2b91af">IVsMonitorSelection</span>)<span style="color: #2b91af">Package</span>.GetGlobalService(<span style="color: blue">typeof</span>(<span style="color: #2b91af">SVsShellMonitorSelection</span>));</p>
<p style="margin: 0px; text-align: left">&#160;</p>
<p style="margin: 0px; text-align: left">&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: green">// Get a cookie for our UI Context. This &quot;registers&quot; our</span></p>
<p style="margin: 0px; text-align: left">&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: green">// UI context with the selection service so we can set it again later.</span></p>
<p style="margin: 0px; text-align: left">&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: blue">uint</span> retVal;</p>
<p style="margin: 0px; text-align: left">&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: #2b91af">Guid</span> uiContext = <span style="color: #2b91af">GuidList</span>.UICONTEXT_DbmlFileSelected;</p>
<p style="margin: 0px; text-align: left">&#160;&#160;&#160;&#160;&#160;&#160;&#160; SelectionService.GetCmdUIContextCookie(<span style="color: blue">ref</span> uiContext, <span style="color: blue">out</span> retVal);</p>
<p style="margin: 0px; text-align: left">&#160;</p>
<p style="margin: 0px; text-align: left">&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: blue">return</span> retVal;</p>
<p style="margin: 0px; text-align: left">&#160;&#160;&#160; }</p>
<p style="margin: 0px; text-align: left">&#160;</p>
<p style="margin: 0px; text-align: left">&#160;&#160;&#160; <span style="color: green">// We don&#8217;t care about either of these methods, but it&#8217;s useful to know what they do.</span></p>
<p style="margin: 0px; text-align: left">&#160;&#160;&#160; <span style="color: blue">int</span> <span style="color: #2b91af">IVsSelectionEvents</span>.OnCmdUIContextChanged(<span style="color: blue">uint</span> dwCmdUICookie, <span style="color: blue">int</span> fActive)</p>
<p style="margin: 0px; text-align: left">&#160;&#160;&#160; {</p>
<p style="margin: 0px; text-align: left">&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: blue">return</span> <span style="color: #2b91af">VSConstants</span>.S_OK;</p>
<p style="margin: 0px">&#160;&#160;&#160; }</p>
<p style="margin: 0px; text-align: left">&#160;&#160;&#160; <span style="color: blue">int</span> <span style="color: #2b91af">IVsSelectionEvents</span>.OnElementValueChanged(<span style="color: blue">uint</span> elementid, <span style="color: blue">object</span> varValueOld, <span style="color: blue">object</span> varValueNew)</p>
<p style="margin: 0px; text-align: left">&#160;&#160;&#160; {</p>
<p style="margin: 0px; text-align: left">&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: blue">return</span> <span style="color: #2b91af">VSConstants</span>.S_OK;</p>
<p style="margin: 0px; text-align: left">&#160;&#160;&#160; }</p>
<p style="margin: 0px; text-align: left">&#160;</p>
<p style="margin: 0px; text-align: left">&#160;&#160;&#160; <span style="color: blue">int</span> <span style="color: #2b91af">IVsSelectionEvents</span>.OnSelectionChanged(<span style="color: #2b91af">IVsHierarchy</span> pHierOld, <span style="color: blue">uint</span> itemidOld,</p>
<p style="margin: 0px; text-align: left">&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: #2b91af">IVsMultiItemSelect</span> pMISOld, <span style="color: #2b91af">ISelectionContainer</span> pSCOld,</p>
<p style="margin: 0px; text-align: left">&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: #2b91af">IVsHierarchy</span> pHierNew, <span style="color: blue">uint</span> itemidNew,</p>
<p style="margin: 0px; text-align: left">&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: #2b91af">IVsMultiItemSelect</span> pMISNew, <span style="color: #2b91af">ISelectionContainer</span> pSCNew)</p>
<p style="margin: 0px; text-align: left">&#160;&#160;&#160; {</p>
<p style="margin: 0px; text-align: left">&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: blue">if</span> (pHierNew != <span style="color: blue">null</span>)</p>
<p style="margin: 0px; text-align: left">&#160;&#160;&#160;&#160;&#160;&#160;&#160; {</p>
<p style="margin: 0px; text-align: left">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: blue">object</span> fileName;</p>
<p style="margin: 0px; text-align: left">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; pHierNew.GetProperty(itemidNew, (<span style="color: blue">int</span>)<span style="color: #2b91af">__VSHPROPID</span>.VSHPROPID_Name, <span style="color: blue">out</span> fileName);</p>
<p style="margin: 0px; text-align: left">&#160;</p>
<p style="margin: 0px; text-align: left">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: blue">if</span> (fileName != <span style="color: blue">null</span> &amp;&amp; fileName.ToString().EndsWith(<span style="color: #a31515">&quot;.dbml&quot;</span>))</p>
<p style="margin: 0px; text-align: left">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; {</p>
<p style="margin: 0px; text-align: left">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: green">// If we meet the conditions, set the UI context to be active.</span></p>
<p style="margin: 0px; text-align: left">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; SelectionService.SetCmdUIContext(ContextCookie, 1);</p>
<p style="margin: 0px; text-align: left">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: blue">return</span> <span style="color: #2b91af">VSConstants</span>.S_OK;</p>
<p style="margin: 0px; text-align: left">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; }</p>
<p style="margin: 0px; text-align: left">&#160;&#160;&#160;&#160;&#160;&#160;&#160; }</p>
<p style="margin: 0px; text-align: left">&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: green">// Otherwise, deactivate it.</span></p>
<p style="margin: 0px; text-align: left">&#160;&#160;&#160;&#160;&#160;&#160;&#160; SelectionService.SetCmdUIContext(ContextCookie, 0);</p>
<p style="margin: 0px; text-align: left">&#160;</p>
<p style="margin: 0px; text-align: left">&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: blue">return</span> <span style="color: #2b91af">VSConstants</span>.S_OK;</p>
<p style="margin: 0px; text-align: left">&#160;&#160;&#160; }</p>
<p style="margin: 0px; text-align: left">}</p>
</p></div>
<p>The implementation should make sense based off my previous article. When the selection changes, we inspect the new <span style="color: #2b91af; font-family: courier new">IVsHierarchy</span> to find its selection. If the name of the selection ends with &quot;.dbml&quot;, then we are dealing with a DBML file. We activate the UI context in this case, and deactivate it in all other cases. Before any of that happens, though, we have to register the UI context GUID with the <a style="color: #2b91af; font-family: courier new" href="http://msdn2.microsoft.com/en-us/library/microsoft.visualstudio.shell.interop.svsshellmonitorselection(VS.80).aspx">SVsShellMonitorSelection</a> service, which is what the <span style="font-family: courier new">RegisterContext()</span> method does. The cookie that we receive from the call to <span style="font-family: courier new">IVsMonitorSelection.GetCmdUIContextCookie()</span> is then used to set the UI context later on. There&#8217;s a bit of a trickery involved here to understand what&#8217;s going on, but most of it should be self-evident.</p>
<h4 style="margin-bottom: 10px">Registering the Selection Event Listener</h4>
<p>Now that we have a listener for the selection events, we need to register it with the selection service. To do this, add this to the <span style="font-family: courier new">Initialize()</span> method in our package:</p>
<div style="font-size: 8pt; background: white; margin-bottom: 10px; color: black; font-family: courier new">
<p style="margin: 0px; text-align: left">mySelectionEvents = <span style="color: blue">new</span> <span style="color: #2b91af">SelectionEvents</span>();</p>
<p style="margin: 0px; text-align: left"><span style="color: #2b91af">IVsMonitorSelection</span> selectionService = (<span style="color: #2b91af">IVsMonitorSelection</span>)<span style="color: blue">this</span>.GetService(<span style="color: blue">typeof</span>(<span style="color: #2b91af">SVsShellMonitorSelection</span>));</p>
<p style="margin: 0px; text-align: left">selectionService.AdviseSelectionEvents(mySelectionEvents, <span style="color: blue">out</span> mySelectionEventsCookie);</p>
</p></div>
<p>Here, <span style="font-family: courier new">mySelectionEvents</span> and <span style="font-family: courier new">mySelectionEventsCookie</span> are private fields in the package class. The only unfamiliar territory is the <span style="font-family: courier new">IVsMonitorSelection.AdviseSelectionEvents</span> method. Now, I am by no means a COM expert, but this pattern of <em>advising</em> for events and then <em>unadvising</em> for them later on seems to be a common task for applications that interact with COM. The fact that we can unadvise for the events implies that there is a unique identifier for an &quot;advise.&quot; This unique identifier is the cookie that is passed by reference into the call for advising for selection events. We store this value in a private field so we can unadvise at an appropriate time <em>i.e.</em> in the package&#8217;s <span style="font-family: courier new">Dispose</span> method:</p>
<div style="font-size: 8pt; background: white; margin-bottom: 10px; color: black; font-family: courier new">
<p style="margin: 0px; text-align: left"><span style="color: blue">protected</span> <span style="color: blue">override</span> <span style="color: blue">void</span> Dispose(<span style="color: blue">bool</span> disposing)</p>
<p style="margin: 0px; text-align: left">{</p>
<p style="margin: 0px; text-align: left">&#160;&#160;&#160; <span style="color: #2b91af">IVsMonitorSelection</span> selectionService = (<span style="color: #2b91af">IVsMonitorSelection</span>)<span style="color: blue">this</span>.Ge       <br />tService(<span style="color: blue">typeof</span>(<span style="color: #2b91af">SVsShellMonitorSelection</span>));</p>
<p style="margin: 0px; text-align: left">&#160;&#160;&#160; <span style="color: blue">if</span> (selectionService != <span style="color: blue">null</span>)</p>
<p style="margin: 0px; text-align: left">&#160;&#160;&#160; {</p>
<p style="margin: 0px; text-align: left">&#160;&#160;&#160;&#160;&#160;&#160;&#160; selectionService.UnadviseSelectionEvents(mySelectionEventsCookie);</p>
<p style="margin: 0px; text-align: left">&#160;&#160;&#160; }</p>
<p style="margin: 0px; text-align: left">&#160;</p>
<p style="margin: 0px; text-align: left">&#160;&#160;&#160; <span style="color: blue">base</span>.Dispose(disposing);</p>
<p style="margin: 0px; text-align: left">}</p>
</p></div>
<h4 style="margin-bottom: 10px">Hooking Up the Menu Commands</h4>
<p>It&#8217;s been a long toll, but we&#8217;re almost to the end! The last step is to hook up our two menu commands to the UI context we created. <a href="http://blogs.rev-net.com/ddewinter/index.php/2008/03/14/dynamic-menu-commands-in-visual-studio-packages-part-1/">Part 1</a> shows how to do this with built-in UI contexts, and doing it with a custom one is no different. The first step is to add the GUID for our custom UI context to the Symbols element. Then, we add VisibilityItem elements to the VisibilityConstraints section which hook up the menu commands to that context.</p>
<h5 style="margin-bottom: 10px">The GUID Symbol for the Custom UI Context</h5>
<div style="font-size: 8pt; background: white; margin-bottom: 10px; color: black; font-family: courier new">
<p style="margin: 0px; text-align: left"><span style="color: blue">&lt;</span><span style="color: #a31515">GuidSymbol</span><span style="color: blue"> </span><span style="color: red">name</span><span style="color: blue">=</span>&quot;<span style="color: blue">UICONTEXT_DbmlFileSelected</span>&quot;<span style="color: blue"> </span><span style="color: red">value</span><span style="color: blue">=</span>&quot;<span style="color: blue">{203116D4-FC70-48d8-A4E8-2467F58B1F65}</span>&quot;<span style="color: blue"> /&gt;</span></p>
</p></div>
<h5 style="margin-bottom: 10px">The Visibility Constraints</h5>
<div style="font-size: 8pt; background: white; margin-bottom: 10px; color: black; font-family: courier new">
<p style="margin: 0px; text-align: left"><span style="color: blue">&lt;</span><span style="color: #a31515">VisibilityConstraints</span><span style="color: blue">&gt;</span></p>
<p style="margin: 0px; text-align: left"><span style="color: blue">&#160; &lt;</span><span style="color: #a31515">VisibilityItem</span><span style="color: blue"> </span><span style="color: red">guid</span><span style="color: blue">=</span>&quot;<span style="color: blue">guidDynamicMenuDevelopmentCmdSet</span>&quot;<span style="color: blue"> </span><span style="color: red">id</span><span style="color: blue">=</span>&quot;<span style="color: blue">cmdidBuiltInUIContext</span>&quot;<span style="color: blue"> </span><span style="color: red">context</span><span style="color: blue">=</span>&quot;<span style="color: blue">UICONTEXT_NoSolution</span>&quot;<span style="color: blue"> /&gt;</span></p>
<p style="margin: 0px; text-align: left"><span style="color: blue">&#160; <strong>&lt;</strong></span><strong><span style="color: #a31515">VisibilityItem</span><span style="color: blue"> </span><span style="color: red">guid</span><span style="color: blue">=</span>&quot;<span style="color: blue">guidDynamicMenuDevelopmentCmdSetPart2</span>&quot;<span style="color: blue"> </span><span style="color: red">id</span><span style="color: blue">=</span>&quot;<span style="color: blue">cmdidCustomUIContext</span>&quot;<span style="color: blue"> </span><span style="color: red">context</span><span style="color: blue">=</span>&quot;<span style="color: blue">UICONTEXT_DbmlFileSelected</span>&quot;<span style="color: blue"> /&gt;</span></strong></p>
<p style="margin: 0px; text-align: left"><strong><span style="color: blue">&#160; &lt;</span><span style="color: #a31515">VisibilityItem</span><span style="color: blue"> </span><span style="color: red">guid</span><span style="color: blue">=</span>&quot;<span style="color: blue">guidDynamicMenuDevelopmentCmdSetPart2</span>&quot;<span style="color: blue"> </span><span style="color: red">id</span><span style="color: blue">=</span>&quot;<span style="color: blue">cmdidCustomUIContext2</span>&quot;<span style="color: blue"> </span><span style="color: red">context</span><span style="color: blue">=</span>&quot;<span style="color: blue">UICONTEXT_DbmlFileSelected</span>&quot;<span style="color: blue"> /&gt;</span></strong></p>
<p style="margin: 0px; text-align: left"><span style="color: blue">&lt;/</span><span style="color: #a31515">VisibilityConstraints</span><span style="color: blue">&gt;</span></p>
</p></div>
<h3 style="margin-bottom: 10px">Step 3: The Results!</h3>
<p>Now that we&#8217;ve gone through that rigmarole, press F5 and load a project with a DBML file in it (or create a DBML file in some file). You&#8217;ll see that our two new menu commands (as well the menu command we implemented with the BeforeQueryStatus event handler in Part 2) show up only when right clicking on a DBML file.</p>
<p><a href="http://dev.rev-net.com/blog/ddewinter/wp-content/uploads/2008/04/image1.png"><img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="189" alt="image" src="http://dev.rev-net.com/blog/ddewinter/wp-content/uploads/2008/04/image-thumb1.png" width="260" border="0" /></a></p>
<p>This concludes both this article on building custom UI contexts and this series on dynamic menus in Visual Studio. I hope this and the past articles help in you Visual Studio Package development!</p>
<h3><a href="http://dev.rev-net.com/blog/ddewinter/wp-content/uploads/2008/04/dynamicmenudevelopment-part-3.zip">Associated Solution</a></h3>
<h4>Other Articles in the Series</h4>
<ul>
<li><a href="http://blogs.rev-net.com/ddewinter/index.php/2008/03/14