<?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"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Tallan&#039;s Technology Blog &#187; Andrew Babiec</title>
	<atom:link href="http://blog.tallan.com/author/andy/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.tallan.com</link>
	<description>Tallan&#039;s Top Technologists Share Their Thoughts on Today&#039;s Technology Challenges</description>
	<lastBuildDate>Fri, 03 Feb 2012 17:23:33 +0000</lastBuildDate>
	
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Resolving an obscure BizTalk 2010 build issue</title>
		<link>http://blog.tallan.com/2011/08/10/resolving-an-obscure-biztalk-2010-build-issue/</link>
		<comments>http://blog.tallan.com/2011/08/10/resolving-an-obscure-biztalk-2010-build-issue/#comments</comments>
		<pubDate>Wed, 10 Aug 2011 16:48:46 +0000</pubDate>
		<dc:creator>Andrew Babiec</dc:creator>
				<category><![CDATA[BizTalk]]></category>
		<category><![CDATA[BizTalk 2010]]></category>
		<category><![CDATA[BTDF]]></category>
		<category><![CDATA[MSBuild]]></category>

		<guid isPermaLink="false">http://blog.tallan.com/?p=1292</guid>
		<description><![CDATA[I recently started work on upgrading a BizTalk 2006 R2 application to BizTalk 2010. I upgraded the solution to VS 2010, deployed the application to my local BizTalk and verified everything was working.
The next step was to start work on automating the build and deployment process. A perfect opportunity to leverage the TFS and MSBuild [...]]]></description>
			<content:encoded><![CDATA[<p>I recently started work on upgrading a BizTalk 2006 R2 application to BizTalk 2010. I upgraded the solution to VS 2010, deployed the application to my local BizTalk and verified everything was working.</p>
<p>The next step was to start work on automating the build and deployment process. A perfect opportunity to leverage the TFS and <a href="http://msdn.microsoft.com/en-us/library/0k6kkbsd.aspx">MSBuild</a> support introduced in <a href="http://msdn.microsoft.com/en-us/library/aa561109(v=BTS.10).aspx">BizTalk 2009</a>. </p>
<p>In order to build a BizTalk 2010 project, I need to install the BizTalk Project Build Components on the TFS build agent. Unfortunately, the client was using Windows Server 2003 R2 for the existing TFS 2008 Build Agent (BizTalk 2010 <a href="http://www.microsoft.com/biztalk/en/us/system-requirements.aspx">requires</a> Windows Server 2008 and above.)</p>
<p><a href="http://blog.tallan.com/wp-content/uploads/2011/08/image.png"><img style="border-bottom: 0px;border-left: 0px;margin: 0px 0px 18px;padding-left: 0px;padding-right: 0px;border-top: 0px;border-right: 0px;padding-top: 0px" border="0" alt="image" src="http://blog.tallan.com/wp-content/uploads/2011/08/image_thumb.png" width="540" height="440" /></a></p>
<p>To work around this, we installed TFS 2008 Build on the BizTalk 2010 Development machine and added it as an Agent to the TFS server. (This is a short-term work-around until the client creates a dedicated VM for this purpose.)</p>
<p>I set-up my build definition and got the build working. Hooray!</p>
<p>I then used <a href="http://technet.microsoft.com/en-us/library/aa559686(v=BTS.70).aspx">BTSTask</a> to write a simple batch file to <a href="http://technet.microsoft.com/en-us/library/aa559837(v=BTS.70).aspx">Create the Application</a>, <a href="http://technet.microsoft.com/en-us/library/aa560955(v=BTS.70).aspx">Add the Resource</a> and <a href="http://technet.microsoft.com/en-us/library/aa560656(v=BTS.70).aspx">Import Bindings</a>.</p>
<p>The next time I ran the same build, it failed with the following error: “<strong>SGEN : error : Cannot generate serialization assembly because it already exists. Use /force to force an overwrite of the existing assembly.</strong>”. </p>
<table border="2" cellspacing="0" cellpadding="2" width="554">
<tbody>
<tr>
<td valign="top" width="550">
<p><font face="Consolas">Target &quot;GenerateSerializationAssemblies&quot; in file &quot;C:\Windows\Microsoft.NET\Framework\v3.5\Microsoft.Common.targets&quot; from project &quot;C:\tfsbuilds\BizTalk2010\Sources\MyBizTalkProject.btproj&quot;:              <br />Building target &quot;GenerateSerializationAssemblies&quot; completely.               <br />Output file &quot;obj\Release\MyBizTalkProject.XmlSerializers.dll&quot; does not exist.               <br />Task &quot;SGen&quot;               <br />Command:               <br />C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\bin\sgen.exe               <br /></font><font face="Consolas">/assembly:MyBizTalkProject.dll /keyfile:MyProject.Key.snk              <br /></font></p>
<p><font face="Consolas">Microsoft (R) Xml Serialization support utility              <br />[Microsoft (R) .NET Framework, Version 2.0.50727.3038]               <br />Copyright (C) Microsoft Corporation. All rights reserved.               <br />SGEN : error : Cannot generate serialization assembly C:\tfsbuilds\BizTalk2010\Sources\MyBizTalkProject.XmlSerializers.dll because it already exists. Use /force to force an overwrite of the existing assembly.               </p>
<p>If you would like more help, please type &quot;sgen /?&quot;.               <br />The command exited with code 1.               <br />Done executing task &quot;SGen&quot; &#8212; FAILED.</font></p>
</td>
</tr>
</tbody>
</table>
<p><font face="Consolas"></font></p>
<p>I was somewhat puzzled why the build failed when I haven’t made any changes to the source code.</p>
<p>The <a href="http://msdn.microsoft.com/en-us/library/bk3w6240(v=VS.100).aspx">MSDN docs for SGEN</a> provides the following info…</p>
<blockquote><p>The XML Serializer Generator creates an XML serialization assembly for types in a specified assembly in order to improve the startup performance of a XmlSerializer when it serializes or deserializes objects of the specified types.</p>
</blockquote>
<p>Since this appears to be a performance optimization step, my initial approach was to disable <strong>Generate serialization assembly</strong> by changing it from <strong>Auto</strong> to <strong>Off</strong> in the BizTalk project properties (build tab.)</p>
<p><a href="http://blog.tallan.com/wp-content/uploads/2011/08/image1.png"><img style="border-bottom: 0px;border-left: 0px;margin: 0px 0px 18px;padding-left: 0px;padding-right: 0px;border-top: 0px;border-right: 0px;padding-top: 0px" border="0" alt="image" src="http://blog.tallan.com/wp-content/uploads/2011/08/image_thumb1.png" width="434" height="67" /></a>    </p>
<p>This setting had no affect on the build and did not resolve the build error. I took a break from resolving the build error and worked on automating the deployment and un-deployment of the Biztalk application.</p>
<p>Around this time, I noticed that the build succeeded <em>only </em>when the BizTalk application was not deployed!</p>
<p>Looking into the issue more, I noticed that the error was due to my BizTalk project assembly being in the GAC. This was mentioned as an issue in the following <a href="http://social.msdn.microsoft.com/Forums/en-US/biztalkgeneral/thread/87325949-ab61-405b-9531-55410b930ad0">MSDN forum post</a> and I verified that the build failed when the assembly was in <strong>C:\Windows\assembly </strong>and succeeded when it was removed.</p>
<p>So if SGEN does not like the assembly being in the GAC, I will just modify the build script to&#160; remove it from the GAC before compilation and add it back in afterwards. Messy, but a necessary step due to the TFS Build Agent residing on the DEV BizTalk Server.</p>
<p><a href="http://blog.tallan.com/wp-content/uploads/2011/08/image2.png"><img style="border-bottom: 0px;border-left: 0px;margin: 0px auto 18px;padding-left: 0px;padding-right: 0px;float: none;border-top: 0px;border-right: 0px;padding-top: 0px" border="0" alt="image" src="http://blog.tallan.com/wp-content/uploads/2011/08/image_thumb2.png" width="255" height="219" /></a></p>
<p>To implement this, I started by adding the Un-GAC step to the build script&#8230; </p>
<p><font face="Consolas"><span style="color:"><font color="#0000ff"><font>&lt;</font></font></span><font><span style="color:"><font color="#a31515">Target</font></span><span style="color:"><font color="#0000ff">&#160;</font></span><span style="color:"><font color="#ff0000">Name</font></span><span style="color:"><font color="#0000ff">=</font></span>&quot;<span style="color:"><font color="#0000ff">BeforeCompile</font></span>&quot;<span style="color:"><font color="#0000ff">&#160;</font></span><span style="color:"><font color="#ff0000">Condition</font></span><span style="color:"><font color="#0000ff">=</font></span>&quot;<span style="color:"><font color="#0000ff">&#8216;$(IsDesktopBuild)&#8217;!=&#8217;true&#8217;</font></span>&quot;<span style="color:"><font color="#0000ff">&gt;</font></span>        <br /><span style="color:"><font color="#0000ff">&#160;&#160;&#160; &lt;</font></span><span style="color:"><font color="#a31515">Exec</font></span><span style="color:"><font color="#0000ff">&#160;</font></span><span style="color:"><font color="#ff0000">Command</font></span><span style="color:"><font color="#0000ff">=</font></span>&quot;<span style="color:"><font color="#0000ff">gacutil /u MyBizTalkProject</font></span>&quot;<span style="color:"><font color="#0000ff">&#160;</font></span><span style="color:"><font color="#ff0000">WorkingDirectory</font></span><span style="color:"><font color="#0000ff">=</font></span>&quot;<span style="color:"><font color="#0000ff">C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Bin</font></span>&quot;<span style="color:"><font color="#0000ff">/&gt;</font></span>        <br /><span style="color:"><font color="#0000ff">&lt;/</font></span><span style="color:"><font color="#a31515">Target</font></span></font><span style="color:"><font color="#0000ff">&gt;</font></span></font></p>
<p>Around the same time, I resumed working on the deployment process – now using the <a href="http://biztalkdeployment.codeplex.com/">BizTalk Deployment Framework (BTDF)</a>. At this point, I deployed a new version of the BizTalk application using the server MSI provided by BTDF.</p>
<p>The next build succeeded and I wanted to verify that my build customization was working properly. When I examined the build results, I noticed that it was not finding the assembly in the GAC:</p>
<p><font face="Consolas">Target &quot;BeforeCompile&quot; in file &quot;&#8230;\BuildType\TFSBuild.proj&quot;:     <br />Using &quot;Exec&quot; task from assembly &quot;Microsoft.Build.Tasks.v3.5, Version=3.5.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a&quot;.      <br />Task &quot;Exec&quot;      <br />&#160; Command:      <br />&#160; gacutil /u MyBizTalkProject      <br />&#160; Microsoft (R) .NET Global Assembly Cache Utility.&#160; Version 3.5.30729.1      <br />&#160; Copyright (c) Microsoft Corporation.&#160; All rights reserved.      <br />&#160; <br /><strong>&#160; No assemblies found matching: MyBizTalkProject</strong>      <br />&#160; Number of assemblies uninstalled = 0       <br />&#160; Number of failures = 0      <br />Done executing task &quot;Exec&quot;.      <br />Done building target &quot;BeforeCompile&quot; in project &quot;TFSBuild.proj&quot;.</font></p>
<p>I was a little confused – I was sure that assembly was deployed to the GAC as the application was up and running in BizTalk. Looking into this a bit more, I realized what was going on…</p>
<p>In .NET, assemblies compiled targeting the 4.0 CLR are now deployed to </p>
<p><font face="Consolas">C:\Windows\Microsoft.NET\assembly</font></p>
<p>whereas assemblies targeting the 2.0 CLR (which includes .NET 2.0, 3.0 and 3.5) are kept in</p>
<p><font face="Consolas">C:\Windows\assembly</font></p>
<p>&#160;</p>
<p>This was a BizTalk 2010 project and I verified that .NET 4 is the target framework – so it should be using the&#160; .NET 4.0 GAC. Why were my assemblies being deployed to the .NET 2.0 GAC earlier (C:\Windows\assembly)? </p>
<p><a href="http://blog.tallan.com/wp-content/uploads/2011/08/image3.png"><img style="border-bottom: 0px;border-left: 0px;margin: 0px 0px 18px;padding-left: 0px;padding-right: 0px;border-top: 0px;border-right: 0px;padding-top: 0px" border="0" alt="image" src="http://blog.tallan.com/wp-content/uploads/2011/08/image_thumb3.png" width="540" height="290" /></a></p>
<p>&#160;</p>
<p>It was at this point that I realized that I forgot to configure the TFS Build Agent to build using the .NET 4 compiler. This was confirmed by checking the build log…</p>
<p><font face="Consolas">Project file contains ToolsVersion=&quot;4.0&quot;, which is not supported by this version of MSBuild. Treating the project as if it had ToolsVersion=&quot;3.5&quot;.     <br />Building with tools version &quot;3.5&quot;.</font></p>
<p>TFS 2008 Build Agent was compiling it using the .NET 3.5 compiler. And when I deployed using BTSTask, I was deploying a .NET 3.5 assembly to the GAC and the 3.5 version of SGEN was generating an error during the next build. </p>
<p>When I switched over to using BTDF, it was compiled on my desktop as a .NET 4.0 MSI and was deployed the assembly on the DEV server to the 4.0 GAC. Since the .NET 3.5 tools and utilities cannot see the 4.0 GAC, SGEN does not generate an error during the build and&#160; <a href="http://msdn.microsoft.com/en-us/library/ex0ss12c(v=VS.90).aspx">gacutil</a> is not able to find the assembly.</p>
<blockquote><p>Side Note: the .NET 4 <a href="http://msdn.microsoft.com/en-us/library/ex0ss12c(v=VS.100).aspx">gacutil</a> searches both the v4 and v2 GACs</p>
</blockquote>
<p>I incorrectly <em>assumed </em>that it was compiled as .NET 4 since the TFS builds were succeeding and the build server already had the v4 framework and SDK installed.</p>
<p>Old BizTalk habits die hard and after working with BizTalk 2004-2009 for so long, I didn’t notice anything wrong when the assemblies were in the old GAC (C:\Windows\assembly).</p>
<p>The following table provides an overview of when my builds were failing.</p>
<table style="line-height: normal;border-collapse: collapse" border="0" cellspacing="0" cellpadding="0" width="294">
<col style="width: 89pt" width="119" />
<col style="width: 71pt" width="94" />
<col style="width: 61pt" width="81" />
<tbody>
<tr style="height: 15.75pt">
<td style="border-bottom: #16365c 0.5pt solid;border-left: #16365c 1.5pt solid;background-color: #c5d9f1;padding-left: 1px;padding-right: 1px;vertical-align: bottom;border-top: #16365c 1.5pt solid;border-right: #16365c 0.5pt solid;padding-top: 1px" class="xl74" height="21" width="118" align="center"><font face="Calibri"><font color="#16365c"><strong>Assembly in which GAC?</strong></font></font></td>
<td style="border-bottom: #16365c 0.5pt solid;border-left: medium none;background-color: #c5d9f1;padding-left: 1px;padding-right: 1px;vertical-align: bottom;border-top: #16365c 1.5pt solid;border-right: #16365c 0.5pt solid;padding-top: 1px" class="xl75" width="94" align="center"><font face="Calibri"><font color="#16365c"><strong>MSBuild and SGEN version</strong></font></font></td>
<td style="border-bottom: #16365c 0.5pt solid;border-left: medium none;background-color: #c5d9f1;padding-left: 1px;padding-right: 1px;vertical-align: bottom;border-top: #16365c 1.5pt solid;border-right: #16365c 1.5pt solid;padding-top: 1px" class="xl70" width="81" align="center"><font face="Calibri"><font color="#16365c"><strong>Build Result</strong></font></font></td>
</tr>
<tr style="height: 15pt">
<td style="border-bottom: #16365c 0.5pt solid;border-left: #16365c 1.5pt solid;padding-left: 1px;padding-right: 1px;vertical-align: bottom;border-top: medium none;border-right: #16365c 0.5pt solid;padding-top: 1px" class="xl66" height="20" align="center"><font face="Calibri"><font color="#16365c">none</font></font></td>
<td style="border-bottom: #16365c 0.5pt solid;border-left: medium none;padding-left: 1px;padding-right: 1px;vertical-align: bottom;border-top: medium none;border-right: #16365c 0.5pt solid;padding-top: 1px" class="xl67" align="center"><font face="Calibri"><font color="#16365c">v3.5</font></font></td>
<td style="border-bottom: #16365c 0.5pt solid;border-left: medium none;padding-left: 1px;padding-right: 1px;vertical-align: bottom;border-top: medium none;border-right: #16365c 1.5pt solid;padding-top: 1px" class="xl71" align="center"><font face="Calibri"><font color="#00b050"><strong>SUCCESS</strong></font></font></td>
</tr>
<tr style="height: 15pt">
<td style="border-bottom: #16365c 0.5pt solid;border-left: #16365c 1.5pt solid;padding-left: 1px;padding-right: 1px;vertical-align: bottom;border-top: medium none;border-right: #16365c 0.5pt solid;padding-top: 1px" class="xl66" height="20" align="center"><font face="Calibri"><font color="#16365c">v2.0</font></font></td>
<td style="border-bottom: #16365c 0.5pt solid;border-left: medium none;padding-left: 1px;padding-right: 1px;vertical-align: bottom;border-top: medium none;border-right: #16365c 0.5pt solid;padding-top: 1px" class="xl67" align="center"><font face="Calibri"><font color="#16365c">v3.5</font></font></td>
<td style="border-bottom: #16365c 0.5pt solid;border-left: medium none;padding-left: 1px;padding-right: 1px;vertical-align: bottom;border-top: medium none;border-right: #16365c 1.5pt solid;padding-top: 1px" class="xl72" align="center"><font face="Calibri"><font color="#ff0000"><strong>FAIL</strong></font></font></td>
</tr>
<tr style="height: 15pt">
<td style="border-bottom: #16365c 0.5pt solid;border-left: #16365c 1.5pt solid;padding-left: 1px;padding-right: 1px;vertical-align: bottom;border-top: medium none;border-right: #16365c 0.5pt solid;padding-top: 1px" class="xl66" height="20" align="center"><font face="Calibri"><font color="#16365c">v4</font></font></td>
<td style="border-bottom: #16365c 0.5pt solid;border-left: medium none;padding-left: 1px;padding-right: 1px;vertical-align: bottom;border-top: medium none;border-right: #16365c 0.5pt solid;padding-top: 1px" class="xl67" align="center"><font face="Calibri"><font color="#16365c">v3.5</font></font></td>
<td style="border-bottom: #16365c 0.5pt solid;border-left: medium none;padding-left: 1px;padding-right: 1px;vertical-align: bottom;border-top: medium none;border-right: #16365c 1.5pt solid;padding-top: 1px" class="xl71" align="center"><font face="Calibri"><font color="#00b050"><strong>SUCCESS</strong></font></font></td>
</tr>
<tr style="height: 15pt">
<td style="border-bottom: #16365c 0.5pt solid;border-left: #16365c 1.5pt solid;padding-left: 1px;padding-right: 1px;vertical-align: bottom;border-top: medium none;border-right: #16365c 0.5pt solid;padding-top: 1px" class="xl66" height="20" align="center"><font face="Calibri"><font color="#16365c">v4</font></font></td>
<td style="border-bottom: #16365c 0.5pt solid;border-left: medium none;padding-left: 1px;padding-right: 1px;vertical-align: bottom;border-top: medium none;border-right: #16365c 0.5pt solid;padding-top: 1px" class="xl67" align="center"><font face="Calibri"><font color="#16365c">v4</font></font></td>
<td style="border-bottom: #16365c 0.5pt solid;border-left: medium none;padding-left: 1px;padding-right: 1px;vertical-align: bottom;border-top: medium none;border-right: #16365c 1.5pt solid;padding-top: 1px" class="xl72" align="center"><font face="Calibri"><font color="#ff0000"><strong>FAIL</strong></font></font></td>
</tr>
<tr style="height: 15.75pt">
<td style="border-bottom: #16365c 1.5pt solid;border-left: #16365c 1.5pt solid;padding-left: 1px;padding-right: 1px;vertical-align: bottom;border-top: medium none;border-right: #16365c 0.5pt solid;padding-top: 1px" class="xl68" height="21" align="center"><font face="Calibri"><font color="#16365c">none</font></font></td>
<td style="border-bottom: #16365c 1.5pt solid;border-left: medium none;padding-left: 1px;padding-right: 1px;vertical-align: bottom;border-top: medium none;border-right: #16365c 0.5pt solid;padding-top: 1px" class="xl69" align="center"><font face="Calibri"><font color="#16365c">v4</font></font></td>
<td style="border-bottom: #16365c 1.5pt solid;border-left: medium none;padding-left: 1px;padding-right: 1px;vertical-align: bottom;border-top: medium none;border-right: #16365c 1.5pt solid;padding-top: 1px" class="xl73" align="center"><font face="Calibri"><font color="#00b050"><strong>SUCCESS</strong></font></font></td>
</tr>
</tbody>
</table>
<p>&#160;</p>
<h3>Resolution</h3>
<p>Modify the TFS Build Agent to default to the .NET 4 MSBuild. This is easily done by&#8230;</p>
<p>1. Stopping the Visual Studio Team Foundation Build service </p>
<p><font face="Consolas">net stop VSTFBUILD</font></p>
<p>2. Edit the following file:</p>
<p><font face="Consolas">C:\Program Files (x86)\Microsoft Visual Studio 9.0\Common7\IDE\PrivateAssemblies\tfsbuildservice.exe.config</font></p>
<p>and modify the following setting…</p>
<p><font face="Consolas"><span style="color:"><font color="#0000ff">&lt;!&#8211;</font></span><font><font><span style="color:"><font color="#008000"> MSBuildPath</font></span><br />
<span style="color:"><font color="#008000">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; Set this value to the full path to the directory of MSBuild.exe to use</font></span><br />
<span style="color:"><font color="#008000">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; a location other than the default. This should only be needed if a new</font></span><br />
<span style="color:"><font color="#008000">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; version of the .NET Framework is installed. </font></span><span style="color:"><font color="#0000ff">&#8211;&gt;</font></span></font><br />
<span style="color:"><font color="#0000ff">&lt;</font></span><span style="color:"><font color="#a31515">add</font></span><span style="color:"><font color="#0000ff">&#160;</font></span><span style="color:"><font color="#ff0000">key</font></span><span style="color:"><font color="#0000ff">=</font></span>&quot;<span style="color:"><font color="#0000ff">MSBuildPath</font></span>&quot;<span style="color:"><font color="#0000ff">&#160;</font></span><span style="color:"><font color="#ff0000">value</font></span><span style="color:"><font color="#0000ff">=</font></span>&quot;<span style="color:"><font color="#0000ff">C:\Windows\Microsoft.NET\Framework\v4.0.30319</font></span>&quot;</font><span style="color:"><font color="#0000ff"> /&gt;</font></span></font></p>
<blockquote>
<p><font size="1">Note: the build will fail with the following error if you try to point to the X64 version of MSBuild:</p>
<p>C:\Windows\Microsoft.NET\<strong>Framework64</strong>\v4.0.30319</font></p>
<p>MSBUILD : error MSB1021: Cannot create an instance of the logger. Could not load file or assembly &#8216;file:///C:\Program Files (x86)\Microsoft Visual Studio 9.0\Common7\IDE\PrivateAssemblies\Microsoft.TeamFoundation.Build.Server.Logger.dll&#8217; or one of its dependencies. An attempt was made to load a program with an incorrect format. </p>
</blockquote>
<p>3. Start the build service</p>
<p><font face="Consolas">net start VSTFBUILD</font></p>
<p>&#160;</p>
<p>Now that TFS Build is using the proper MSBuild version, the BizTalk assembly is being compiled as a v4 CLR image.</p>
<p>The last step is to modify the build script to reference the correct version of gacutil in order to GAC and un-GAC the assemblies. If you aren’t paying careful attention, you may not realize which .NET version tools you are using. Compounding this problem is the subtle difference in the file paths. For example, these are the directories for the .NET 3.5 tools (depending on whether you want to run the 32-bit or 64-bit versions):</p>
<p><font face="Consolas">C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Bin</p>
<p>C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Bin\x64</font></p>
<p>These are the directories for the .NET 4.0 tools:</p>
<p><font face="Consolas">C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Bin\NETFX 4.0 Tools</p>
<p>C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Bin\NETFX 4.0 Tools\x64</font></p>
<p>Going back to my build script, changing the Working Directory of the Exec task completes the last bit of changes.</p>
<p><font face="Consolas"><span style="color:"><font color="#0000ff"><font>&lt;</font></font></span><font><span style="color:"><font color="#a31515">Target</font></span><span style="color:"><font color="#0000ff"> </font></span><span style="color:"><font color="#ff0000">Name</font></span><span style="color:"><font color="#0000ff">=</font></span>&quot;<span style="color:"><font color="#0000ff">BeforeCompile</font></span>&quot;<span style="color:"><font color="#0000ff"> </font></span><span style="color:"><font color="#ff0000">Condition</font></span><span style="color:"><font color="#0000ff">=</font></span>&quot;<span style="color:"><font color="#0000ff">&#8216;$(IsDesktopBuild)&#8217;!=&#8217;true&#8217;</font></span>&quot;<span style="color:"><font color="#0000ff">&gt;</font></span><br />
<span style="color:"><font color="#0000ff">&#160;&#160; &lt;</font></span><span style="color:"><font color="#a31515">Exec</font></span><span style="color:"><font color="#0000ff"> </font></span><span style="color:"><font color="#ff0000">Command</font></span><span style="color:"><font color="#0000ff">=</font></span>&quot;<span style="color:"><font color="#0000ff">gacutil /u MyBizTalkProject</font></span>&quot;<span style="color:"><font color="#0000ff"> </font></span><span style="color:"><font color="#ff0000">WorkingDirectory</font></span><span style="color:"><font color="#0000ff">=</font></span>&quot;<span style="color:"><font color="#0000ff">C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Bin\<strong>NETFX 4.0 Tools</strong></font></span>&quot;<span style="color:"><font color="#0000ff">/&gt;<br />
</font></span><span style="color:"><font color="#0000ff">&lt;/</font></span><span style="color:"><font color="#a31515">Target</font></span></font><span style="color:"><font color="#0000ff">&gt;</font></span></font></p>
<h3>Lessons Learned</h3>
<p>
<p>1. Just because a build succeeded on the first try, doesn’t mean you shouldn’t examine the text log. If I did that early on, I would have seen countless references to .NET 3.5. It is very easy to see the green success icon in the Build Results page and quickly move to the next task.<a href="http://blog.tallan.com/wp-content/uploads/2011/08/image4.png"><img style="border-right-width: 0px;margin: 0px 0px 18px;padding-left: 0px;padding-right: 0px;float: right;border-top-width: 0px;border-bottom-width: 0px;border-left-width: 0px;padding-top: 0px" border="0" alt="image" align="right" src="http://blog.tallan.com/wp-content/uploads/2011/08/image_thumb4.png" width="48" height="40" /></a></p>
</p>
</p>
<p>2. Don’t use TFS Build on the same server as BizTalk. Having to UnGAC an assembly during a build is a pain and it disrupts BizTalk processing.</p>
<p>3. Try to unlearn old habits – such as jumping to C:\Windows\assembly to look for an assembly in the GAC.</p></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.tallan.com/2011/08/10/resolving-an-obscure-biztalk-2010-build-issue/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Identity Developer Training Kit and an issue with missing dependencies</title>
		<link>http://blog.tallan.com/2010/09/14/identity-developer-training-kit-and-an-issue-with-missing-dependencies/</link>
		<comments>http://blog.tallan.com/2010/09/14/identity-developer-training-kit-and-an-issue-with-missing-dependencies/#comments</comments>
		<pubDate>Tue, 14 Sep 2010 17:58:30 +0000</pubDate>
		<dc:creator>Andrew Babiec</dc:creator>
				<category><![CDATA[.NET Framework]]></category>
		<category><![CDATA[Identity]]></category>
		<category><![CDATA[WIF]]></category>

		<guid isPermaLink="false">http://blog.tallan.com/?p=672</guid>
		<description><![CDATA[If you are learning about Windows Identity Foundation, you should install these components in the following order:

WIF runtime
WIF SDK
Identity Developer Training Kit

Note that there is a version of the SDK and Training Kit for Visual Studio 2008 SP1 (.NET 3.5) and one for Visual Studio 2010 (.NET 4.0.)
Note: Side by side installation of the WIF [...]]]></description>
			<content:encoded><![CDATA[<p>If you are learning about <a href="http://msdn.microsoft.com/en-us/security/aa570351.aspx">Windows Identity Foundation</a>, you should install these components in the following order:</p>
<ul>
<li><a href="http://msdn.microsoft.com/en-us/evalcenter/dd440951.aspx">WIF runtime</a></li>
<li><a href="http://www.microsoft.com/downloads/en/details.aspx?FamilyID=C148B2DF-C7AF-46BB-9162-2C9422208504">WIF SDK</a></li>
<li><a href="http://www.microsoft.com/downloads/en/details.aspx?FamilyID=c3e315fa-94e2-4028-99cb-904369f177c0">Identity Developer Training Kit</a></li>
</ul>
<p>Note that there is a version of the SDK and Training Kit for Visual Studio 2008 SP1 (.NET 3.5) and one for Visual Studio 2010 (.NET 4.0.)</p>
<p><em><strong>Note:</strong> Side by side installation of the WIF 3.5 and 4.0 SDKs is not recommended. Visual Studio templates will be properly installed for side by side installations of Visual Studio 2008 and 2010, the included samples will not work in such a configuration without modification.</em></p>
<p>This post is about a<strong> </strong>problem I found with the 2008/3.5 version of the Identity Training Kit and how you can fix an error in the lab set-up scripts.</p>
<p>Each training lab has a <strong>SetupLab.cmd</strong> file that needs to be run in order to install and configure the code snippets and certificates for that lab. For the first hands-on lab, Web Sites and Identity, this can be found at <span style="font-family: Consolas;font-size: x-small">\IdentityTrainingKit\Labs\WebSitesAndIdentity\Source\Setup</span></p>
<p><a href="http://blog.tallan.com/wp-content/uploads/2010/09/image.png"><img style="border-width: 0px" src="http://blog.tallan.com/wp-content/uploads/2010/09/image_thumb.png" border="0" alt="image" width="540" height="218" /></a></p>
<p>When you run this batch script (with elevated administrator permissions), it runs a configuration wizard that checks for all prerequisites: PowerShell, Visual Studio, SQL, IIS7, WCF HTTP Activation, WIF.</p>
<p>Unfortunately, it complains about the WIF SDK not being installed even though it is.</p>
<p><a href="http://blog.tallan.com/wp-content/uploads/2010/09/image1.png"><img style="border-width: 0px" src="http://blog.tallan.com/wp-content/uploads/2010/09/image_thumb1.png" border="0" alt="image" width="540" height="348" /></a></p>
<p>I verified that the SDK was properly installed in <strong>Control Panel</strong> &gt; <strong>Programs and Features</strong>. I tried reinstalling the SDK but that didn’t fix the error.</p>
<p><a href="http://blog.tallan.com/wp-content/uploads/2010/09/image2.png"><img style="border-width: 0px" src="http://blog.tallan.com/wp-content/uploads/2010/09/image_thumb2.png" border="0" alt="image" width="540" height="198" /></a></p>
<p>I did some investigating in the content of the TrainingKit and followed a trail of folders (<span style="font-family: Consolas">IdentityTrainingKit\Assets\DependencyChecker\scripts\dependencies\check</span>) to this set of PowerShell scripts…</p>
<p><a href="http://blog.tallan.com/wp-content/uploads/2010/09/image3.png"><img style="border-width: 0px" src="http://blog.tallan.com/wp-content/uploads/2010/09/image_thumb3.png" border="0" alt="image" width="540" height="549" /></a></p>
<p>Open up <strong>CheckWifSdk.ps1</strong> and you will find the culprit</p>
<pre class="brush: powershell; highlight: [22,23]; wrap-lines: false;">
function SearchUninstall($SearchFor, $SearchVersion, $UninstallKey)
{
$uninstallObjects = ls -path $UninstallKey;
$found = $FALSE;
[reflection.assembly]::LoadWithPartialName(&quot;System.Version&quot;);
foreach($uninstallEntry in  $uninstallObjects)
{
   $entryProperty = Get-ItemProperty -path registry::$uninstallEntry
   if($entryProperty.DisplayName -like $searchFor)
   {
       $vc1 = new-Object System.Version($entryProperty.DisplayVersion);
       $vc2 = new-Object System.Version($searchVersion);
       if($vc1.CompareTo($vc2) -ne -1)
       {
         $found = $TRUE;
         break;
       }
   }
}
$found;
}
$res1 = SearchUninstall -SearchFor 'Windows Identity Foundation SDK' -SearchVersion '6.1.7600.113' -UninstallKey 'HKLM:SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\';
$res2 = SearchUninstall -SearchFor 'Windows Identity Foundation SDK' -SearchVersion '6.1.7600.113' -UninstallKey 'HKLM:SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\';
(($res1 -eq $TRUE) -or ($res2 -eq $TRUE))
</pre>
<p>The culprit is in the last section. Change <span style="font-family: Consolas"><span style="color: #3366ff">6.1.7600.<strong>113</strong></span></span> to <span style="font-family: Consolas"><span style="color: #3366ff">6.1.7600.<strong>16436</strong></span></span> AND <span style="color: #3366ff"><span style="font-family: Consolas">Windows Identity Foundation SDK</span> </span>to <span style="font-family: Consolas"><span style="color: #3366ff">Windows Identity Foundation SDK <strong>3.5</strong></span></span> in both <span style="font-family: Consolas">SearchUninstall </span>statements (one checks for the x86 version while the other looks for the x64 version of the SDK)</p>
<p>You can verify the version number and display name by checking the detail info in <strong>Control Panel</strong> &gt; <strong>Programs and Features</strong> (see screenshot above) or by checking the registry paths the PowerShell script uses.</p>
<p><span style="font-family: Consolas">HKLM:SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\<br />
or</span><span style="font-family: Consolas"><br />
</span><span style="font-family: Consolas">HKLM:SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\</span></p>
<p>Re-run <strong>setupLab.cmd</strong> and you should be able to proceed to the remainder of the set-up. Follow the recommended steps described in the <strong>Overview</strong> of each Lab.</p>
<p><a href="http://blog.tallan.com/wp-content/uploads/2010/09/image4.png"><img style="border: 0px" src="http://blog.tallan.com/wp-content/uploads/2010/09/image_thumb4.png" border="0" alt="image" width="540" height="352" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.tallan.com/2010/09/14/identity-developer-training-kit-and-an-issue-with-missing-dependencies/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Free Seminar: Breakthroughs in Microsoft Integration</title>
		<link>http://blog.tallan.com/2008/06/05/free-seminar-breakthroughs-in-microsoft-integration/</link>
		<comments>http://blog.tallan.com/2008/06/05/free-seminar-breakthroughs-in-microsoft-integration/#comments</comments>
		<pubDate>Thu, 05 Jun 2008 16:37:04 +0000</pubDate>
		<dc:creator>Andrew Babiec</dc:creator>
				<category><![CDATA[BizTalk]]></category>

		<guid isPermaLink="false">http://www.blogbiztalk.com/?p=79</guid>
		<description><![CDATA[For those in the Connecticut area&#8230;
Tallan is providing a complimentary executive lunch around the topic of Microsoft Integration. It includes a talk by Tom Stickle, Program Manager at Microsoft for the Connected Systems Division, about the new integration features in BizTalk. In addition, there will be a real-life integration case study from a CT-based company.
The [...]]]></description>
			<content:encoded><![CDATA[<p>For those in the Connecticut area&#8230;</p>
<p>Tallan is providing a complimentary executive lunch around the topic of Microsoft Integration. It includes a talk by Tom Stickle, Program Manager at Microsoft for the Connected Systems Division, about the new integration features in BizTalk. In addition, there will be a real-life integration case study from a CT-based company.</p>
<p>The event will be held from 11:00 AM until 1:00 PM on June 10th at Lake of Isles in North Stonington, CT (part of the Foxwoods Resort), where an executive lunch will be served.</p>
<p>Here is the link to <a href="http://www.tallan.com/events/pages/EventDetails.aspx?eventID=13">more information about this event and how to register</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.tallan.com/2008/06/05/free-seminar-breakthroughs-in-microsoft-integration/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>New England BizTalk User Group presentation</title>
		<link>http://blog.tallan.com/2008/06/03/new-england-biztalk-user-group-presentation/</link>
		<comments>http://blog.tallan.com/2008/06/03/new-england-biztalk-user-group-presentation/#comments</comments>
		<pubDate>Tue, 03 Jun 2008 05:45:19 +0000</pubDate>
		<dc:creator>Andrew Babiec</dc:creator>
				<category><![CDATA[BizTalk]]></category>

		<guid isPermaLink="false">http://www.blogbiztalk.com/?p=78</guid>
		<description><![CDATA[I gave a presentation on BizTalk High Availability options to the New England chapter of the BizTalk user Group on May 14th. 
Here is a link if you are interested in downloading the presentation (powerpoint 97-2003 format).
]]></description>
			<content:encoded><![CDATA[<p>I gave a presentation on BizTalk High Availability options to the <a href="http://www.btug.biz/Home/NewEngland/tabid/92/Default.aspx">New England chapter of the BizTalk user Group</a> on May 14th. </p>
<p>Here is a link if you are interested in downloading the <a href="http://blog.tallan.com/wp-content/uploads/2008/06/biztalk-high-availability-ababiec.ppt">presentation</a> (powerpoint 97-2003 format).</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.tallan.com/2008/06/03/new-england-biztalk-user-group-presentation/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Some new BizTalk links</title>
		<link>http://blog.tallan.com/2007/09/12/some-new-biztalk-links/</link>
		<comments>http://blog.tallan.com/2007/09/12/some-new-biztalk-links/#comments</comments>
		<pubDate>Wed, 12 Sep 2007 15:40:34 +0000</pubDate>
		<dc:creator>Andrew Babiec</dc:creator>
				<category><![CDATA[BizTalk]]></category>

		<guid isPermaLink="false">http://www.blogbiztalk.com/?p=57</guid>
		<description><![CDATA[Some interesting links:
BizTalk Server Database Optimization White Paper &#8211; This is an excellent MSDN write-up on how to optimize your BizTalk systems. The title is somewhat incorrect as it describes how to optimize the hardware (which RAID level to use, turn off hyperthreading), the Network (usage of subnets), the OS (Registry and other settings) , [...]]]></description>
			<content:encoded><![CDATA[<p>Some interesting links:</p>
<p><a href="http://msdn2.microsoft.com/en-us/library/bb743398.aspx">BizTalk Server Database Optimization White Paper</a> &#8211; This is an excellent MSDN write-up on how to optimize your BizTalk systems. The title is somewhat incorrect as it describes how to optimize the hardware (which RAID level to use, turn off hyperthreading), the Network (usage of subnets), the OS (Registry and other settings) , IIS and SQL Server tuning. This is an extensive and through document that includes lab performance tests and results, recommended configurations and links to helpful tools and utilities.</p>
<p>Some of the suggestions can be helpful even if you aren&#8217;t using BizTalk.</p>
<p><a href="http://www.codeplex.com/esb">Enterprise Service Bus (ESB) Guidance Documentation and Source Code</a> &#8211; This is the CodePlex community site for the latest release (CTP3) of the ESB Guidance package for BizTalk. Current plan is to release the final version in October.</p>
<p><a href="http://blogs.tallan.com/biztalk/files/2007/09/esb.jpg"><img style="width: 541px;height: 424px;border-width: 0px" height="424" alt="esb" src="http://blogs.tallan.com/biztalk/files/2007/09/esb_thumb.jpg" width="541" border="0" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.tallan.com/2007/09/12/some-new-biztalk-links/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>A Custom Functoid &#8211; EBCDIC to ASCII</title>
		<link>http://blog.tallan.com/2006/12/20/a-custom-functoid-ebcdic-to-ascii/</link>
		<comments>http://blog.tallan.com/2006/12/20/a-custom-functoid-ebcdic-to-ascii/#comments</comments>
		<pubDate>Wed, 20 Dec 2006 16:40:00 +0000</pubDate>
		<dc:creator>Andrew Babiec</dc:creator>
				<category><![CDATA[BizTalk]]></category>

		<guid isPermaLink="false">http://www.blogbiztalk.com/?p=51</guid>
		<description><![CDATA[Here is an example of a custom functoid method that converts an EBCDIC signed value to ASCII format:
Add a new C# class library project to your BizTalk solution and call it MyCompany.BizTalk.Functoids. Create a C# class in the project and use the same project name for the namespace.
 Example:

using System;
using System.Collections.Generic;
using System.Text;
 
namespace MyCompany.BizTalk.Functoids
{
    /// &#60;summary&#62;
    /// Summary [...]]]></description>
			<content:encoded><![CDATA[<p>Here is an example of a custom functoid method that converts an EBCDIC signed value to ASCII format:</p>
<p>Add a new C# class library project to your BizTalk solution and call it MyCompany.BizTalk.Functoids. Create a C# class in the project and use the same project name for the namespace.</p>
<p> Example:</p>
<div style="font-size: 10pt;background: white;color: black;font-family: consolas">
<p style="margin: 0px"><span style="color: blue">using</span> System;</p>
<p style="margin: 0px"><span style="color: blue">using</span> System.Collections.Generic;</p>
<p style="margin: 0px"><span style="color: blue">using</span> System.Text;</p>
<p style="margin: 0px"> </p>
<p style="margin: 0px"><span style="color: blue">namespace</span> MyCompany.BizTalk.Functoids</p>
<p style="margin: 0px">{</p>
<p style="margin: 0px">    <span style="color: gray">///</span><span style="color: green"> </span><span style="color: gray">&lt;summary&gt;</span></p>
<p style="margin: 0px">    <span style="color: gray">///</span><span style="color: green"> Summary description for Utils.</span></p>
<p style="margin: 0px">    <span style="color: gray">///</span><span style="color: green"> </span><span style="color: gray">&lt;/summary&gt;</span></p>
<p style="margin: 0px">    <span style="color: blue">public</span> <span style="color: blue">class</span> <span style="color: teal">Utils</span></p>
<p style="margin: 0px">    {</p>
<p style="margin: 0px">        <span style="color: blue">public</span> Utils()</p>
<p style="margin: 0px">        {</p>
<p style="margin: 0px"> </p>
<p style="margin: 0px">        }</p>
</div>
<p>Add the method to perform the conversion:</p>
<div style="font-size: 10pt;background: white;color: black;font-family: consolas">
<p style="margin: 0px"><span style="color: gray">///</span><span style="color: green"> </span><span style="color: gray">&lt;summary&gt;</span></p>
<p style="margin: 0px">        <span style="color: gray">///</span><span style="color: green"> Convert EBCDIC signed values to ASCII format </span></p>
<p style="margin: 0px">        <span style="color: gray">///</span><span style="color: green"> </span><span style="color: gray">&lt;/summary&gt;</span></p>
<p style="margin: 0px">        <span style="color: gray">///</span><span style="color: green"> </span><span style="color: gray">&lt;param name=&#8221;amount&#8221;&gt;</span><span style="color: green">Amount to be converted</span><span style="color: gray">&lt;/param&gt;</span></p>
<p style="margin: 0px">        <span style="color: gray">///</span><span style="color: green"> </span><span style="color: gray">&lt;param name=&#8221;sign&#8221;&gt;</span><span style="color: green">Signed Value</span><span style="color: gray">&lt;/param&gt;</span></p>
<p style="margin: 0px">        <span style="color: gray">///</span><span style="color: green"> </span><span style="color: gray">&lt;returns&gt;&lt;/returns&gt;</span></p>
<p style="margin: 0px">        <span style="color: blue">public</span> <span style="color: blue">double</span> ConvertFromEBCDIC(<span style="color: blue">double</span> amount, <span style="color: blue">string</span> sign)</p>
<p style="margin: 0px">        {</p>
<p style="margin: 0px">            <span style="color: blue">switch</span> (sign)</p>
<p style="margin: 0px">            {</p>
<p style="margin: 0px">                <span style="color: blue">case</span> <span style="color: maroon">&#8220;{&#8220;</span>:</p>
<p style="margin: 0px">                    amount = (amount / 10);</p>
<p style="margin: 0px">                    <span style="color: blue">break</span>;</p>
<p style="margin: 0px">                <span style="color: blue">case</span> <span style="color: maroon">&#8220;}&#8221;</span>:</p>
<p style="margin: 0px">                    amount = (amount / 10) * -1;</p>
<p style="margin: 0px">                    <span style="color: blue">break</span>;</p>
<p style="margin: 0px">                <span style="color: blue">case</span> <span style="color: maroon">&#8220;A&#8221;</span>:</p>
<p style="margin: 0px">                    amount = (amount / 10) + .01;</p>
<p style="margin: 0px">                    <span style="color: blue">break</span>;</p>
<p style="margin: 0px">                <span style="color: blue">case</span> <span style="color: maroon">&#8220;J&#8221;</span>:</p>
<p style="margin: 0px">                    amount = ((amount / 10) + .01) * -1;</p>
<p style="margin: 0px">                    <span style="color: blue">break</span>;</p>
<p style="margin: 0px">                <span style="color: blue">case</span> <span style="color: maroon">&#8220;B&#8221;</span>:</p>
<p style="margin: 0px">                    amount = ((amount / 10) + .02);</p>
<p style="margin: 0px">                    <span style="color: blue">break</span>;</p>
<p style="margin: 0px">                <span style="color: blue">case</span> <span style="color: maroon">&#8220;K&#8221;</span>:</p>
<p style="margin: 0px">                    amount = ((amount / 10) + .02) * -1;</p>
<p style="margin: 0px">                    <span style="color: blue">break</span>;</p>
<p style="margin: 0px">                <span style="color: blue">case</span> <span style="color: maroon">&#8220;C&#8221;</span>:</p>
<p style="margin: 0px">                    amount = ((amount / 10) + .03);</p>
<p style="margin: 0px">                    <span style="color: blue">break</span>;</p>
<p style="margin: 0px">                <span style="color: blue">case</span> <span style="color: maroon">&#8220;L&#8221;</span>:</p>
<p style="margin: 0px">                    amount = ((amount / 10) + .03) * -1;</p>
<p style="margin: 0px">                    <span style="color: blue">break</span>;</p>
<p style="margin: 0px">                <span style="color: blue">case</span> <span style="color: maroon">&#8220;D&#8221;</span>:</p>
<p style="margin: 0px">                    amount = ((amount / 10) + .04);</p>
<p style="margin: 0px">                    <span style="color: blue">break</span>;</p>
<p style="margin: 0px">                <span style="color: blue">case</span> <span style="color: maroon">&#8220;M&#8221;</span>:</p>
<p style="margin: 0px">                    amount = ((amount / 10) + .04) * -1;</p>
<p style="margin: 0px">                    <span style="color: blue">break</span>;</p>
<p style="margin: 0px">                <span style="color: blue">case</span> <span style="color: maroon">&#8220;E&#8221;</span>:</p>
<p style="margin: 0px">                    amount = ((amount / 10) + .05);</p>
<p style="margin: 0px">                    <span style="color: blue">break</span>;</p>
<p style="margin: 0px">                <span style="color: blue">case</span> <span style="color: maroon">&#8220;N&#8221;</span>:</p>
<p style="margin: 0px">                    amount = ((amount / 10) + .05) * -1;</p>
<p style="margin: 0px">                    <span style="color: blue">break</span>;</p>
<p style="margin: 0px">                <span style="color: blue">case</span> <span style="color: maroon">&#8220;F&#8221;</span>:</p>
<p style="margin: 0px">                    amount = ((amount / 10) + .06);</p>
<p style="margin: 0px">                    <span style="color: blue">break</span>;</p>
<p style="margin: 0px">                <span style="color: blue">case</span> <span style="color: maroon">&#8220;O&#8221;</span>:</p>
<p style="margin: 0px">                    amount = ((amount / 10) + .06) * -1;</p>
<p style="margin: 0px">                    <span style="color: blue">break</span>;</p>
<p style="margin: 0px">                <span style="color: blue">case</span> <span style="color: maroon">&#8220;G&#8221;</span>:</p>
<p style="margin: 0px">                    amount = ((amount / 10) + .07);</p>
<p style="margin: 0px">                    <span style="color: blue">break</span>;</p>
<p style="margin: 0px">                <span style="color: blue">case</span> <span style="color: maroon">&#8220;P&#8221;</span>:</p>
<p style="margin: 0px">                    amount = ((amount / 10) + .07) * -1;</p>
<p style="margin: 0px">                    <span style="color: blue">break</span>;</p>
<p style="margin: 0px">                <span style="color: blue">case</span> <span style="color: maroon">&#8220;H&#8221;</span>:</p>
<p style="margin: 0px">                    amount = ((amount / 10) + .08);</p>
<p style="margin: 0px">                    <span style="color: blue">break</span>;</p>
<p style="margin: 0px">                <span style="color: blue">case</span> <span style="color: maroon">&#8220;Q&#8221;</span>:</p>
<p style="margin: 0px">                    amount = ((amount / 10) + .08) * -1;</p>
<p style="margin: 0px">                    <span style="color: blue">break</span>;</p>
<p style="margin: 0px">                <span style="color: blue">case</span> <span style="color: maroon">&#8220;I&#8221;</span>:</p>
<p style="margin: 0px">                    amount = ((amount / 10) + .09);</p>
<p style="margin: 0px">                    <span style="color: blue">break</span>;</p>
<p style="margin: 0px">                <span style="color: blue">case</span> <span style="color: maroon">&#8220;R&#8221;</span>:</p>
<p style="margin: 0px">                    amount = ((amount / 10) + .09) * -1;</p>
<p style="margin: 0px">                    <span style="color: blue">break</span>;</p>
<p style="margin: 0px">            }</p>
<p style="margin: 0px"> </p>
<p style="margin: 0px">            <span style="color: blue">return</span> amount;</p>
<p style="margin: 0px">        }</p>
</div>
<p> </p>
<p>Add the close braces for the class and namespace, save the file and compile the project.</p>
<p>In order to use the scripting functoid in your map, you will need to first add the assembly to the GAC:</p>
<blockquote><p>gacutil /i MyCompany.BizTalk.Functoids.dll</p></blockquote>
<p>In order to use it on a map, you will need to drop the Scripting Functoid onto the map. It looks like a orange box with a S label. Select the scripting functoid and in the properties, click on the <strong>Configure Functoid Script </strong>option. A Configure Functoid Script dialog box will appear and the following entries should be filled in as follows:</p>
<blockquote><p>Script Type: <strong>External Assembly</strong></p>
<p>Script Assembly:  <strong>MyCompany.BizTalk.Functoids, version=&#8230;</strong></p>
<p>Script Class: <strong>MyCompany.BizTalk.Functoids.Utils</strong></p>
<p>Script Method: <strong>ConvertFromEBCDIC</strong></p></blockquote>
<p>After this, all you would need to do is connect the input parameter and the one output parameter.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.tallan.com/2006/12/20/a-custom-functoid-ebcdic-to-ascii/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Custom Pipeline Components &#8211; part 3: Completing the Archive Component</title>
		<link>http://blog.tallan.com/2006/12/20/custom-pipeline-components-part-3-completing-the-archive-component/</link>
		<comments>http://blog.tallan.com/2006/12/20/custom-pipeline-components-part-3-completing-the-archive-component/#comments</comments>
		<pubDate>Wed, 20 Dec 2006 16:13:55 +0000</pubDate>
		<dc:creator>Andrew Babiec</dc:creator>
				<category><![CDATA[BizTalk]]></category>

		<guid isPermaLink="false">http://www.blogbiztalk.com/?p=50</guid>
		<description><![CDATA[This post continues the series on creating custom pipeline components.&#160;The previous posts in the series&#160;can be found&#160;here:&#160;&#160;post 1, &#160;post 2.
In order to complete the exercise of&#160;creating the archive component, we need to add the code to actually perform the archival of the message. For this example, the requirements of the archive component is to persist [...]]]></description>
			<content:encoded><![CDATA[<p>This post continues the series on creating custom pipeline components.&nbsp;The previous posts in the series&nbsp;can be found&nbsp;here:&nbsp;&nbsp;<a href="http://www.blogbiztalk.com/?p=38">post 1</a>, &nbsp;<a href="http://www.blogbiztalk.com/?p=39">post 2</a>.</p>
<p>In order to complete the exercise of&nbsp;creating the archive component, we need to add the code to actually perform the archival of the message. For this example, the requirements of the archive component is to persist an exact copy of the message coming into BizTalk (whether flat file, xml, binary or even an encrypted) in it&#8217;s original form to the local filesystem.</p>
<p>To start off, we need to create&nbsp;a method to write&nbsp;an inputstream&nbsp;to the filesystem outputstream. The following CopyStream method does this&#8230;</p>
<p>
<div style="font-size: 10pt;background: white;color: black;font-family: consolas">
<p style="margin: 0px">&nbsp;</p>
<p style="margin: 0px">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color: blue">protected</span> <span style="color: blue">void</span> CopyStream(<span style="color: teal">Stream</span> input, <span style="color: teal">Stream</span> output)</p>
<p style="margin: 0px">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; {</p>
<p style="margin: 0px">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color: blue">int</span> BUFFER_SIZE = 4096;</p>
<p style="margin: 0px">&nbsp;</p>
<p style="margin: 0px">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color: blue">byte</span>[] buffer = <span style="color: blue">new</span> <span style="color: blue">byte</span>[BUFFER_SIZE];</p>
<p style="margin: 0px">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color: blue">int</span> bytesRead;</p>
<p style="margin: 0px">&nbsp;</p>
<p style="margin: 0px">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color: blue">try</span></p>
<p style="margin: 0px">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; {</p>
<p style="margin: 0px">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; bytesRead = input.Read(buffer, 0, BUFFER_SIZE);</p>
<p style="margin: 0px">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color: blue">while</span> (bytesRead &gt; 0)</p>
<p style="margin: 0px">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; {</p>
<p style="margin: 0px">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; output.Write(buffer, 0, bytesRead);</p>
<p style="margin: 0px">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; bytesRead = input.Read(buffer, 0, BUFFER_SIZE);</p>
<p style="margin: 0px">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }</p>
<p style="margin: 0px">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }</p>
<p style="margin: 0px">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color: blue">catch</span> (<span style="color: teal">Exception</span> ex)</p>
<p style="margin: 0px">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; {</p>
<p style="margin: 0px">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color: blue">throw</span> ex;</p>
<p style="margin: 0px">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }</p>
<p style="margin: 0px">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color: blue">finally</span></p>
<p style="margin: 0px">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; {</p>
<p style="margin: 0px">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color: green">// rewind input stream</span></p>
<p style="margin: 0px">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color: blue">if</span> (input.CanSeek)</p>
<p style="margin: 0px">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; input.Position = 0;</p>
<p style="margin: 0px">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }</p>
<p style="margin: 0px">&nbsp;</p>
<p style="margin: 0px">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }</p>
</div>
<p>&nbsp;The next method needed is one that takes a BizTalk <a href="http://msdn2.microsoft.com/en-us/library/microsoft.biztalk.message.interop.ibasemessage_members.aspx">IBaseMessage</a> and uses the CopyStream method from above to write&nbsp;the message&nbsp;to the filesystem.</p>
<p>
<div style="font-size: 10pt;background: white;color: black;font-family: consolas">
<p style="margin: 0px">&nbsp;</p>
<p style="margin: 0px">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color: blue">protected</span> <span style="color: blue">void</span> WriteToFile(<span style="color: teal">IBaseMessage</span> message, <span style="color: blue">string</span> fileName)</p>
<p style="margin: 0px">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; {</p>
<p style="margin: 0px">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color: teal">Stream</span> msgStream = message.BodyPart.GetOriginalDataStream();</p>
<p style="margin: 0px">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color: teal">FileStream</span> fileStream = <span style="color: blue">null</span>;</p>
<p style="margin: 0px">&nbsp;</p>
<p style="margin: 0px">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color: blue">try</span></p>
<p style="margin: 0px">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; {</p>
<p style="margin: 0px">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; fileStream = <span style="color: blue">new</span> <span style="color: teal">FileStream</span>(fileName, <span style="color: teal">FileMode</span>.OpenOrCreate);</p>
<p style="margin: 0px">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color: blue">this</span>.CopyStream(msgStream, fileStream);</p>
<p style="margin: 0px">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }</p>
<p style="margin: 0px">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color: blue">catch</span> (<span style="color: teal">Exception</span> ex)</p>
<p style="margin: 0px">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; {</p>
<p style="margin: 0px">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color: blue">throw</span> ex;</p>
<p style="margin: 0px">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }</p>
<p style="margin: 0px">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color: blue">finally</span></p>
<p style="margin: 0px">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; {</p>
<p style="margin: 0px">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color: blue">if</span> (fileStream != <span style="color: blue">null</span>)</p>
<p style="margin: 0px">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; fileStream.Close();</p>
<p style="margin: 0px">&nbsp;</p>
<p style="margin: 0px">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color: blue">if</span> (msgStream.CanSeek)</p>
<p style="margin: 0px">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; msgStream.Position = 0;</p>
<p style="margin: 0px">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }</p>
<p style="margin: 0px">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }</p>
</div>
<p>The final step is to&nbsp;&nbsp;implement the Execute method that utilizes the WriteToFile method we just created. We will use the&nbsp;InterchangeID as the filename, and since it is&nbsp;basically a&nbsp;GUID it guarantees the filename&nbsp;will be&nbsp;unique. This is a string automatically&nbsp;set by the Messaging Engine for each message that arrives on the server and it defines the unique ID that is used to group the documents that resulted from the same interchange message.</p>
<p>We also want to the archive file to include the original filename, otherwise it might be difficult for a user to determine which message came from which file when a directory is filled with just GUIDs. So what we will do is look at the original filename property and prepend it to the InterchangeID with a underscore between them. You will notice that depending on the adapter (FILE, FTP) the file comes in on, we use a different schema.&nbsp;In addition, if the file comes in from any other adapter, the filename property&nbsp;won&#8217;t be available,&nbsp;so we skip&nbsp;the prepend step.&nbsp;</p>
<p>
<div style="font-size: 10pt;background: white;color: black;font-family: consolas">
<p style="margin: 0px"><span style="color: gray">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ///</span><span style="color: green"> </span><span style="color: gray">&lt;summary&gt;</span></p>
<p style="margin: 0px">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color: gray">///</span><span style="color: green"> Implements IComponent.Execute method.</span></p>
<p style="margin: 0px">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color: gray">///</span><span style="color: green"> </span><span style="color: gray">&lt;/summary&gt;</span></p>
<p style="margin: 0px">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color: gray">///</span><span style="color: green"> </span><span style="color: gray">&lt;param name=&#8221;pc&#8221;&gt;</span><span style="color: green">Pipeline context</span><span style="color: gray">&lt;/param&gt;</span></p>
<p style="margin: 0px">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color: gray">///</span><span style="color: green"> </span><span style="color: gray">&lt;param name=&#8221;inmsg&#8221;&gt;</span><span style="color: green">Input message</span><span style="color: gray">&lt;/param&gt;</span></p>
<p style="margin: 0px">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color: gray">///</span><span style="color: green"> </span><span style="color: gray">&lt;returns&gt;</span><span style="color: green">Original input message</span><span style="color: gray">&lt;/returns&gt;</span></p>
<p style="margin: 0px">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color: gray">///</span><span style="color: green"> </span><span style="color: gray">&lt;remarks&gt;</span></p>
<p style="margin: 0px">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color: gray">///</span><span style="color: green"> IComponent.Execute method is used to initiate</span></p>
<p style="margin: 0px">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color: gray">///</span><span style="color: green"> the processing of the message in this pipeline component.</span></p>
<p style="margin: 0px">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color: gray">///</span><span style="color: green"> </span><span style="color: gray">&lt;/remarks&gt;</span></p>
<p style="margin: 0px">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color: blue">public</span> Microsoft.BizTalk.Message.Interop.<span style="color: teal">IBaseMessage</span> Execute&nbsp; </p>
<p style="margin: 0px">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(Microsoft.BizTalk.Component.Interop.<span style="color: teal">IPipelineContext</span> pContext,&nbsp; </p>
<p style="margin: 0px">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Microsoft.BizTalk.Message.Interop.<span style="color: teal">IBaseMessage</span> pInMsg)</p>
<p style="margin: 0px">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; {</p>
<p style="margin: 0px">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color: teal">IBaseMessage</span> passedMessage = pInMsg;</p>
<p style="margin: 0px">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color: blue">string</span> archiveFileName = <span style="color: blue">null</span>;</p>
<p style="margin: 0px">&nbsp;</p>
<p style="margin: 0px">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color: green">// get the interchange id from the message</span></p>
<p style="margin: 0px">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color: blue">string</span> interchangeID = (<span style="color: blue">string</span>)pInMsg.Context.Read(<span style="color: maroon">&#8220;InterchangeID&#8221;</span>,</p>
<p style="margin: 0px">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color: maroon">&#8220;http://schemas.microsoft.com/BizTalk/2003/system-properties&#8221;</span>);</p>
<p style="margin: 0px">&nbsp;</p>
<p style="margin: 0px">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color: green">// if the transport type if file or ftp, get the incoming filename to use</span></p>
<p style="margin: 0px">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color: green">// as part of the archive filename (for easier identification)</span></p>
<p style="margin: 0px">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color: blue">string</span> filePath = <span style="color: blue">null</span>;</p>
<p style="margin: 0px">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color: blue">string</span> adapterType = (<span style="color: blue">string</span>)pInMsg.Context.Read(<span style="color: maroon">&#8220;InboundTransportType&#8221;</span>,</p>
<p style="margin: 0px">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color: maroon">&#8220;http://schemas.microsoft.com/BizTalk/2003/system-properties&#8221;</span>);</p>
<p style="margin: 0px">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color: blue">if</span> (adapterType == <span style="color: maroon">&#8220;FILE&#8221;</span>)</p>
<p style="margin: 0px">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; {</p>
<p style="margin: 0px">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; filePath = (<span style="color: blue">string</span>)pInMsg.Context.Read(<span style="color: maroon">&#8220;ReceivedFileName&#8221;</span>,</p>
<p style="margin: 0px">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color: maroon">&#8220;http://schemas.microsoft.com/BizTalk/2003/file-properties&#8221;</span>);</p>
<p style="margin: 0px">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }</p>
<p style="margin: 0px">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color: blue">else</span> <span style="color: blue">if</span> (adapterType == <span style="color: maroon">&#8220;FTP&#8221;</span>)</p>
<p style="margin: 0px">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; {</p>
<p style="margin: 0px">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; filePath = (<span style="color: blue">string</span>)pInMsg.Context.Read(<span style="color: maroon">&#8220;ReceivedFileName&#8221;</span>,</p>
<p style="margin: 0px">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color: maroon">&#8220;http://schemas.microsoft.com/BizTalk/2003/ftp-properties&#8221;</span>);</p>
<p style="margin: 0px">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }</p>
<p style="margin: 0px">&nbsp;</p>
<p style="margin: 0px">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; archiveFileName = interchangeID + <span style="color: maroon">&#8220;.out&#8221;</span>;</p>
<p style="margin: 0px">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color: blue">if</span> (filePath != <span style="color: blue">null</span>)</p>
<p style="margin: 0px">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; {</p>
<p style="margin: 0px">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; archiveFileName = <span style="color: teal">Path</span>.GetFileName(filePath) + <span style="color: maroon">&#8220;_&#8221;</span> + archiveFileName;</p>
<p style="margin: 0px">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }</p>
<p style="margin: 0px">&nbsp;</p>
<p style="margin: 0px">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color: green">// write the archive file</span></p>
<p style="margin: 0px">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; WriteToFile(pInMsg, <span style="color: teal">Path</span>.Combine(<span style="color: blue">this</span>._ArchivePath, archiveFileName));</p>
<p style="margin: 0px">&nbsp;</p>
<p style="margin: 0px">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color: green">// this way, it&#8217;s a passthrough pipeline component</span></p>
<p style="margin: 0px">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color: blue">return</span><br />
 pInMsg;</p>
<p style="margin: 0px">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }</p>
<p style="margin: 0px"><span style="color: blue">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; #endregion</span></p>
</div>
<p>When used, the&nbsp;archive component&nbsp;will create&nbsp;files&nbsp;with&nbsp;filenames similar to&nbsp;the following examples:</p>
<p>If Transport Type =&nbsp;FTP&nbsp; or FILE: </p>
<p>MyTestFile.txt.pgp_{2E50A0DD-395B-4629-A345-7CB0FDDE4727}.out</p>
<p>Any other Transport Type:</p>
<p>{B9D33010-BE49-490B-ABFA-E3B63CAFCDAE}.out</p>
<p>&nbsp;The next article in this series goes over the steps to using the custom Archive pipeline component in your BizTalk application.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.tallan.com/2006/12/20/custom-pipeline-components-part-3-completing-the-archive-component/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Custom Pipeline Components &#8211; part 2: Archive component continued&#8230;</title>
		<link>http://blog.tallan.com/2006/11/22/custom-pipeline-components-part-2-archive-same-continued/</link>
		<comments>http://blog.tallan.com/2006/11/22/custom-pipeline-components-part-2-archive-same-continued/#comments</comments>
		<pubDate>Wed, 22 Nov 2006 00:06:06 +0000</pubDate>
		<dc:creator>Andrew Babiec</dc:creator>
				<category><![CDATA[BizTalk]]></category>

		<guid isPermaLink="false">http://www.blogbiztalk.com/?p=39</guid>
		<description><![CDATA[In the previous post we started&#160;creating the c# class&#160;that implements the interfaces needed to develop a custom BizTalk pipeline component. In this post, we continue with this sample&#8230;
The next interface we will implement is the IPersistPropertyBag interface. Before we do that, we need to add two generic utility methods to read to &#38; write from [...]]]></description>
			<content:encoded><![CDATA[<p>In the <a href="http://blogs.tallan.com/biztalk/?p=38">previous post</a> we started&nbsp;creating the c# class&nbsp;that implements the interfaces needed to develop a custom BizTalk pipeline component. In this post, we continue with this sample&#8230;</p>
<p>The next interface we will implement is the <strong>IPersistPropertyBag </strong>interface. Before we do that, we need to add two generic utility methods to read to &amp; write from property bags. A property bag&nbsp;is&nbsp;an object which can persistently save its properties. <a href="http://msdn2.microsoft.com/en-us/default.aspx">MSDN</a> provides more info on the <a href="http://msdn2.microsoft.com/en-us/library/ms974265.aspx">Microsoft.BizTalk.Adapter.Framework.PropertyBag</a> class.</p>
<p>
<div style="font-size: 10pt;color: black;font-family: consolas">
<p style="margin: 0px"><span style="color: blue">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; #region</span> utility functions</p>
<p style="margin: 0px">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color: gray">///</span><span style="color: green"> </span><span style="color: gray">&lt;summary&gt;</span></p>
<p style="margin: 0px">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color: gray">///</span><span style="color: green"> Reads property value from property bag</span></p>
<p style="margin: 0px">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color: gray">///</span><span style="color: green"> </span><span style="color: gray">&lt;/summary&gt;</span></p>
<p style="margin: 0px">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color: gray">///</span><span style="color: green"> </span><span style="color: gray">&lt;param name=&#8221;pb&#8221;&gt;</span><span style="color: green">Property bag</span><span style="color: gray">&lt;/param&gt;</span></p>
<p style="margin: 0px">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color: gray">///</span><span style="color: green"> </span><span style="color: gray">&lt;param name=&#8221;propName&#8221;&gt;</span><span style="color: green">Name of property</span><span style="color: gray">&lt;/param&gt;</span></p>
<p style="margin: 0px">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color: gray">///</span><span style="color: green"> </span><span style="color: gray">&lt;returns&gt;</span><span style="color: green">Value of the property</span><span style="color: gray">&lt;/returns&gt;</span></p>
<p style="margin: 0px">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color: blue">private</span> <span style="color: blue">object</span> ReadPropertyBag(</p>
<p style="margin: 0px">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Microsoft.BizTalk.Component.Interop.<span style="color: teal">IPropertyBag</span> pb, <span style="color: blue">string</span> propName)</p>
<p style="margin: 0px">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; {</p>
<p style="margin: 0px">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color: blue">object</span> val = <span style="color: blue">null</span>;</p>
<p style="margin: 0px">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color: blue">try</span></p>
<p style="margin: 0px">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; {</p>
<p style="margin: 0px">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; pb.Read(propName, <span style="color: blue">out</span> val, 0);</p>
<p style="margin: 0px">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }</p>
<p style="margin: 0px">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color: blue">catch</span> (System.<span style="color: teal">ArgumentException</span>)</p>
<p style="margin: 0px">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; {</p>
<p style="margin: 0px">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color: blue">return</span> val;</p>
<p style="margin: 0px">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }</p>
<p style="margin: 0px">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color: blue">catch</span> (System.<span style="color: teal">Exception</span> e)</p>
<p style="margin: 0px">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; {</p>
<p style="margin: 0px">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color: blue">throw</span> <span style="color: blue">new</span> System.<span style="color: teal">ApplicationException</span>(e.Message);</p>
<p style="margin: 0px">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }</p>
<p style="margin: 0px">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color: blue">return</span> val;</p>
<p style="margin: 0px">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }</p>
<p style="margin: 0px">&nbsp;</p>
<p style="margin: 0px">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color: gray">///</span><span style="color: green"> </span><span style="color: gray">&lt;summary&gt;</span></p>
<p style="margin: 0px">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color: gray">///</span><span style="color: green"> Writes property values into a property bag.</span></p>
<p style="margin: 0px">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color: gray">///</span><span style="color: green"> </span><span style="color: gray">&lt;/summary&gt;</span></p>
<p style="margin: 0px">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color: gray">///</span><span style="color: green"> </span><span style="color: gray">&lt;param name=&#8221;pb&#8221;&gt;</span><span style="color: green">Property bag.</span><span style="color: gray">&lt;/param&gt;</span></p>
<p style="margin: 0px">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color: gray">///</span><span style="color: green"> </span><span style="color: gray">&lt;param name=&#8221;propName&#8221;&gt;</span><span style="color: green">Name of property.</span><span style="color: gray">&lt;/param&gt;</span></p>
<p style="margin: 0px">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color: gray">///</span><span style="color: green"> </span><span style="color: gray">&lt;param name=&#8221;val&#8221;&gt;</span><span style="color: green">Value of property.</span><span style="color: gray">&lt;/param&gt;</span></p>
<p style="margin: 0px">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color: blue">private</span> <span style="color: blue">void</span> WritePropertyBag(</p>
<p style="margin: 0px">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Microsoft.BizTalk.Component.Interop.<span style="color: teal">IPropertyBag</span> pb, </p>
<p style="margin: 0px"><span style="color: blue">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; string</span> propName, <span style="color: blue">object</span> val)</p>
<p style="margin: 0px">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; {</p>
<p style="margin: 0px">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color: blue">try</span></p>
<p style="margin: 0px">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; {</p>
<p style="margin: 0px">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; pb.Write(propName, <span style="color: blue">ref</span> val);</p>
<p style="margin: 0px">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }</p>
<p style="margin: 0px">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color: blue">catch</span> (System.<span style="color: teal">Exception</span> e)</p>
<p style="margin: 0px">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; {</p>
<p style="margin: 0px">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color: blue">throw</span> <span style="color: blue">new</span> System.<span style="color: teal">ApplicationException</span>(e.Message);</p>
<p style="margin: 0px">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }</p>
<p style="margin: 0px">&nbsp;&nbsp;&nbsp; &amp;nb<br />
sp;&nbsp;&nbsp; }</p>
<p style="margin: 0px"><span style="color: blue">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; #endregion</span></p>
</div>
<p>&nbsp;</p>
<ul>Now we can implement the <strong>IPersistPropertyBag</strong> interface which only requires the following four methods:
<li><strong>GetClassID</strong> &#8211; Gets the class ID of the object to persist.
<li><strong>InitNew</strong> &#8211; Initializes a new class.
<li><strong>Load</strong> &#8211; Loads data from the persisted object into the new object.
<li><strong>Save</strong> &#8211; Saves the new object. Notice that the Save and Load methods&nbsp;persist the custom properties (<strong>path, IsActive</strong>)&nbsp;we created in the first post.</li>
</ul>
<p>
<div style="font-size: 10pt;color: black;font-family: consolas">
<p style="margin: 0px"><span style="color: blue">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; #region</span> IPersistPropertyBag members</p>
<p style="margin: 0px">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color: gray">///</span><span style="color: green"> </span><span style="color: gray">&lt;summary&gt;</span></p>
<p style="margin: 0px">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color: gray">///</span><span style="color: green"> Gets class ID of component for usage from unmanaged code.</span></p>
<p style="margin: 0px">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color: gray">///</span><span style="color: green"> </span><span style="color: gray">&lt;/summary&gt;</span></p>
<p style="margin: 0px">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color: gray">///</span><span style="color: green"> </span><span style="color: gray">&lt;param name=&#8221;classid&#8221;&gt;</span></p>
<p style="margin: 0px">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color: gray">///</span><span style="color: green"> Class ID of the component</span></p>
<p style="margin: 0px">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color: gray">///</span><span style="color: green"> </span><span style="color: gray">&lt;/param&gt;</span></p>
<p style="margin: 0px">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color: blue">public</span> <span style="color: blue">void</span> GetClassID(<span style="color: blue">out</span> System.<span style="color: teal">Guid</span> classid)</p>
<p style="margin: 0px">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; {</p>
<p style="margin: 0px">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; classid = <span style="color: blue">new</span> System.<span style="color: teal">Guid</span>(<span style="color: maroon">&#8220;f5f5337f-593f-4618-8e35-dff308dbb6f5&#8243;</span>);</p>
<p style="margin: 0px">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }</p>
<p style="margin: 0px">&nbsp;</p>
<p style="margin: 0px">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color: gray">///</span><span style="color: green"> </span><span style="color: gray">&lt;summary&gt;</span></p>
<p style="margin: 0px">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color: gray">///</span><span style="color: green"> not implemented</span></p>
<p style="margin: 0px">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color: gray">///</span><span style="color: green"> </span><span style="color: gray">&lt;/summary&gt;</span></p>
<p style="margin: 0px">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color: blue">public</span> <span style="color: blue">void</span> InitNew()</p>
<p style="margin: 0px">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; {</p>
<p style="margin: 0px">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }</p>
<p style="margin: 0px">&nbsp;</p>
<p style="margin: 0px">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color: gray">///</span><span style="color: green"> </span><span style="color: gray">&lt;summary&gt;</span></p>
<p style="margin: 0px">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color: gray">///</span><span style="color: green"> Loads configuration properties for the component</span></p>
<p style="margin: 0px">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color: gray">///</span><span style="color: green"> </span><span style="color: gray">&lt;/summary&gt;</span></p>
<p style="margin: 0px">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color: gray">///</span><span style="color: green"> </span><span style="color: gray">&lt;param name=&#8221;pb&#8221;&gt;</span><span style="color: green">Configuration property bag</span><span style="color: gray">&lt;/param&gt;</span></p>
<p style="margin: 0px">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color: gray">///</span><span style="color: green"> </span><span style="color: gray">&lt;param name=&#8221;errlog&#8221;&gt;</span><span style="color: green">Error status</span><span style="color: gray">&lt;/param&gt;</span></p>
<p style="margin: 0px">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color: blue">public</span> <span style="color: blue">virtual</span> <span style="color: blue">void</span> Load(</p>
<p style="margin: 0px">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Microsoft.BizTalk.Component.Interop.<span style="color: teal">IPropertyBag</span> pb, <span style="color: blue">int</span> errlog)</p>
<p style="margin: 0px">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; {</p>
<p style="margin: 0px">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color: blue">object</span> val = <span style="color: blue">null</span>;</p>
<p style="margin: 0px">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; val = <span style="color: blue">this</span>.ReadPropertyBag(pb, <span style="color: maroon">&#8220;path&#8221;</span>);</p>
<p style="margin: 0px">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color: blue">if</span> ((val != <span style="color: blue">null</span>))</p>
<p style="margin: 0px">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; {</p>
<p style="margin: 0px">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color: blue">this</span>._path = ((<span style="color: blue">string</span>)(val));</p>
<p style="margin: 0px">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }</p>
<p style="margin: 0px">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; val = <span style="color: blue">this</span>.ReadPropertyBag(pb, <span style="color: maroon">&#8220;IsActive&#8221;</span>);</p>
<p style="margin: 0px">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color: blue">if</span> ((val != <span style="color: blue">null</span>))</p>
<p style="margin: 0px">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; {</p>
<p style="margin: 0px">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color: blue">this</span>._IsActive = ((<span style="color: blue">bool</span>)(val));</p>
<p style="margin: 0px">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }</p>
<p style="margin: 0px">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }</p>
<p style="margin: 0px">&nbsp;</p>
<p style="margin: 0px">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color: gray">///</span><span style="color: green"> </span><span style="color: gray">&lt;summary&gt;</span></p>
<p style="margin: 0px">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color: gray">///</span><span style="color: green"> Saves the current component configuration into the property bag</span></p>
<p style="margin: 0px">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color: gray">///</span><span style="color: green"> </span><span style="color: gray">&lt;/summary&gt;</span></p>
<p style="margin: 0px">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color: gray">///</span><span style="color: green"> </span><span style="color: gray">&lt;param name=&#8221;pb&#8221;&gt;</span><span style="color: green">Configuration property bag</span><span style="color: gray">&lt;/param&gt;</span></p>
<p style="margin: 0px">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color: gray">///</span><span style="color: green"> </span><span style="color: gray">&lt;param name=&#8221;fClearDirty&#8221;&gt;</span><span style="color: green">not used</span><span style="color: gray">&lt;/param&gt;</span></p>
<p style="margin: 0px">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color: gray">///</span><span style="color: green"> </span><span style="color: gray">&lt;param name=&#8221;fSaveAllProperties&#8221;&gt;</span><span style="color: green">not used</span><span style="color: gray">&lt;/param&gt;</span></p>
<p style="margin: 0px">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color: blue">public</span> <span style="color: blue">virtual</span> <span style="color: blue">void</span> Save(Microsoft.BizTalk.Component.Interop.<span style="color: teal">IPropertyBag</span> pb, </p>
<p style="margin: 0px"><span style="color: blue">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; bool</span> fClearDirty, <span style="color: blue">bool</span> fSaveAllProperties)</p>
<p style="margin: 0px">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; {</p>
<p style="margin: 0px">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color: blue">this</span>.WritePropertyBag(pb, <span style="color: maroon">&#8220;path&#8221;</span>, <span style="color: blue">this</span>.path);</p>
<p style="margin: 0px">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color: blue">this</span>.WritePropertyBag(pb, <span style="color: maroon">&#8220;IsActive&#8221;</span>, <span style="color: blue">this</span>.IsActive);</p>
<p style="margin: 0px">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp; </p>
<p style="margin: 0px"><span style="color: blue">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; #endregion</span></p>
</div>
<p>
<ul>Note: the guid in this example should be replaced by your custom derived value (see the <a href="http://www.blogbiztalk.com/?p=38">first post</a> of this series)</ul>
</p>
<p>&nbsp;The last part of the interface we need to implement is the <strong>Microsoft.BizTalk.Component.Interop.IComponent </strong>interface. We just need to define one method &#8211; <strong>Execute</strong> -&nbsp;which is called by the pipeline&nbsp;to process the input message and get the resulting message.&nbsp;The method&nbsp;accepts the <strong>current pipeline context </strong>and the <strong>message to process</strong>, and it returns the&nbsp;modified (or not)&nbsp;message. </p>
<p>
<div style="font-size: 10pt;color: black;font-family: consolas">
<p style="margin: 0px"><span style="color: blue">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; #region</span> IComponent members</p>
<p style="margin: 0px">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color: gray">///</span><span style="color: green"> </span><span style="color: gray">&lt;summary&gt;</span></p>
<p style="margin: 0px">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color: gray">///</span><span style="color: green"> Implements IComponent.Execute method.</span></p>
<p style="margin: 0px">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color: gray">///</span><span style="color: green"> </span><span style="color: gray">&lt;/summary&gt;</span></p>
<p style="margin: 0px">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color: gray">///</span><span style="color: green"> </span><span style="color: gray">&lt;param name=&#8221;pc&#8221;&gt;</span><span style="color: green">Pipeline context</span><span style="color: gray">&lt;/param&gt;</span></p>
<p style="margin: 0px">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color: gray">///</span><span style="color: green"> </span><span style="color: gray">&lt;param name=&#8221;inmsg&#8221;&gt;</span><span style="color: green">Input message</span><span style="color: gray">&lt;/param&gt;</span></p>
<p style="margin: 0px">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color: gray">///</span><span style="color: green"> </span><span style="color: gray">&lt;returns&gt;</span><span style="color: green">Original input message</span><span style="color: gray">&lt;/returns&gt;</span></p>
<p style="margin: 0px">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color: gray">///</span><span style="color: green"> </span><span style="color: gray">&lt;remarks&gt;</span></p>
<p style="margin: 0px">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color: gray">///</span><span style="color: green"> IComponent.Execute method is used to initiate</span></p>
<p style="margin: 0px">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color: gray">///</span><span style="color: green"> the processing of the message in this pipeline component.</span></p>
<p style="margin: 0px">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color: gray">///</span><span style="color: green"> </span><span style="color: gray">&lt;/remarks&gt;</span></p>
<p style="margin: 0px">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color: blue">public</span> Microsoft.BizTalk.Message.Interop.<span style="color: teal">IBaseMessage</span> Execute(</p>
<p style="margin: 0px">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Microsoft.BizTalk.Component.Interop.<span style="color: teal">IPipelineContext</span> pc,</p>
<p style="margin: 0px">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Microsoft.BizTalk.Message.Interop.<span style="color: teal">IBaseMessage</span> inmsg)</p>
<p style="margin: 0px">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; {</p>
<p style="margin: 0px">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color: green">// </span></p>
<p style="margin: 0px">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color: green">// TODO: implement component logic</span></p>
<p style="margin: 0px">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color: green">// </span></p>
<p style="margin: 0px">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color: green">// this way, it&#8217;s a passthrough pipeline component</span></p>
<p style="margin: 0px">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color: blue">return</span> inmsg;</p>
<p style="margin: 0px">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }</p>
<p style="margin: 0px"><span style="color: blue">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; #endregion</span></p>
</div>
<p>For now, we will not add the actual &#8220;archive&#8221;&nbsp;code &#8211; that comes in the next post. We will just return the same message&nbsp;passed in. The reader should be able to compile this class and generate a DLL.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.tallan.com/2006/11/22/custom-pipeline-components-part-2-archive-same-continued/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Custom Pipeline Components &#8211; part 1: Getting Started</title>
		<link>http://blog.tallan.com/2006/11/21/custom-pipeline-components-part-1-getting-started/</link>
		<comments>http://blog.tallan.com/2006/11/21/custom-pipeline-components-part-1-getting-started/#comments</comments>
		<pubDate>Tue, 21 Nov 2006 23:29:23 +0000</pubDate>
		<dc:creator>Andrew Babiec</dc:creator>
				<category><![CDATA[BizTalk]]></category>

		<guid isPermaLink="false">http://www.blogbiztalk.com/?p=38</guid>
		<description><![CDATA[This is the first post in a series on how to develop custom pipelines and incorporate advanced functionality. The final example will allow the reader to incorporate PGP decryption on the receive sid and encryption on the send ports. 
A custom pipeline component is just a plain .NET class that implements several BizTalk interfaces. I [...]]]></description>
			<content:encoded><![CDATA[<p>This is the first post in a series on how to develop custom pipelines and incorporate advanced functionality. The final example will allow the reader to incorporate PGP decryption on the receive sid and encryption on the send ports. </p>
<p>A custom pipeline component is just a plain .NET class that implements several BizTalk interfaces. I recommend creating a seperate c# project to contain just your custom pipeline classes.</p>
<p>In this post, I will go through creating a sample pipeline component that archives the incoming message to the file system at the Decode stage</p>
<p>To get started, create a standard C#&nbsp;Class Library project.</p>
<ul>Add references to the following:
<li>Microsoft.BizTalk.Messaging (C:\Program Files\Microsoft BizTalk Server 2006\Microsoft.Biztalk.Messaging.dll)
<li>Microsoft.BizTalk.Pipeline (C:\Program Files\Microsoft BizTalk Server 2006\Microsoft.BizTalk.Pipeline.dll)
<li>System
<li>System.Data
<li>System.Drawing
<li>System.XML</li>
</ul>
<p>&nbsp;Add&nbsp;your namespace and the following namespace directives&#8230;</p>
<div style="font-size: 10pt;background: white;color: black;font-family: consolas">
<p style="margin: 0px"><span style="color: blue">namespace</span> Tallan.BlogBizTalk.PipelineComponent</p>
<p style="margin: 0px">{</p>
<p style="margin: 0px">&nbsp;&nbsp;&nbsp; <span style="color: blue">using</span> System;</p>
<p style="margin: 0px">&nbsp;&nbsp;&nbsp; <span style="color: blue">using</span> System.IO;</p>
<p style="margin: 0px">&nbsp;&nbsp;&nbsp; <span style="color: blue">using</span> System.Text;</p>
<p style="margin: 0px">&nbsp;&nbsp;&nbsp; <span style="color: blue">using</span> System.Drawing;</p>
<p style="margin: 0px">&nbsp;&nbsp;&nbsp; <span style="color: blue">using</span> System.Resources;</p>
<p style="margin: 0px">&nbsp;&nbsp;&nbsp; <span style="color: blue">using</span> System.Reflection;</p>
<p style="margin: 0px">&nbsp;&nbsp;&nbsp; <span style="color: blue">using</span> System.Diagnostics;</p>
<p style="margin: 0px">&nbsp;&nbsp;&nbsp; <span style="color: blue">using</span> System.Collections;</p>
<p style="margin: 0px">&nbsp;&nbsp;&nbsp; <span style="color: blue">using</span> System.ComponentModel;</p>
<p style="margin: 0px">&nbsp;&nbsp;&nbsp; <span style="color: blue">using</span> Microsoft.BizTalk.Message.Interop;</p>
<p style="margin: 0px">&nbsp;&nbsp;&nbsp; <span style="color: blue">using</span> Microsoft.BizTalk.Component.Interop;</p>
<p style="margin: 0px">&nbsp;&nbsp;&nbsp; <span style="color: blue">using</span> Microsoft.BizTalk.Component;</p>
<p style="margin: 0px">&nbsp;&nbsp;&nbsp; <span style="color: blue">using</span> Microsoft.BizTalk.Messaging;</p>
</div>
<p>&nbsp;</p>
<p>Add the class name and the following attributes. Note that you should replace the guid value with a value generated for your class</p>
<div style="font-size: 10pt;background: white;color: black;font-family: consolas">
<p style="margin: 0px">[<span style="color: teal">ComponentCategory</span>(<span style="color: teal">CategoryTypes</span>.CATID_PipelineComponent)]</p>
<p style="margin: 0px">[System.Runtime.InteropServices.<span style="color: teal">Guid</span>(<span style="color: maroon">"f5f5337f-593f-4618-8e35-dff308dbb6f5"</span>)]</p>
<p style="margin: 0px">[<span style="color: teal">ComponentCategory</span>(<span style="color: teal">CategoryTypes</span>.CATID_Decoder)]</p>
<p style="margin: 0px"><span style="color: blue">public</span> <span style="color: blue">class</span> <span style="color: teal">MyArchivePipelineComponent </span>:</p>
<p style="margin: 0px">&nbsp; Microsoft.BizTalk.Component.Interop.<span style="color: teal">IComponent</span>,<span style="color: teal">IBaseComponent</span>, </p>
<p style="margin: 0px">&nbsp;&nbsp;<span style="color: teal">IPersistPropertyBag</span>,<span style="color: teal">&nbsp;&nbsp; IComponentUI</span></p>
<p style="margin: 0px">&nbsp;&nbsp;&nbsp; {</p>
</div>
<p>&nbsp;</p>
<ul>Note that the class implements the following interfaces:
<li><strong>Microsoft.BizTalk.Component.Interop.IComponent </strong>- All pipeline components except assemblers and disassemblers implement this interface to get messages from the BizTalk Server engine for processing and to pass processed messages back to the engine.<br />NOTE: this needs to be a fully qualified reference, otherwise it will cause a compiler error: &#8216;IComponent&#8217; is an ambiguous reference between &#8216;System.ComponentModel.IComponent&#8217; and &#8216;Microsoft.BizTalk.Component.Interop.IComponent&#8217;
<li><strong>IBaseComponent</strong> &#8211; All pipeline components need to implement this interface to provide basic information about the component.
<li><strong>IPersistPropertyBag</strong> &#8211; &nbsp;Pipeline components need to implement this interface to receive its configuration information.
<li><strong>IComponentUI</strong> &#8211; Pipeline components must implement this interface to be used within the Pipeline Designer environment.</li>
</ul>
<p>The archive component has two properties: an <strong>archive folder location</strong> (set as a string)&nbsp;and a boolean&nbsp;to indicate whether the archive component is turned on.&nbsp;</p>
<div style="font-size: 10pt;background: white;color: black;font-family: consolas">
<p style="margin: 0px">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color: blue">private</span> <span style="color: blue">string</span> _path;</p>
<p style="margin: 0px">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="color: blue">public</span> <span style="color: blue">string</span> path</p>
<p style="margin: 0px">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; {</p>
<p style="margin: 0px">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color: blue">get</span> {&nbsp; <span style="color: blue">return</span> _path;&nbsp;&nbsp;&nbsp; }</p>
<p style="margin: 0px">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color: blue">set</span> {&nbsp; _path = <span style="color: blue">value</span>;&nbsp;&nbsp; }</p>
<p style="margin: 0px">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }</p>
<p style="margin: 0px">&nbsp;</p>
<p style="margin: 0px">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color: blue">private</span> <span style="color: blue">bool</span> _IsActive;&nbsp;</p>
<p style="margin: 0px">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color: blue">public</span> <span style="color: blue">bool</span> IsActive</p>
<p style="margin: 0px">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; {</p>
<p style="margin: 0px">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color: blue">get</span> { <span style="color: blue">return</span> _IsActive;&nbsp; }</p>
<p style="margin: 0px">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color: blue">set</span> { _IsActive = <span style="color: blue">value</span>; }</p>
<p style="margin: 0px">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }</p>
</div>
<p>&nbsp;</p>
<p>&nbsp;The following properties are required to implement the <strong>IBaseComponent</strong> interface. Basically,&nbsp;the name, version and description of the component returned as string.</p>
<div style="font-size: 10pt;background: white;color: black;font-family: consolas">
<p style="margin: 0px"><span style="color: blue">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; #region</span> IBaseComponent members</p>
<p style="margin: 0px">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color: gray">///</span><span style="color: green"> </span><span style="color: gray">&lt;summary&gt;</span></p>
<p style="margin: 0px">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color: gray">///</span><span style="color: green"> Name of the component</span></p>
<p style="margin: 0px">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color: gray">///</span><span style="color: green"> </span><span style="color: gray">&lt;/summary&gt;</span></p>
<p style="margin: 0px">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; [<span style="color: teal">Browsable</span>(<span style="color: blue">false</span>)]</p>
<p style="margin: 0px">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color: blue">public</span> <span style="color: blue">string</span> Name</p>
<p style="margin: 0px">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; {</p>
<p style="margin: 0px">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color: blue">get</span> { <span style="color: blue">return</span> &#8220;MyComponentName&#8221;;&nbsp; }</p>
<p style="margin: 0px">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }</p>
<p style="margin: 0px">&nbsp;</p>
<p style="margin: 0px">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color: gray">///</span><span style="color: green"> </span><span style="color: gray">&lt;summary&gt;</span></p>
<p style="margin: 0px">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color: gray">///</span><span style="color: green"> Version of the component</span></p>
<p style="margin: 0px">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color: gray">///</span><span style="color: green"> </span><span style="color: gray">&lt;/summary&gt;</span></p>
<p style="margin: 0px">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; [<span style="color: teal">Browsable</span>(<span style="color: blue">false</span>)]</p>
<p style="margin: 0px">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color: blue">public</span> <span style="color: blue">string</span> Version</p>
<p style="margin: 0px">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; {</p>
<p style="margin: 0px">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color: blue">get</span> { <span style="color: blue">return</span> &#8220;1.0&#8243;; }</p>
<p style="margin: 0px">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }</p>
<p style="margin: 0px">&nbsp;</p>
<p style="margin: 0px">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color: gray">///</span><span style="color: green"> </span><span style="color: gray">&lt;summary&gt;</span></p>
<p style="margin: 0px">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color: gray">///</span><span style="color: green"> Description of the component</span></p>
<p style="margin: 0px">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color: gray">///</span><span style="color: green"> </span><span style="color: gray">&lt;/summary&gt;</span></p>
<p style="margin: 0px">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; [<span style="color: teal">Browsable</span>(<span style="color: blue">false</span>)]</p>
<p style="margin: 0px">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color: blue">public</span> <span style="color: blue">string</span> Description</p>
<p style="margin: 0px">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; { </p>
<p style="margin: 0px">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color: blue">get</span> {&nbsp; <span style="color: blue">return</span> &#8220;Sample of a custom&nbsp;pipeline component&#8221;;&nbsp; }</p>
<p style="margin: 0px">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }</p>
<p style="margin: 0px"><span style="color: blue">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; #endregion</span></p>
</div>
<p>&nbsp;</p>
<p>Another alternative to hard-coding the strings is to use a resource file&nbsp;(.resx)&nbsp;by adding a new class member&#8230;</p>
<div style="font-size: 10pt;background: white;color: black;font-family: consolas">
<p style="margin: 0px"><span style="color: blue">private</span> System.Resources.<span style="color: teal">ResourceManager</span> resManager = </p>
<p style="margin: 0px"><span style="color: blue">&nbsp;&nbsp;&nbsp; new</span> System.Resources.<span style="color: teal">ResourceManager</span>(<span style="color: maroon">&#8220;Tallan.BlogBizTalk.PipelineComponent.MyArchivePipelineComponent&#8221;</span>, </p>
<p style="margin: 0px">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color: teal">Assembly</span>.GetExecutingAssembly());</p>
</div>
<p>And replacing <strong>return &#8220;string&#8221;</strong> with</p>
<p>
<div style="font-size: 10pt;background: white;color: black;font-family: consolas">
<p style="margin: 0px"><span style="color: blue">return</span> resManager.GetString(<span style="color: maroon">&#8220;COMPONENTNAME&#8221;</span>,</p>
<p style="margin: 0px">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; System.Globalization.<span style="color: teal">CultureInfo</span>.InvariantCulture);&nbsp;</p>
</div>
<p>&nbsp;</p>
<p>Now, we will implement the&nbsp;<strong>ComponentUI</strong> interface. This consists of an icon property and a method called Validate. Validate is called by the compiler to verify all of the configuration properties are set correctly.&nbsp; For now, to indicate&nbsp;successful property validation, the method should return an empty enumerator.</p>
<p>
<div style="font-size: 10pt;background: white;color: black;font-family: consolas">
<p style="margin: 0px"><span style="color: blue">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; #region</span> IComponentUI members</p>
<p style="margin: 0px">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color: gray">///</span><span style="color: green"> </span><span style="color: gray">&lt;summary&gt;</span></p>
<p style="margin: 0px">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color: gray">///</span><span style="color: green"> Component icon to use in BizTalk Editor</span></p>
<p style="margin: 0px">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color: gray">///</span><span style="color: green"> </span><span style="color: gray">&lt;/summary&gt;</span></p>
<p style="margin: 0px">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; [<span style="color: teal">Browsable</span>(<span style="color: blue">false</span>)]</p>
<p style="margin: 0px">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color: blue">public</span> <span style="color: teal">IntPtr</span> Icon</p>
<p style="margin: 0px">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; {</p>
<p style="margin: 0px">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color: blue">get</span></p>
<p style="margin: 0px">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; {</p>
<p style="margin: 0px">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color: blue">return</span> ((System.Drawing.<span style="color: teal">Bitmap</span>)(<span style="color: blue">this</span>.res.GetObject(<span style="color: maroon">&#8220;COMPONENTICON&#8221;</span>, System.Globalization.<span style="color: teal">CultureInfo</span>.InvariantCulture))).GetHicon();</p>
<p style="margin: 0px">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }</p>
<p style="margin: 0px">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }</p>
<p style="margin: 0px">&nbsp;</p>
<p style="margin: 0px">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color: gray">///</span><span style="color: green"> </span><span style="color: gray">&lt;summary&gt;</span></p>
<p style="margin: 0px">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color: gray">///</span><span style="color: green"> The Validate method is called by the BizTalk Editor during the build </span></p>
<p style="margin: 0px">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color: gray">///</span><span style="color: green"> of a BizTalk project.</span></p>
<p style="margin: 0px">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color: gray">///</span><span style="color: green"> </span><span style="color: gray">&lt;/summary&gt;</span></p>
<p style="margin: 0px">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color: gray">///</span><span style="color: green"> </span><span style="color: gray">&lt;param name=&#8221;obj&#8221;&gt;</span><span style="color: green">An Object containing the configuration properties</span><span style="color: gray">&lt;/param&gt;</span></p>
<p style="margin: 0px">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color: gray">///</span><span style="color: green"> </span><span style="color: gray">&lt;returns&gt;</span><span style="color: green">The IEnumerator enables the caller to enumerate through a collection of strings containing error messages. These error messages appear as compiler error messages. To report successful property validation, the method should return an empty enumerator.</span><span style="color: gray">&lt;/returns&gt;</span></p>
<p style="margin: 0px">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color: blue">public</span> System.Collections.<span style="color: teal">IEnumerator</span> Validate(<span style="color: blue">object</span> obj)</p>
<p style="margin: 0px">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; {</p>
<p style="margin: 0px">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color: green">// example implementation:</span></p>
<p style="margin: 0px">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color: green">// ArrayList errorList = new ArrayList();</span></p>
<p style="margin: 0px">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color: green">// errorList.Add(&#8220;This is a compiler error&#8221;);</span></p>
<p style="margin: 0px">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color: green">// return errorList.GetEnumerator();</span></p>
<p style="margin: 0px">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color: blue">return</span> <span style="color: blue">null</span>;</p>
<p style="margin: 0px">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }</p>
<p style="margin: 0px"><span style="color: blue">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; #endregion</span></p>
</div>
<p>This ends the first part of the Custom Pipeline Components posts. This is continued in part two.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.tallan.com/2006/11/21/custom-pipeline-components-part-1-getting-started/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Passwords &amp; BizTalk</title>
		<link>http://blog.tallan.com/2006/09/27/passwords-biztalk/</link>
		<comments>http://blog.tallan.com/2006/09/27/passwords-biztalk/#comments</comments>
		<pubDate>Wed, 27 Sep 2006 20:03:46 +0000</pubDate>
		<dc:creator>Andrew Babiec</dc:creator>
				<category><![CDATA[BizTalk]]></category>

		<guid isPermaLink="false">http://www.blogbiztalk.com/?p=24</guid>
		<description><![CDATA[Even with all the time I have spent with BizTalk 2004 and 2006, there is one thing that I will occasionally get tripped on &#8211; the fact that exported Bindings and Configuration files do not contain passwords.
For security purposes, BizTalk never shows the existing values of any passwords &#8211; whether those passwords are entered during configuration, setting up [...]]]></description>
			<content:encoded><![CDATA[<p>Even with all the time I have spent with BizTalk 2004 and 2006, there is one thing that I will occasionally get tripped on &#8211; the fact that exported Bindings and Configuration files do not contain passwords.</p>
<p>For security purposes, BizTalk never shows the existing values of any passwords &#8211; whether those passwords are entered during configuration, setting up SQL or FTP adapters, etc. Instead all the user will see is *************  (the # of asterisks does not correspond to the length of the password).</p>
<p>So if you export bindings to &#8220;save a copy&#8221; of the current configuration, don&#8217;t forget to track the passwords somewhere. One approach is to edit the exported files and fill in the empty password fields, but this should only be done if you can ensure the xml binding files will be tightly secured.</p>
<p>Here is an example of the password output for a SQL Server database connection. Just replace the stars with your real password&#8230;</p>
<p><a href="http://blogs.tallan.com/biztalk/files/2006/09/WindowsLiveWriter/PasswordsBizTalk_13320/clip_image001%5B5%5D.gif"><img height="82" src="http://blogs.tallan.com/biztalk/files/2006/09/WindowsLiveWriter/PasswordsBizTalk_13320/clip_image001%5B5%5D%5B1%5D%5B1%5D%5B3%5D.gif" width="419" border="0" /></a></p>
<p>(BTW, this post has another purpose &#8211; to test the blog post capabilities of Live Writer, including uploading images)</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.tallan.com/2006/09/27/passwords-biztalk/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

