<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://weblogs.asp.net/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Andru's WebLog : NETFX3</title><link>http://weblogs.asp.net/andresv/archive/tags/NETFX3/default.aspx</link><description>Tags: NETFX3</description><dc:language>en</dc:language><generator>CommunityServer 2007 SP1 (Build: 20510.895)</generator><item><title>Adding a database project reference (DBPro) to a WIX 3.0 project</title><link>http://weblogs.asp.net/andresv/archive/2007/07/17/adding-a-database-project-reference-dbpro-to-a-wix-3-0-project.aspx</link><pubDate>Tue, 17 Jul 2007 18:03:00 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:3192630</guid><dc:creator>andresv</dc:creator><slash:comments>0</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://weblogs.asp.net/andresv/rsscomments.aspx?PostID=3192630</wfw:commentRss><comments>http://weblogs.asp.net/andresv/archive/2007/07/17/adding-a-database-project-reference-dbpro-to-a-wix-3-0-project.aspx#comments</comments><description>&lt;P&gt;I'm building some installers for the project currently working on, and because we use TFS and Team Build I wanted to have the ability of creating MSI packages from the build script run at the build server.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Unfortunately&amp;nbsp;MSBUILD doesn't natively support Visual Studio Setup projects so they won't compile your nice MSI setup packages out of the box. Of course you can just modify the MSBUILD script to add an EXEC task&amp;nbsp;to run&amp;nbsp;VS2005&amp;nbsp;in order to&amp;nbsp;build the setup project, but that requires splitting the original solution (or creating a new one just for compiling the setup project) and this new setup project can't contain references to projects (all references must be changed into binary references).&lt;/P&gt;
&lt;P&gt;For those reasons I explored WIX, the new (and open source) Windows Installer for Xml project from Microsoft, published in SourceForge and found in the Url &lt;A href="http://wix.sourceforge.net/" mce_href="http://wix.sourceforge.net/"&gt;http://wix.sourceforge.net/&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;I started with WIX 3.0 because it fully supports MSBUILD, but the version I downloaded had some serious drawbacks (it lacked support for Votive project variables, for example) and that was a show stopper for me. I also tried the stable WIX 2.0 release, but the lack of MSBUILD support and some other bugs (like no support for dots in project names) was also a show stopper for me. After some time I download the latest (unstable) version of WIX 3.0 (build 3.0.3106.0) and everything worked like a charm. Integration with MSBUILD was beautiful, Votive project variables were supported again and even the dots in the project names works as expected!&lt;/P&gt;
&lt;P&gt;I started to code the installer and I wanted to include some SQL scripts to create some databases on install, and I wanted to automate this as much as possible. I have some VS2005 DBpro database projects and wanted to include the output scripts from those projects into my WIX project. The first version just referenced the SQL files from the projects and compiled just fine in my desktop machine, but failed miserably when compiled on the build server because the output paths are very different (Team Build just copies all output from compiled projects in the DROP folder defined in the build script, and don't use the output folder defined in the source projects).&lt;/P&gt;
&lt;P&gt;So, the solution was to include a project reference in the WIX project to the DbPro projects, and later use those project variables to include the output script files in the setup package. So far, so good....&amp;nbsp; except that Visual Studio won't let you add this kind of project reference!&amp;nbsp; If you try that you will get a nice dialog with an "Object Reference Not Set" error message. Not very helpful....&lt;/P&gt;
&lt;P&gt;The solution is to add manually those references by editing the source WIX project file. You can do that by unloading the project in Visual Studio (right click on the project and select "Unload Project") and then right click again on the unloaded project and select the "Edit" option from the context menu. You can always use the good old notepad to do this, but the Visual Studio way is easier (and cooler...). After editing the source project file you can test everything by reloading the project (right click and click the "Reload Project" menu item).&lt;/P&gt;
&lt;P&gt;Inside the WIX project file, near the end of the file (and inside the "ItemGroup" xml tag) you must add something like:&lt;/P&gt;&lt;FONT color=#0000ff size=2&gt;
&lt;P&gt;&amp;lt;&lt;/FONT&gt;&lt;FONT color=#a31515 size=2&gt;ProjectReference&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt; &lt;/FONT&gt;&lt;FONT color=#ff0000 size=2&gt;Include&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;=&lt;/FONT&gt;&lt;FONT size=2&gt;"&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;..\..\..\Databases\Workflow.Persistence\Persistence.dbproj&lt;/FONT&gt;&lt;FONT size=2&gt;"&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&amp;gt;&lt;BR&gt;&amp;lt;&lt;/FONT&gt;&lt;FONT color=#a31515 size=2&gt;Name&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&amp;gt;&lt;/FONT&gt;&lt;FONT size=2&gt;Workflow.Persistence&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&amp;lt;/&lt;/FONT&gt;&lt;FONT color=#a31515 size=2&gt;Name&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&amp;gt;&lt;BR&gt;&amp;lt;&lt;/FONT&gt;&lt;FONT color=#a31515 size=2&gt;Project&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&amp;gt;&lt;/FONT&gt;&lt;FONT size=2&gt;{7b9401a5-5922-49ed-80ed-1d163f0036dd}&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&amp;lt;/&lt;/FONT&gt;&lt;FONT color=#a31515 size=2&gt;Project&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&amp;gt;&lt;BR&gt;&amp;lt;&lt;/FONT&gt;&lt;FONT color=#a31515 size=2&gt;Private&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&amp;gt;&lt;/FONT&gt;&lt;FONT size=2&gt;True&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&amp;lt;/&lt;/FONT&gt;&lt;FONT color=#a31515 size=2&gt;Private&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&amp;gt;&lt;BR&gt;&amp;lt;/&lt;/FONT&gt;&lt;FONT color=#a31515 size=2&gt;ProjectReference&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&amp;gt;&lt;/P&gt;&lt;/FONT&gt;
&lt;P mce_keep="true"&gt;Inside the&amp;nbsp;&lt;FONT color=#0000ff&gt;&amp;lt;&lt;/FONT&gt;&lt;FONT color=#a31515 size=2&gt;Project&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&amp;gt;&lt;/FONT&gt;&amp;nbsp;xml tag you must type the project GUID you want to reference, and this project GUID can be found inside the project being references itself. In this case, I must open the "Persistence.dbproj" file and look for the "ProjectGuid" xml tag: &lt;/P&gt;
&lt;P mce_keep="true"&gt;&amp;lt;Project DefaultTargets="Build" xmlns="&lt;A href="http://schemas.microsoft.com/developer/msbuild/2003"&gt;http://schemas.microsoft.com/developer/msbuild/2003&lt;/A&gt;"&amp;gt;&lt;BR&gt;&amp;nbsp; &amp;lt;PropertyGroup&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;Configuration Condition=" '$(Configuration)' == '' "&amp;gt;Default&amp;lt;/Configuration&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;Name&amp;gt;"DatabaseProject"&amp;lt;/Name&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;SchemaVersion&amp;gt;2.0&amp;lt;/SchemaVersion&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;STRONG&gt;&amp;lt;ProjectGuid&amp;gt;{4d8e8950-2bf5-4315-a539-ac80f7959187}&amp;lt;/ProjectGuid&amp;gt;&lt;BR&gt;&lt;/STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;ShowWizard&amp;gt;True&amp;lt;/ShowWizard&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;OutputType&amp;gt;Database&amp;lt;/OutputType&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;DBProduct&amp;gt;SQL Server 2005&amp;lt;/DBProduct&amp;gt;&lt;BR&gt;&amp;nbsp;&lt;/P&gt;
&lt;P mce_keep="true"&gt;After that, you should have those nice database project references in your WIX project, like this:&lt;/P&gt;
&lt;P mce_keep="true"&gt;&lt;IMG title="WIX DbPro References" style="WIDTH: 307px; HEIGHT: 393px" height=393 alt="WIX DbPro References" src="http://byfiles.storage.msn.com/y1pkn3FT78Zqpo5SXaDQSSMdIkpRxk2HlYrIyq1FypYtdlmNRCxqF8K14RsXvT1p5IDeQ7rFWStDI4" width=307 mce_src="http://byfiles.storage.msn.com/y1pkn3FT78Zqpo5SXaDQSSMdIkpRxk2HlYrIyq1FypYtdlmNRCxqF8K14RsXvT1p5IDeQ7rFWStDI4"&gt;&lt;/P&gt;
&lt;P mce_keep="true"&gt;Later, in the WIX setup script you can reference the output of those projects like this:&lt;/P&gt;&lt;FONT color=#0000ff size=2&gt;&amp;lt;&lt;/FONT&gt;&lt;FONT color=#a31515 size=2&gt;Binary&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt; &lt;/FONT&gt;&lt;FONT color=#ff0000 size=2&gt;Id&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;=&lt;/FONT&gt;&lt;FONT size=2&gt;"&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;CatalogDbScript&lt;/FONT&gt;&lt;FONT size=2&gt;"&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt; &lt;/FONT&gt;&lt;FONT color=#ff0000 size=2&gt;SourceFile&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;=&lt;/FONT&gt;&lt;FONT size=2&gt;"&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;$(var.Catalog.TargetDir)\WFTCatalog.sql&lt;/FONT&gt;&lt;FONT size=2&gt;"&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt; /&amp;gt; &lt;BR&gt;&amp;lt;&lt;/FONT&gt;&lt;FONT color=#a31515 size=2&gt;Binary&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt; &lt;/FONT&gt;&lt;FONT color=#ff0000 size=2&gt;Id&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;=&lt;/FONT&gt;&lt;FONT size=2&gt;"&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;PersistenceDbScript&lt;/FONT&gt;&lt;FONT size=2&gt;"&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt; &lt;/FONT&gt;&lt;FONT color=#ff0000 size=2&gt;SourceFile&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;=&lt;/FONT&gt;&lt;FONT size=2&gt;"&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;$(var.Persistence.TargetDir)\WFTPersistence.sql&lt;/FONT&gt;&lt;FONT size=2&gt;"&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt; /&amp;gt; &lt;BR&gt;&amp;lt;&lt;/FONT&gt;&lt;FONT color=#a31515 size=2&gt;Binary&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt; &lt;/FONT&gt;&lt;FONT color=#ff0000 size=2&gt;Id&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;=&lt;/FONT&gt;&lt;FONT size=2&gt;"&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;TrackingDbScript&lt;/FONT&gt;&lt;FONT size=2&gt;"&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt; &lt;/FONT&gt;&lt;FONT color=#ff0000 size=2&gt;SourceFile&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;=&lt;/FONT&gt;&lt;FONT size=2&gt;"&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;$(var.Tracking.TargetDir)\WFTTracking.sql&lt;/FONT&gt;&lt;FONT size=2&gt;"&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt; /&amp;gt; &lt;/FONT&gt;&lt;/FONT&gt;
&lt;P mce_keep="true"&gt;As you can see, I'm adding a binary file to the setup package using the "TargetDir" variable for the referenced project. Isn't that nice?&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Tahoma&gt;Usign the cool WIX "SqlExtension" I can very easily include and run those database scripts when installing my project, but that's for another post.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Tahoma&gt;Andrés G Vettori&lt;BR&gt;MCSE/MCSD/MCT&lt;BR&gt;EDS Top Gun - .NET Capability Architect&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Tahoma&gt;Leader of the C# Community of the &lt;/FONT&gt;&lt;A href="http://www.mug.org.ar/" mce_href="http://www.mug.org.ar/"&gt;&lt;FONT face=Tahoma color=#223355 size=2&gt;Microsoft Users Group Argentina&lt;/FONT&gt;&lt;/A&gt;&lt;/P&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=3192630" width="1" height="1"&gt;</description><category domain="http://weblogs.asp.net/andresv/archive/tags/NET+2.0/default.aspx">NET 2.0</category><category domain="http://weblogs.asp.net/andresv/archive/tags/C_2300_/default.aspx">C#</category><category domain="http://weblogs.asp.net/andresv/archive/tags/.NET/default.aspx">.NET</category><category domain="http://weblogs.asp.net/andresv/archive/tags/NETFX3/default.aspx">NETFX3</category><category domain="http://weblogs.asp.net/andresv/archive/tags/WIX/default.aspx">WIX</category></item><item><title>WCF Extensibility - Part 2</title><link>http://weblogs.asp.net/andresv/archive/2006/10/23/WCF-Extensibility-_2D00_-Part-2.aspx</link><pubDate>Mon, 23 Oct 2006 16:05:00 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:713860</guid><dc:creator>andresv</dc:creator><slash:comments>0</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://weblogs.asp.net/andresv/rsscomments.aspx?PostID=713860</wfw:commentRss><comments>http://weblogs.asp.net/andresv/archive/2006/10/23/WCF-Extensibility-_2D00_-Part-2.aspx#comments</comments><description>&lt;h2 style="margin: 12pt 0in 3pt"&gt;&lt;em&gt;Service Description&lt;/em&gt;&lt;/h2&gt;&lt;p style="margin: 6pt 0in 0pt" class="MsoNormal"&gt;&lt;strong&gt;&lt;em&gt;&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;&lt;p style="margin: 6pt 0in 0pt" class="MsoNormal"&gt;&amp;nbsp;&lt;img style="width: 600px; height: 447px" src="http://tkfiles.storage.msn.com/x1pCxs_ZzBE0DzUmNecu_dKxW45PtZuplEOOqcJGrJQ42Q99tABTk6qIqqbz5GfePZ1TMZRGDkCz46rMU1l-H1QwZzyKgUItU9mDogjcoSWNEUxjOPvMAkwlHcdiYDTqmv5d7piCO6JsOI" alt="Service Description at Runtime" title="Service Description at Runtime" width="600" height="447" /&gt;&lt;/p&gt;&lt;p style="margin: 6pt 0in 0pt" class="MsoNormal"&gt;&lt;strong&gt;&lt;em&gt;&lt;font face="Verdana"&gt;Figure 2. ServiceDescription at runtime&lt;/font&gt;&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;&lt;p style="margin: 6pt 0in 0pt" class="MsoNormal"&gt;&amp;nbsp;&lt;/p&gt;&lt;p style="margin: 6pt 0in 0pt" class="MsoNormal"&gt;&lt;font face="Verdana"&gt;The Service Description is the heart of the service and is created when a &lt;strong&gt;ServiceHost&lt;/strong&gt; or client &lt;strong&gt;ChannelFactory&lt;/strong&gt; is created to describe all aspects of the service, endpoints and behaviors. This description is a logical view of what the WCF runtime is going to build when the Open method on the &lt;strong&gt;ServiceHost&lt;/strong&gt; is executed, and also is used to generate the WSDL and policy metadata for the service. This metadata is exposed through the &lt;strong&gt;ServiceDescription&lt;/strong&gt; class and the &lt;strong&gt;Description&lt;/strong&gt; property on the &lt;strong&gt;ServiceHost&lt;/strong&gt; and can be changed, for example, by injecting behaviors. To build the &lt;strong&gt;ServiceDescription&lt;/strong&gt; information the WCF runtime first reflects over the service types and then it loads the service configuration. This information is then used when you execute the &lt;strong&gt;Open&lt;/strong&gt; method of the &lt;strong&gt;ServiceHost&lt;/strong&gt; to build the runtime.&lt;/font&gt;&lt;/p&gt;&lt;p style="margin: 6pt 0in 0pt" class="MsoNormal"&gt;&lt;font face="Verdana"&gt;In the code shown below you can see how the service description information could be accessed and modified:&lt;/font&gt;&lt;/p&gt;&lt;p style="margin: 6pt 0in 0pt" class="MsoNormal"&gt;&amp;nbsp;&lt;/p&gt;&lt;pre style="margin-bottom: 0pt; vertical-align: top"&gt;&lt;span style="font-size: 9pt; color: green"&gt;&lt;font style="background-color: #eeeeee"&gt;&lt;font face="Courier New"&gt;// Construct the ServiceHost&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size: 9pt; color: black"&gt;&lt;font style="background-color: #eeeeee"&gt;&lt;font face="Courier New"&gt;ServiceHost host = new ServiceHost(typeof(EchoService), new Uri(&amp;ldquo;http://localhost/echo&amp;rdquo;) );&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size: 9pt; color: green"&gt;&lt;font style="background-color: #eeeeee"&gt;&lt;font face="Courier New"&gt;// Add endpoints to description&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size: 9pt; color: black"&gt;&lt;font style="background-color: #eeeeee"&gt;&lt;font face="Courier New"&gt;host.AddServiceEndpoint(typeof(IEchoService), new BasicHttpBinding(), &amp;ldquo;&amp;rdquo;);&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size: 9pt; color: green"&gt;&lt;font style="background-color: #eeeeee"&gt;&lt;font face="Courier New"&gt;// You can access the Description property of the host&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size: 9pt; color: black"&gt;&lt;font style="background-color: #eeeeee"&gt;&lt;font face="Courier New"&gt;Console.Writeline(host.Description.ServiceType);&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size: 9pt; color: green"&gt;&lt;font style="background-color: #eeeeee"&gt;&lt;font face="Courier New"&gt;// And you can change things before calling Open&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size: 9pt; color: black"&gt;&lt;font style="background-color: #eeeeee"&gt;&lt;font face="Courier New"&gt;foreach( ServiceEndpoint endpoint in host.Description.Endpoints )&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size: 9pt; color: black"&gt;&lt;font style="background-color: #eeeeee"&gt;&lt;font face="Courier New"&gt;{&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;br /&gt;&lt;font style="background-color: #eeeeee"&gt;&lt;font face="Courier New"&gt;&lt;span style="font-size: 9pt; color: black"&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: 9pt; color: green"&gt;// Add My behavior to all Http endpoints&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;br /&gt;&lt;span style="font-size: 9pt"&gt;&lt;font style="background-color: #eeeeee"&gt;&lt;font face="Courier New"&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;If( endpoint.Uri.Scheme == &amp;ldquo;http&amp;rdquo; )&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size: 9pt"&gt;&lt;font style="background-color: #eeeeee"&gt;&lt;font face="Courier New"&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;endpoint.Behaviors.Add( new MyHttpBehavior() );&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size: 9pt; color: black"&gt;&lt;font style="background-color: #eeeeee"&gt;&lt;font face="Courier New"&gt;}&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size: 9pt; color: green"&gt;&lt;font style="background-color: #eeeeee"&gt;&lt;font face="Courier New"&gt;// Open the Host&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size: 9pt"&gt;&lt;font style="background-color: #eeeeee"&gt;&lt;font face="Courier New"&gt;Host.Open();&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/pre&gt;&lt;p&gt;&lt;strong&gt;Next post: Building a Custom ServiceHost&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;Enjoy!&lt;/p&gt;&lt;p&gt;&lt;font face="Tahoma"&gt;Andr&amp;eacute;s G Vettori&lt;br /&gt;MCSE/MCSD/MCT&lt;br /&gt;EDS Top Gun - .NET Capability Architect&lt;/font&gt;&lt;/p&gt;&lt;p&gt;&lt;font face="Tahoma"&gt;Leader of the C# Community of the &lt;/font&gt;&lt;a href="http://www.mug.org.ar/"&gt;&lt;font face="Tahoma" size="2" color="#223355"&gt;Microsoft Users Group Argentina&lt;/font&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=713860" width="1" height="1"&gt;</description><category domain="http://weblogs.asp.net/andresv/archive/tags/SOA/default.aspx">SOA</category><category domain="http://weblogs.asp.net/andresv/archive/tags/.NET/default.aspx">.NET</category><category domain="http://weblogs.asp.net/andresv/archive/tags/WCF/default.aspx">WCF</category><category domain="http://weblogs.asp.net/andresv/archive/tags/NETFX3/default.aspx">NETFX3</category></item><item><title>WCF Extensibility - Part 1</title><link>http://weblogs.asp.net/andresv/archive/2006/10/20/WCF-Extensibility-_2D00_-Part-1.aspx</link><pubDate>Fri, 20 Oct 2006 18:12:00 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:696248</guid><dc:creator>andresv</dc:creator><slash:comments>0</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://weblogs.asp.net/andresv/rsscomments.aspx?PostID=696248</wfw:commentRss><comments>http://weblogs.asp.net/andresv/archive/2006/10/20/WCF-Extensibility-_2D00_-Part-1.aspx#comments</comments><description>&lt;p&gt;&lt;strong&gt;What we have in WCF&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;WCF has a design that clearly shows a very hard work of many talented people for a long time, and that kind of effort can only be a good thing.&lt;/p&gt;&lt;p&gt;The first thing you note when start working with WCF is the simplicity of the programming model, a thing that COM+ and Enterprise Services was very good at providing some interesting programming models, like declarative programming using attributes, that WCF tried to incorporate.&lt;/p&gt;&lt;p&gt;After that first impression you start digging a little more into the WCF inner workings and you note that it has all the flexibility and extensibility of WSE and Remoting, and then some more, and also supports the communication style of Remoting (although the WCF team doesn&amp;#39;t want to encourage its use) side by side with the full Service Orientation support. &lt;/p&gt;&lt;p&gt;As WCF really is the unification of all previous communication technologies and development paradigms for application and integration scenarios, we can expect to find a more complex architecture underneath, and as I said before it can be a little intimidating when you start looking into all those interfaces and options for extensibility.&lt;/p&gt;&lt;p&gt;&lt;strong&gt;&lt;em&gt;&lt;img style="width: 600px; height: 374px" src="http://tkfiles.storage.msn.com/x1pCxs_ZzBE0DzUmNecu_dKxZKcDWfRPRPtaLgOgvBGQ7400LKWD4BMG1SSIR-7fBxwQ8gz7EYOnzPjkwpIul6daVo5xH4-eswhsvVacH94esvLDJRUygVTW1QfZdjbRpgjRAxMoPl0xyc" alt="WCF Architecture" title="WCF Architecture" width="600" height="374" /&gt;&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;&lt;strong&gt;&lt;em&gt;Figure 1. WCF Architecture&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;As we can see in the simplified architecture diagram shown above, WCF has two main layers where extensibility can be applied and the first decision you have to make is at what layer you need to apply the extensibility you need:&lt;/p&gt;&lt;ol&gt;&lt;li&gt;Customizations at the service model level: this is the higher level of abstraction in WCF and they apply to the higher level constructs like service, contracts and operations. Most common customizations are made at this level and they relate to the fact that you can change the local behavior of any of those service constructs.&lt;/li&gt;&lt;li&gt;Customizations at the messaging level: this is the lower level of the WCF infrastructure where you have protocols and transport channels. In this layer the message is serialized and transmitted using the selected transport, also protocol rules are applied (like reliable messaging) and security (like encryption). Customizations here are needed when you need to modify &amp;quot;what&amp;#39;s on the wire&amp;quot;.&lt;/li&gt;&lt;/ol&gt;&lt;p&gt;Other extensibility points beyond these two include Bindings, Security, Metadata, Serializers and Hosting but they are somewhat less common in typical applications.&lt;/p&gt;&lt;p&gt;The three ways of customizing the service layer include:&lt;/p&gt;&lt;ul&gt;&lt;li&gt;Manipulate the Service Description.&lt;/li&gt;&lt;li&gt;Injecting Behaviors by hand.&lt;/li&gt;&lt;li&gt;Overriding ServiceHost / ChannelFactory&amp;lt;T&amp;gt;.&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;We are going to dive into these three customization methods in the next posts.&lt;/p&gt;&lt;p&gt;&lt;strong&gt;Next post: WCF Service Description Layer&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp;Enjoy!&lt;/p&gt;&lt;p&gt;&lt;font face="Tahoma"&gt;Andr&amp;eacute;s G Vettori&lt;br /&gt;MCSE/MCSD/MCT&lt;br /&gt;EDS Top Gun - .NET Capability Architect&lt;/font&gt;&lt;/p&gt;&lt;p&gt;&lt;font face="Tahoma"&gt;Leader of the C# Community of the &lt;/font&gt;&lt;a href="http://www.mug.org.ar/"&gt;&lt;font face="Tahoma" size="2" color="#223355"&gt;Microsoft Users Group Argentina&lt;/font&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=696248" width="1" height="1"&gt;</description><category domain="http://weblogs.asp.net/andresv/archive/tags/SOA/default.aspx">SOA</category><category domain="http://weblogs.asp.net/andresv/archive/tags/.NET/default.aspx">.NET</category><category domain="http://weblogs.asp.net/andresv/archive/tags/WCF/default.aspx">WCF</category><category domain="http://weblogs.asp.net/andresv/archive/tags/NETFX3/default.aspx">NETFX3</category></item><item><title>Understanding WCF Extensibility</title><link>http://weblogs.asp.net/andresv/archive/2006/10/19/Understanding-WCF-Extensibility.aspx</link><pubDate>Thu, 19 Oct 2006 20:15:00 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:689792</guid><dc:creator>andresv</dc:creator><slash:comments>0</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://weblogs.asp.net/andresv/rsscomments.aspx?PostID=689792</wfw:commentRss><comments>http://weblogs.asp.net/andresv/archive/2006/10/19/Understanding-WCF-Extensibility.aspx#comments</comments><description>&lt;p&gt;I have written a white paper on WCF extensibility and I would like to share it with the community so I have&amp;nbsp;attached&amp;nbsp;a copy&amp;nbsp;to this post in Word 2003 format.&lt;/p&gt;&lt;p&gt;&amp;nbsp;Enjoy!&lt;/p&gt;&lt;p&gt;&lt;font face="Tahoma"&gt;Andr&amp;eacute;s G Vettori&lt;br /&gt;MCSE/MCSD/MCT&lt;br /&gt;EDS Top Gun - .NET Capability Architect&lt;/font&gt;&lt;/p&gt;&lt;p&gt;&lt;font face="Tahoma"&gt;Leader of the C# Community of the &lt;/font&gt;&lt;a href="http://www.mug.org.ar/"&gt;&lt;font face="Tahoma" size="2" color="#223355"&gt;Microsoft Users Group Argentina&lt;/font&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=689792" width="1" height="1"&gt;</description><enclosure url="http://weblogs.asp.net/andresv/attachment/689792.ashx" length="605184" type="application/msword" /><category domain="http://weblogs.asp.net/andresv/archive/tags/SOA/default.aspx">SOA</category><category domain="http://weblogs.asp.net/andresv/archive/tags/.NET/default.aspx">.NET</category><category domain="http://weblogs.asp.net/andresv/archive/tags/WCF/default.aspx">WCF</category><category domain="http://weblogs.asp.net/andresv/archive/tags/NETFX3/default.aspx">NETFX3</category></item><item><title>WS-Compression, WCF and Named Pipes</title><link>http://weblogs.asp.net/andresv/archive/2006/10/12/WS_2D00_Compression_2C00_-WCF-and-Named-Pipes.aspx</link><pubDate>Thu, 12 Oct 2006 21:37:00 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:657776</guid><dc:creator>andresv</dc:creator><slash:comments>1</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://weblogs.asp.net/andresv/rsscomments.aspx?PostID=657776</wfw:commentRss><comments>http://weblogs.asp.net/andresv/archive/2006/10/12/WS_2D00_Compression_2C00_-WCF-and-Named-Pipes.aspx#comments</comments><description>&lt;p&gt;I found the WCF version of the WSE3 compression filters on the Pablo Cribaro&amp;#39;s &lt;a href="http://weblogs.asp.net/cibrax/archive/2006/09/13/WS_2D00_Compression-for-WCF-RC1-_2800_September_2900_.aspx" target="_blank" title="WCF Compression"&gt;blog&lt;/a&gt;&amp;nbsp;where he published an updated WCF RC1 version.&lt;/p&gt;&lt;p&gt;This code was first released by &lt;a href="http://blog.morty.info/PermaLink.aspx?guid=9ee6bf4b-643f-4dcc-8e15-8a07d0fe71dd" target="_blank" title="Morty&amp;acute;s Blog"&gt;Morty&lt;/a&gt; for WSE2. At that time we (&lt;a href="http://weblogs.shockbyte.com.ar/rodolfof/" target="_blank" title="Rodolfo@blog"&gt;Rodolfo Finochieti&lt;/a&gt; and I) make some improvements to that code, and later Rodolfo migrated this code to WSE3. Is very interesting how the community works....&lt;/p&gt;&lt;p&gt;The thing is the WCF version was having problems when used over a Named Pipes transport, so I decided to take some time and discovered some interesting behavior.&lt;/p&gt;&lt;p&gt;The problem occured in the ReadXml method of the CompressionMethod.cs class, and only fails when using TCP or NamedPipes, not on Http. So after&amp;nbsp;doing some debugging I found that in the case of the Http transport, when the Xml Reader was reading an XmlNode with attributes it first reads the StartElement and after that an EndElement. This behavior changes when you are using Named Pipes and after reading the XmlNode that has some attributes, the reader skips the EndNode completely and positions itself on the nect XmlNode.&lt;/p&gt;&lt;p&gt;I first made a quick fix just by asking the XmlReader if the next node was an EndElement before trying to execute a ReadEndElement, but it seems too much as a hack so I tryied another approach. &lt;/p&gt;&lt;p&gt;In the attached file I publish an updated version of the compression library for WCF (for RC1) and modified the CompressionMethod.cs so it doesn&amp;#39;t use attributes anymore, and in that way it works as expected regarding the transport being used.&lt;/p&gt;&lt;p&gt;If you ask me it looks like a bug on the XmlReader, because both messages was exactly the same (checked with trace) and this different behavior is totally unexpected.&lt;/p&gt;&lt;p&gt;I found other bug related to the use of Request/Reply channels with void contract methods. In that case a NULL message was sent back as response and therefore the code fails. On the CompressionInterceptor.cs class I have to check if the passed message was equal to null in the Compress and Decompress methods, and everything works as expected now.&lt;/p&gt;&lt;p&gt;Enjoy!&lt;/p&gt;&lt;p&gt;&lt;font face="Tahoma"&gt;Andr&amp;eacute;s G Vettori&lt;br /&gt;MCSE/MCSD/MCT&lt;br /&gt;EDS Top Gun - .NET Capability Architect&lt;/font&gt;&lt;/p&gt;&lt;p&gt;&lt;font face="Tahoma"&gt;Leader of the C# Community of the &lt;/font&gt;&lt;a href="http://www.mug.org.ar/"&gt;&lt;font face="Tahoma" size="2" color="#223355"&gt;Microsoft Users Group Argentina&lt;/font&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=657776" width="1" height="1"&gt;</description><enclosure url="http://weblogs.asp.net/andresv/attachment/657776.ashx" length="34282" type="application/x-zip-compressed" /><category domain="http://weblogs.asp.net/andresv/archive/tags/NET+2.0/default.aspx">NET 2.0</category><category domain="http://weblogs.asp.net/andresv/archive/tags/C_2300_/default.aspx">C#</category><category domain="http://weblogs.asp.net/andresv/archive/tags/.NET/default.aspx">.NET</category><category domain="http://weblogs.asp.net/andresv/archive/tags/WCF/default.aspx">WCF</category><category domain="http://weblogs.asp.net/andresv/archive/tags/NETFX3/default.aspx">NETFX3</category></item></channel></rss>