
<?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>merill.net &#187; .NET</title>
	<atom:link href="http://merill.net/category/net/feed/" rel="self" type="application/rss+xml" />
	<link>http://merill.net</link>
	<description>My utmost for His highest, my best for His glory</description>
	<lastBuildDate>Thu, 02 Feb 2012 21:02:26 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>Generating a mock/stub WCF web service from a WSDL</title>
		<link>http://merill.net/2011/08/generating-a-mockstub-wcf-web-service-from-a-wsdl/</link>
		<comments>http://merill.net/2011/08/generating-a-mockstub-wcf-web-service-from-a-wsdl/#comments</comments>
		<pubDate>Mon, 01 Aug 2011 22:29:14 +0000</pubDate>
		<dc:creator>Merill Fernando</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[wcf]]></category>
		<category><![CDATA[wsdl]]></category>

		<guid isPermaLink="false">http://merill.net/?p=732</guid>
		<description><![CDATA[When working on integration projects you sometimes need to build a stub or mock service to emulate the behavior of the targeted system in your dev environment. Visual Studio&#8217;s Add Service Reference dialog provides an easy way for generating the client code based on the WSDL of the service that you are invoking. Unfortunately there [...]]]></description>
			<content:encoded><![CDATA[<p>When working on integration projects you sometimes need to build a stub or mock service to emulate the behavior of the targeted system in your dev environment.</p>
<p>Visual Studio&#8217;s Add Service Reference dialog provides an easy way for generating the client code based on the WSDL of the service that you are invoking. Unfortunately there is no such dialog to generate a server side stub / mock.</p>
<p>There are various approaches you can take here but using svcutil.exe has been the most pain-free for me. </p>
<p>Here&#8217;s an example of how to go about it:<br />
<code>svcutil /mc UserService.wsdl UserTypes.xsd</code></p>
<p>The /mc parameter generates a class file with all the data types defined in the .xsd as well as the interfaces for all the operations defined in the WSDL. It also provides you with a starter .config file that you&#8217;ll then need to tweak to define the port on which the service is going to be hosted.</p>
<p>Once you have these files create a new WCF Service Library project, add the generated class files. Then create an implementation class that implements the interfaces that is generated. To keep things simple you might want to write code for just the operations that your calling from the client side.</p>
<p>Now here&#8217;s a gotcha for those stubbing out a service generated by Oracle WebLogic. The Action (SOAP Action) attribute on the operations are sometimes the same for all the operations in the interface. WCF doesn&#8217;t support this since it doesn&#8217;t conform to the WSDL specifications. You&#8217;ll easily know that you&#8217;ve hit this issue when you get the following exception when trying to host your stubbed service.</p>
<p><code>System.InvalidOperationException: The operations xxx and yyy have the same action ().  Every operation must have a unique action value.<br />
   at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ActionDemuxer.Add(String action, DispatchOperationRuntime operation)<br />
   at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime..ctor(DispatchRuntime dispatch)<br />
   at System.ServiceModel.Dispatcher.DispatchRuntime.GetRuntimeCore()<br />
   at System.ServiceModel.Dispatcher.ChannelDispatcher.OnOpened()<br />
   at System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout)<br />
   at System.ServiceModel.ServiceHostBase.OnOpen(TimeSpan timeout)<br />
   at System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout)<br />
   at Microsoft.Tools.SvcHost.ServiceHostHelper.OpenService(ServiceInfo info)<br />
</code></p>
<p>To overcome this you can create a custom Dispatch Behavior that uses an alternate algorithm to assign incoming messages to operations. The <a href="http://msdn.microsoft.com/en-us/library/aa395223.aspx">Dispatch by Body Element</a> WCF sample comes with a sample implementation that works well. </p>
<p>All you need to do is add the two class files in this zip file (it&#8217;s the same code that comes with the WCF samples) <a href='http://merill.net/wp-content/uploads/2011/08/Contracts.zip'>DispatchByBodyBehavior</a></p>
<p>Next open up the class generated by svcutil and add the DispatchByBodyBehavior attribute to the ServiceContractInterface. You should now be able to host the service in WCF without any issues.</p>
<p><code>[ServiceContract(Namespace="http://Microsoft.ServiceModel.Samples"),<br />
                            <strong>DispatchByBodyElementBehavior</strong>]<br />
public interface IDispatchedByBody<br />
{<br />
    [OperationContract(ReplyAction="*"),<br />
     DispatchBodyElement("bodyA","http://tempuri.org")]<br />
    Message OperationForBodyA(Message msg);<br />
    [OperationContract(ReplyAction = "*"),<br />
     DispatchBodyElement("bodyB", "http://tempuri.org")]<br />
    Message OperationForBodyB(Message msg);<br />
    [OperationContract(Action="*", ReplyAction="*")]<br />
    Message DefaultOperation(Message msg);<br />
}</code></p>
]]></content:encoded>
			<wfw:commentRss>http://merill.net/2011/08/generating-a-mockstub-wcf-web-service-from-a-wsdl/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Updating Extended Properties of a Database using SQL Server SMO</title>
		<link>http://merill.net/2010/06/updating-extended-properties-of-a-database-using-sql-server-smo/</link>
		<comments>http://merill.net/2010/06/updating-extended-properties-of-a-database-using-sql-server-smo/#comments</comments>
		<pubDate>Wed, 23 Jun 2010 01:28:01 +0000</pubDate>
		<dc:creator>Merill Fernando</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[smo]]></category>
		<category><![CDATA[SQL]]></category>

		<guid isPermaLink="false">http://merill.net/?p=710</guid>
		<description><![CDATA[Updating the extended properties on a database using SQL Server&#8217;s excellent Server Management Objects API is not as straightforward as setting the value and calling update. The database.Alter() method needs to be called both before and after updating the value. I had to lookup the code of El Pluto&#8216;s awesome SQL Server Extended Properties Quick [...]]]></description>
			<content:encoded><![CDATA[<p>Updating the extended properties on a database using SQL Server&#8217;s excellent <a href="http://msdn.microsoft.com/en-us/library/ms162169.aspx">Server Management Objects</a> API is not as straightforward as setting the value and calling update.</p>
<p>The database.Alter() method needs to be called both before and after updating the value. I had to lookup the code of <a href="http://blog.elpluto.com/">El Pluto</a>&#8216;s awesome <a href="http://xqued.codeplex.com/">SQL Server Extended Properties Quick Editor</a> project on CodePlex to figure this out.</p>
<div style="color: black; background: white; font-family: Consolas; font-size: 10pt;">
<pre style="margin: 0px;"><span style="color: blue;">using</span> Microsoft.SqlServer.Management.Smo;</pre>
<pre style="margin: 0px;">&nbsp;</pre>
<pre style="margin: 0px;"><span style="color: gray;">///</span><span style="color: green;"> </span><span style="color: gray;">&lt;summary&gt;</span></pre>
<pre style="margin: 0px;"><span style="color: gray;">///</span><span style="color: green;"> Set's the extended property of a database.</span></pre>
<pre style="margin: 0px;"><span style="color: gray;">///</span><span style="color: green;"> </span><span style="color: gray;">&lt;/summary&gt;</span></pre>
<pre style="margin: 0px;"><span style="color: gray;">///</span><span style="color: green;"> </span><span style="color: gray;">&lt;param name=&quot;serverName&quot;&gt;</span><span style="color: green;">The name of the SQL Server.</span><span style="color: gray;">&lt;/param&gt;</span></pre>
<pre style="margin: 0px;"><span style="color: gray;">///</span><span style="color: green;"> </span><span style="color: gray;">&lt;param name=&quot;databaseName&quot;&gt;</span><span style="color: green;">The name of the database.</span><span style="color: gray;">&lt;/param&gt;</span></pre>
<pre style="margin: 0px;"><span style="color: gray;">///</span><span style="color: green;"> </span><span style="color: gray;">&lt;param name=&quot;propertyName&quot;&gt;</span><span style="color: green;">The name of the extended property.</span><span style="color: gray;">&lt;/param&gt;</span></pre>
<pre style="margin: 0px;"><span style="color: gray;">///</span><span style="color: green;"> </span><span style="color: gray;">&lt;param name=&quot;value&quot;&gt;</span><span style="color: green;">The value of the extended property.</span><span style="color: gray;">&lt;/param&gt;</span></pre>
<pre style="margin: 0px;"><span style="color: blue;">private</span> <span style="color: blue;">void</span> SetExtendedProperty(<span style="color: blue;">string</span> serverName, <span style="color: blue;">string</span> </pre>
<pre style="margin: 0px;">&nbsp;&nbsp;&nbsp; databaseName, <span style="color: blue;">string</span> propertyName, <span style="color: blue;">string</span> value)</pre>
<pre style="margin: 0px;">{</pre>
<pre style="margin: 0px;">&nbsp;&nbsp;&nbsp; <span style="color: blue;">var</span> server = <span style="color: blue;">new</span> <span style="color: #2b91af;">Server</span>(serverName);</pre>
<pre style="margin: 0px;">&nbsp;&nbsp;&nbsp; <span style="color: blue;">var</span> database = server.Databases[databaseName];</pre>
<pre style="margin: 0px;">&nbsp;</pre>
<pre style="margin: 0px;">&nbsp;&nbsp;&nbsp; database.Alter();</pre>
<pre style="margin: 0px;">&nbsp;&nbsp;&nbsp; <span style="color: blue;">if</span> (!database.ExtendedProperties.Contains(propertyName))</pre>
<pre style="margin: 0px;">&nbsp;&nbsp;&nbsp; {</pre>
<pre style="margin: 0px;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; database.ExtendedProperties.Add(</pre>
<pre style="margin: 0px;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color: blue;">new</span> <span style="color: #2b91af;">ExtendedProperty</span>(database, propertyName, value));</pre>
<pre style="margin: 0px;">&nbsp;&nbsp;&nbsp; }</pre>
<pre style="margin: 0px;">&nbsp;&nbsp;&nbsp; <span style="color: blue;">else</span></pre>
<pre style="margin: 0px;">&nbsp;&nbsp;&nbsp; {</pre>
<pre style="margin: 0px;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; database.ExtendedProperties[propertyName].Value = value;</pre>
<pre style="margin: 0px;">&nbsp;&nbsp;&nbsp; }</pre>
<pre style="margin: 0px;">&nbsp;&nbsp;&nbsp; database.Alter();</pre>
<pre style="margin: 0px;">}</pre>
<pre style="margin: 0px;">&nbsp;</pre>
</div>
]]></content:encoded>
			<wfw:commentRss>http://merill.net/2010/06/updating-extended-properties-of-a-database-using-sql-server-smo/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Dynamically setting multiple activity destinations in K2 with ASP .NET</title>
		<link>http://merill.net/2010/06/dynamically-setting-multiple-activity-destinations-in-k2-with-asp-net/</link>
		<comments>http://merill.net/2010/06/dynamically-setting-multiple-activity-destinations-in-k2-with-asp-net/#comments</comments>
		<pubDate>Thu, 17 Jun 2010 04:18:42 +0000</pubDate>
		<dc:creator>Merill Fernando</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[destinations]]></category>
		<category><![CDATA[infopath]]></category>
		<category><![CDATA[k2]]></category>
		<category><![CDATA[workflow]]></category>

		<guid isPermaLink="false">http://merill.net/?p=690</guid>
		<description><![CDATA[When building a typical workflow you usually know which user or group needs to perform an activity at design time. Sometimes though the workflow needs to be more dynamic. The issue I had to resolve recently involved having to build a workflow where the end-user gets to individually pick the users who will be performing [...]]]></description>
			<content:encoded><![CDATA[<p>When building a typical workflow you usually know which user or group needs to perform an activity at design time. Sometimes though the workflow needs to be more dynamic.</p>
<p>The issue I had to resolve recently involved having to build a workflow where the end-user gets to individually pick the users who will be performing the next step. Here&#8217;s a view of  the workflow design.</p>
<p><a href="http://merill.net/wp-content/uploads/2010/06/K2-Multiple-Destination-Workflow.png"><img class="alignnone size-full wp-image-691" title="K2 Multiple=" src="http://merill.net/wp-content/uploads/2010/06/K2-Multiple-Destination-Workflow.png" alt="" width="696" height="478" /></a></p>
<p>The scenario involved an application being submitted for review. The application would go to an individual who is responsible for assigning a group of users (destination users) to review the application. The twist was that it was the individual picking users for each application, it wasn&#8217;t a fixed group or role. The screen mockup shows how they do it.</p>
<p>When the person hits the &#8216;Assign Reviewers&#8217; button the form then needs to turn up as a work list item for each of the reviewers (destination users) who get to review the application in parallel.</p>
<p>Implementing this process using K2/InfoPath is quite straightforward and is well documented in many places including this post titled &#8216;<a href="http://www.k2underground.com/blogs/fromthebench/archive/2008/05/22/activity-destination-users-based-upon-a-repeating-xml-element.aspx">Activity Destination Users based upon a Repeating XML element</a>&#8216; in a K2 underground blog.</p>
<p>It&#8217;s not well documented though for ASP.NET. The post &#8216;<a href="http://www.k2underground.com/blogs/fromthebench/archive/2009/08/18/how-to-use-a-web-service-for-destinations-in-k2-blackpoint.aspx?CommentPosted=true#commentmessage">How To: Use a web service for destinations in K2 blackpoint</a>&#8216; is close to what we want but it&#8217;s targeted at using a web service.</p>
<p>K2 let&#8217;s you set multiple destination users in one of two ways</p>
<p>1. Using a SmartObject method in a role</p>
<p>2. Using Xml as a destination set</p>
<p>Going the SmartObject route was a lot of work for my simple requirement so I chose the Xml method. The idea here is to use the list of users in the Assign Reviewers form and store them in a Process xml field. The destination set will then be configured to read the xml field and create a slot for each user.</p>
<p>FYI: See page 4 of the <a href="http://help.k2.com/en/AdvancedDestinations_Whitepaper.aspx">Advanced Destinations whitepaper</a> for a description of the two roles. &lt;rant&gt;Why the K2 KB portal needs a login is beyond me.&lt;/rant&gt;</p>
<p><strong>Step 1: Write the code to create the xml containing the list of users</strong></p>
<p>The code block below accepts a ; delimited list of domain name\username (e.g. domain\johna) and creates an XML document containing the list of users. This is then assigned to the Process Instance XML field called Reviewers.</p>
<div style="color: black; background: white; font-family: Consolas; font-size: 10pt;">
<pre style="margin: 0px;"><span style="color: blue;">private</span> <span style="color: blue;">static</span> <span style="color: blue;">void</span> AssignReviewers(<span style="color: #2b91af;">WorklistItem</span> item, <span style="color: blue;">string</span> listOfUsers)</pre>
<pre style="margin: 0px;">{</pre>
<pre style="margin: 0px;">    <span style="color: blue;">var</span> doc = <span style="color: blue;">new</span> <span style="color: #2b91af;">XmlDocument</span>();</pre>
<pre style="margin: 0px;">    <span style="color: blue;">var</span> root = doc.CreateElement(<span style="color: #a31515;">"UserList"</span>);</pre>
<pre style="margin: 0px;">    doc.AppendChild(root);</pre>
<pre style="margin: 0px;"></pre>
<pre style="margin: 0px;">    <span style="color: blue;">foreach</span> (<span style="color: blue;">string</span> user <span style="color: blue;">in</span> listOfUsers.Split(<span style="color: #a31515;">';'</span>))</pre>
<pre style="margin: 0px;">    {</pre>
<pre style="margin: 0px;">        <span style="color: blue;">var</span> userNode = doc.CreateElement(<span style="color: #a31515;">"Users"</span>);</pre>
<pre style="margin: 0px;">        userNode.InnerText = user;</pre>
<pre style="margin: 0px;">        root.AppendChild(userNode);</pre>
<pre style="margin: 0px;">    }</pre>
<pre style="margin: 0px;">    item.ProcessInstance.XmlFields[<span style="color: #a31515;">"Reviewers"</span>].Value = doc.OuterXml;</pre>
<pre style="margin: 0px;">}</pre>
</div>
<p><strong>Step 2: Create an xml schema based on the user list xml</strong></p>
<p>This proved to be the trickiest part for me. Using the xsd.exe as documented in this <a href="http://www.k2underground.com/blogs/fromthebench/archive/2009/08/18/how-to-use-a-web-service-for-destinations-in-k2-blackpoint.aspx">article</a> didn&#8217;t work.  After a lot of anguish I worked out that K2 was happy with the schema generated by InfoPath. So I opened an empty form in InfoPath and added a repeating text field (<a href="http://www.k2underground.com/blogs/fromthebench/archive/2008/05/22/activity-destination-users-based-upon-a-repeating-xml-element.aspx">screenshot</a>).</p>
<p>Next I exported the form to get to the .xsd (in InfoPath 2010 it is File -&gt; Publish -&gt; Export Source Files). Cleaning out the my: namespace and a bit of tweaking should give you the following schema definition. This definition should work fine with the xml produced by the above code block.</p>
<div style="color: black; background: white; font-family: Consolas; font-size: 10pt;">
<pre style="margin: 0px;"><span style="color: blue;">&lt;?</span><span style="color: #a31515;">xml</span><span style="color: blue;"> </span><span style="color: red;">version</span><span style="color: blue;">=</span>"<span style="color: blue;">1.0</span>"<span style="color: blue;"> </span><span style="color: red;">encoding</span><span style="color: blue;">=</span>"<span style="color: blue;">UTF-8</span>"<span style="color: blue;"> </span><span style="color: red;">standalone</span><span style="color: blue;">=</span>"<span style="color: blue;">no</span>"<span style="color: blue;">?&gt;</span></pre>
<pre style="margin: 0px;"><span style="color: blue;">&lt;</span><span style="color: #a31515;">xsd:schema</span><span style="color: blue;"> </span><span style="color: red;">xmlns:xsd</span><span style="color: blue;">=</span>"<span style="color: blue;">http://www.w3.org/2001/XMLSchema</span>"<span style="color: blue;">&gt;</span></pre>
<pre style="margin: 0px;"><span style="color: blue;">  &lt;</span><span style="color: #a31515;">xsd:element</span><span style="color: blue;"> </span><span style="color: red;">name</span><span style="color: blue;">=</span>"<span style="color: blue;">UserList</span>"<span style="color: blue;">&gt;</span></pre>
<pre style="margin: 0px;"><span style="color: blue;">    &lt;</span><span style="color: #a31515;">xsd:complexType</span><span style="color: blue;">&gt;</span></pre>
<pre style="margin: 0px;"><span style="color: blue;">      &lt;</span><span style="color: #a31515;">xsd:sequence</span><span style="color: blue;">&gt;</span></pre>
<pre style="margin: 0px;"><span style="color: blue;">        &lt;</span><span style="color: #a31515;">xsd:element</span><span style="color: blue;"> </span><span style="color: red;">name</span><span style="color: blue;">=</span>"<span style="color: blue;">Users</span>"<span style="color: blue;"> </span><span style="color: red;">minOccurs</span><span style="color: blue;">=</span>"<span style="color: blue;">0</span>"<span style="color: blue;"> </span><span style="color: red;">maxOccurs</span><span style="color: blue;">=</span>"<span style="color: blue;">unbounded</span>"<span style="color: blue;">/&gt;</span></pre>
<pre style="margin: 0px;"><span style="color: blue;">      &lt;/</span><span style="color: #a31515;">xsd:sequence</span><span style="color: blue;">&gt;</span></pre>
<pre style="margin: 0px;"><span style="color: blue;">    &lt;/</span><span style="color: #a31515;">xsd:complexType</span><span style="color: blue;">&gt;</span></pre>
<pre style="margin: 0px;"><span style="color: blue;">  &lt;/</span><span style="color: #a31515;">xsd:element</span><span style="color: blue;">&gt;</span></pre>
<pre style="margin: 0px;"><span style="color: blue;">&lt;/</span><span style="color: #a31515;">xsd:schema</span><span style="color: blue;">&gt;</span></pre>
</div>
<p><strong>Step 3: Create an xml field for the process</strong></p>
<p>Armed with the xml schema, we&#8217;re now ready to configure the workflow.</p>
<p>Fire up the K2 process designer and add the process xml field name <em>Reviewers</em> which we referred to in our code in step 1.</p>
<p>To do this open the Process General Properties window, expand the right panel. From the list select the Process/Activity Data node, expand it to select the name of your process and right-click on it to click Add.. and get to the Add XML Field.</p>
<p><img class="alignnone size-full wp-image-696" title="K2 Add Process Xml Field" src="http://merill.net/wp-content/uploads/2010/06/K2-Add-Process-Xml-Field.png" alt="" width="306" height="192" /></p>
<p>Name the field &#8216;Reviewers&#8217;.</p>
<p><img class="alignnone size-full wp-image-697" title="K2 Add Xml Field Dialog" src="http://merill.net/wp-content/uploads/2010/06/K2-Add-Xml-Field-Dialog.png" alt="" width="462" height="205" /></p>
<p>Switch to the XML Schema tab and browse to pick the xsd file created in Step 2.</p>
<p>When you hit OK you should now be able to drill down and see the Users node.</p>
<p><img class="alignnone size-full wp-image-698" title="K2 Xml Field Step" src="http://merill.net/wp-content/uploads/2010/06/K2-Xml-Field-Step.png" alt="" width="188" height="183" /></p>
<p>The key is to make sure that the node&#8217;s icon has a green overlay which flags it as a repeating node. If it&#8217;s there you should be fine. If not you need to repeat the steps above until you get the green overlay icon. Without it, the worklist item is not going to be assigned to multiple users.</p>
<p><strong>Step 4: Setup the destination to read from the xml field</strong></p>
<p>Select the activity which needs to be executed in parallel and click on the Destination Users node. Switch to the Advanced Mode if you are not already in there (select the checkbox on the first page). In the Destination Rule Options select Plan per destination -&gt;All at once. We do this to tell K2 that when it goes to multiple users they will be able to open and work on the item in parallel.</p>
<p><img class="alignnone size-full wp-image-703" title="K2 Setup Destination 1" src="http://merill.net/wp-content/uploads/2010/06/K2-Setup-Destination-1.png" alt="" width="560" height="281" /></p>
<p>Select &#8216;Create a slot for each destination&#8217;, this way each destination user get&#8217;s their own slot.</p>
<p><img class="alignnone size-full wp-image-704" title="K2 Setup Destination 2" src="http://merill.net/wp-content/uploads/2010/06/K2-Setup-Destination-2.png" alt="" width="543" height="328" /></p>
<p>Click on the Edit button to configure the Destination sets.</p>
<p><img class="alignnone size-full wp-image-705" title="K2 Setup Destination 3" src="http://merill.net/wp-content/uploads/2010/06/K2-Setup-Destination-3.png" alt="" width="532" height="198" /></p>
<p>Click on the ellipsis to open the Context Browser, drill down to the Process Xml field that we setup earlier and drag the Users repeating node (the one with the green icon) onto Name column.</p>
<p><img class="alignnone size-full wp-image-706" title="K2 Setup Destination 4" src="http://merill.net/wp-content/uploads/2010/06/K2-Setup-Destination-4.png" alt="" width="734" height="323" /></p>
<p>You should now be all set to test out your dynamic multiple destination users! Running through the workflow you will now see that the worklist item gets assigned to each of the reviewers in parallel.</p>
]]></content:encoded>
			<wfw:commentRss>http://merill.net/2010/06/dynamically-setting-multiple-activity-destinations-in-k2-with-asp-net/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>SharpSvn: A Primer</title>
		<link>http://merill.net/2010/03/sharpsvn-a-primer/</link>
		<comments>http://merill.net/2010/03/sharpsvn-a-primer/#comments</comments>
		<pubDate>Fri, 12 Mar 2010 00:03:14 +0000</pubDate>
		<dc:creator>Merill Fernando</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[sharpsvn]]></category>
		<category><![CDATA[subversion]]></category>
		<category><![CDATA[tortoisesvn]]></category>

		<guid isPermaLink="false">http://merill.net/2010/03/sharpsvn-a-primer/</guid>
		<description><![CDATA[The SharpSvn library basically gives you a .NET interface to all the operations that you would normally perform through a tool like TortoiseSVN. I found myself needing this exact library while writing a tool that changes files that have been checked out from SVN. The problem with manipulating files that are under SVN is that [...]]]></description>
			<content:encoded><![CDATA[<p>The SharpSvn library basically gives you a .NET interface to all the operations that you would normally perform through a tool like TortoiseSVN.</p>
<p>I found myself needing this exact library while writing a tool that changes files that have been checked out from SVN. </p>
<p>The problem with manipulating files that are under SVN is that you need to be careful about renaming files (and sometimes even deleting). If you don’t do it through the SVN api then you will end up with duplicates files/folders in SVN since SVN thinks that it’s a new file.</p>
<p>To solve this I finally got a chance to crack open the SharpSVN library which is used by my favourite AnkhSVN.</p>
<p>1. Download the latest library from <a href="http://sharpsvn.open.collab.net/">http://sharpsvn.open.collab.net/</a>. You have to pick between either 1.5 or 1.6. I went with 1.6 and didn’t run into any issues. I think this is based on the version of the SVN server that your connecting to.</p>
<p>2. In your Visual Studio project add a reference to the following assemblies.    <br />- SharpSvn.dll     <br />- SharpSvn.UI.dll (Only needed if you need the UI to prompt for login)</p>
<p>3. If like me your building on a 64 bit OS and you want your app to run on a 32 bit OS, make sure the project that references the SharpSvn.dll is set to Build for the x86 Platform. (Build –&gt; Configuration Manager – Solution Platform)</p>
<p>4. Write your code using the SvnClient object. Here are some samples from the SharpSvn Wiki and some that I wrote.</p>
<p><strong>CheckOut</strong></p>
<pre class="csharpcode"><span class="kwrd">public</span> <span class="kwrd">void</span> CheckOut()
{
  <span class="kwrd">using</span> (SvnClient client = <span class="kwrd">new</span> SvnClient())
  {
     client.CheckOut(
       <span class="kwrd">new</span> Uri(<span class="str">&quot;http://svn.collab.net/repos/svn/trunk/contrib&quot;</span>),
       <span class="str">@&quot;c:\wc&quot;</span>);
  }
}</pre>
<style type="text/css">
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }</style>
<p>Add new files to the working copy</p>
<pre class="csharpcode"><span class="kwrd">using</span>(SvnClient client = <span class="kwrd">new</span> SvnClient())
{
  SvnAddArgs args = <span class="kwrd">new</span> SvnAddArgs();
  <span class="rem">// TODO: Set optional settings on args</span>

  client.Add(<span class="str">@&quot;C:\file\in\workingcopy&quot;</span>, args);
}</pre>
<style type="text/css">
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }</style>
<p><strong>Check if a given path is a valid SVN working copy</strong></p>
<pre class="csharpcode"><span class="kwrd">public</span> <span class="kwrd">static</span> <span class="kwrd">bool</span> IsWorkingCopy(<span class="kwrd">string</span> path)
{
    <span class="kwrd">using</span> (var client = GetSvnClient())
    {
        var uri = client.GetUriFromWorkingCopy(path);

        <span class="kwrd">return</span> uri != <span class="kwrd">null</span>;
    }
}</pre>
<style type="text/css">
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }</style>
<p><strong>Find out if a particular folder/file has been marked for deletion.</strong></p>
<pre class="csharpcode"><span class="kwrd">public</span> <span class="kwrd">static</span> <span class="kwrd">bool</span> IsDeleted(<span class="kwrd">string</span> path)
{
    <span class="kwrd">if</span>(!IsWorkingCopy(path)) <span class="kwrd">return</span> <span class="kwrd">false</span>;

    <span class="kwrd">bool</span> isDeleted;
    <span class="kwrd">using</span> (var client = GetSvnClient())
    {
        Collection&lt;SvnStatusEventArgs&gt; args;
        client.GetStatus(path, <span class="kwrd">out</span> args);
        isDeleted = args.Count &gt; 0 &amp;&amp; args[0].LocalContentStatus == SvnStatus.Deleted;
    }
    <span class="kwrd">return</span> isDeleted;
}</pre>
<style type="text/css">
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }</style>
<div>&#160;</div>
<div>What’s even more awesome about the guys who wrote this library actively support it (even over twitter, thanks <a href="http://twitter.com/srijken">http://twitter.com/srijken</a>!).</div>
<div>&#160;</div>
<div>And that was even before I found out that they have a ready made .wxs file for integrating the .dlls into my WiX installer package. Awesome!</div>
]]></content:encoded>
			<wfw:commentRss>http://merill.net/2010/03/sharpsvn-a-primer/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>Love This!</title>
		<link>http://merill.net/2009/10/love-this/</link>
		<comments>http://merill.net/2009/10/love-this/#comments</comments>
		<pubDate>Thu, 22 Oct 2009 06:36:02 +0000</pubDate>
		<dc:creator>Merill Fernando</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[SharePoint]]></category>
		<category><![CDATA[visual studio]]></category>

		<guid isPermaLink="false">http://merill.net/2009/10/love-this/</guid>
		<description><![CDATA[]]></description>
			<content:encoded><![CDATA[<p><a href="http://merill.net/wp-content/uploads/2009/10/SharePointDev.png"><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="SharePointDev" border="0" alt="SharePointDev" src="http://merill.net/wp-content/uploads/2009/10/SharePointDev_thumb.png" width="630" height="484" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://merill.net/2009/10/love-this/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Automate Build for a ClickOnce Application Hosted on CodePlex using MSBuild</title>
		<link>http://merill.net/2008/10/automate-build-for-a-clickonce-application-hosted-on-codeplex-using-msbuild/</link>
		<comments>http://merill.net/2008/10/automate-build-for-a-clickonce-application-hosted-on-codeplex-using-msbuild/#comments</comments>
		<pubDate>Wed, 22 Oct 2008 08:51:20 +0000</pubDate>
		<dc:creator>Merill Fernando</dc:creator>
				<category><![CDATA[.NET]]></category>

		<guid isPermaLink="false">/post/2008/10/Automate-Build-for-a-ClickOnce-Application-Hosted-on-CodePlex-using-MSBuild.aspx</guid>
		<description><![CDATA[This is what I wanted my automated build to do: Get the latest version from CodePlex Update the version number in AssemblyInfo.cs Build the project Check-in the updated AssemblyInfo.cs Label the project with the version number Publish the ClickOnce package to my webserver In order to achieve this I used the CodePlex Source Control Client [...]]]></description>
			<content:encoded><![CDATA[<p>This is what I wanted my automated build to do:</p>
<ol>
<li>Get the latest version from CodePlex </li>
<li>Update the version number in AssemblyInfo.cs </li>
<li>Build the project </li>
<li>Check-in the updated AssemblyInfo.cs </li>
<li>Label the project with the version number </li>
<li>Publish the ClickOnce package to my webserver </li>
</ol>
<p>In order to achieve this I used the <a href="http://www.codeplex.com/CodePlexClient">CodePlex Source Control Client</a> (cpc.exe) to perform the get latest and check-ins. I was not able to complete #5 as the cpc client does not provide labelling. Maybe once the <a href="http://www.codeplex.com/SvnBridge">SvnBridge</a> supports it I can upgrade this guide to use a <a href="http://subversion.tigris.org/">SubVersion</a> client.</p>
<p>I also wrote a command line utility SetVersion.exe utility that updates the version number on an AsssemblyInfo.cs or .vb file. The source for this is published as <a href="http://code.msdn.microsoft.com/setversion">SetVersion</a> on the MSDN Code Gallery. </p>
<p>So without further ado this is the MSBuild project file that performs the tasks.</p>
<div>
<div style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #0000ff">&lt;</span><span style="color: #800000">Project</span> <span style="color: #ff0000">xmlns</span><span style="color: #0000ff">=&quot;http://schemas.microsoft.com/developer/msbuild/2003&quot;</span> <span style="color: #ff0000">DefaultTargets</span><span style="color: #0000ff">=&quot;Build&quot;</span><span style="color: #0000ff">&gt;</span></pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">  <span style="color: #0000ff">&lt;</span><span style="color: #800000">PropertyGroup</span><span style="color: #0000ff">&gt;</span></pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">    <span style="color: #0000ff">&lt;</span><span style="color: #800000">CodePlexProjectName</span><span style="color: #0000ff">&gt;</span>mycodeplexprojectname<span style="color: #0000ff">&lt;/</span><span style="color: #800000">CodePlexProjectName</span><span style="color: #0000ff">&gt;</span></pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">    <span style="color: #0000ff">&lt;</span><span style="color: #800000">Version</span><span style="color: #0000ff">&gt;</span>1.$(CCNetNumericLabel).0.0<span style="color: #0000ff">&lt;/</span><span style="color: #800000">Version</span><span style="color: #0000ff">&gt;</span></pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">    <span style="color: #0000ff">&lt;</span><span style="color: #800000">BuildFolder</span><span style="color: #0000ff">&gt;</span>C:\MyBuilds\$(Version)\<span style="color: #0000ff">&lt;/</span><span style="color: #800000">BuildFolder</span><span style="color: #0000ff">&gt;</span></pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">    <span style="color: #0000ff">&lt;</span><span style="color: #800000">IISPublishFolder</span><span style="color: #0000ff">&gt;</span>C:\MyInstallLocation\<span style="color: #0000ff">&lt;/</span><span style="color: #800000">IISPublishFolder</span><span style="color: #0000ff">&gt;</span></pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">    <span style="color: #0000ff">&lt;</span><span style="color: #800000">ProjectFolder</span><span style="color: #0000ff">&gt;</span>MySolution\Client\<span style="color: #0000ff">&lt;/</span><span style="color: #800000">ProjectFolder</span><span style="color: #0000ff">&gt;</span></pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">    <span style="color: #0000ff">&lt;</span><span style="color: #800000">BuildPublishFolder</span><span style="color: #0000ff">&gt;</span>$(ProjectFolder)bin\Release\app.publish<span style="color: #0000ff">&lt;/</span><span style="color: #800000">BuildPublishFolder</span><span style="color: #0000ff">&gt;</span></pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">    <span style="color: #0000ff">&lt;</span><span style="color: #800000">BuildProject</span><span style="color: #0000ff">&gt;</span>$(ProjectFolder)Client.vbproj<span style="color: #0000ff">&lt;/</span><span style="color: #800000">BuildProject</span><span style="color: #0000ff">&gt;</span></pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">    <span style="color: #0000ff">&lt;</span><span style="color: #800000">ToolsFolder</span><span style="color: #0000ff">&gt;</span>C:\Projects\SolutionFolder\Build\<span style="color: #0000ff">&lt;/</span><span style="color: #800000">ToolsFolder</span><span style="color: #0000ff">&gt;</span></pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">    <span style="color: #0000ff">&lt;</span><span style="color: #800000">CodePlexClient</span><span style="color: #0000ff">&gt;</span>$(ToolsFolder)cpc.exe<span style="color: #0000ff">&lt;/</span><span style="color: #800000">CodePlexClient</span><span style="color: #0000ff">&gt;</span></pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">    <span style="color: #0000ff">&lt;</span><span style="color: #800000">SetVersion</span><span style="color: #0000ff">&gt;</span>$(ToolsFolder)SetVersion.exe<span style="color: #0000ff">&lt;/</span><span style="color: #800000">SetVersion</span><span style="color: #0000ff">&gt;</span></pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">    <span style="color: #0000ff">&lt;</span><span style="color: #800000">CodePlexUser</span><span style="color: #0000ff">&gt;</span>codeplexusername<span style="color: #0000ff">&lt;/</span><span style="color: #800000">CodePlexUser</span><span style="color: #0000ff">&gt;</span></pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">    <span style="color: #0000ff">&lt;</span><span style="color: #800000">CodePlexPassword</span><span style="color: #0000ff">&gt;</span>codeplexpassword<span style="color: #0000ff">&lt;/</span><span style="color: #800000">CodePlexPassword</span><span style="color: #0000ff">&gt;</span></pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">  <span style="color: #0000ff">&lt;/</span><span style="color: #800000">PropertyGroup</span><span style="color: #0000ff">&gt;</span></pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">&#160;</pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">  <span style="color: #0000ff">&lt;</span><span style="color: #800000">Target</span> <span style="color: #ff0000">Name</span><span style="color: #0000ff">=&quot;Build&quot;</span><span style="color: #0000ff">&gt;</span></pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">    <span style="color: #0000ff">&lt;</span><span style="color: #800000">Message</span> <span style="color: #ff0000">Text</span><span style="color: #0000ff">=&quot;##Building version: $(Version)&quot;</span> <span style="color: #ff0000">Importance</span><span style="color: #0000ff">=&quot;high&quot;</span><span style="color: #0000ff">/&gt;</span></pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">    <span style="color: #0000ff">&lt;</span><span style="color: #800000">Message</span> <span style="color: #ff0000">Text</span><span style="color: #0000ff">=&quot;##Cleaning folder...&quot;</span> <span style="color: #ff0000">Importance</span><span style="color: #0000ff">=&quot;high&quot;</span><span style="color: #0000ff">/&gt;</span></pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">    <span style="color: #0000ff">&lt;</span><span style="color: #800000">Exec</span> <span style="color: #ff0000">Command</span><span style="color: #0000ff">=&quot;md $(BuildFolder)&quot;</span><span style="color: #0000ff">/&gt;</span></pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">&#160;</pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">    <span style="color: #0000ff">&lt;</span><span style="color: #800000">Message</span> <span style="color: #ff0000">Text</span><span style="color: #0000ff">=&quot;##Getting latest version&quot;</span> <span style="color: #ff0000">Importance</span><span style="color: #0000ff">=&quot;high&quot;</span><span style="color: #0000ff">/&gt;</span></pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">    <span style="color: #0000ff">&lt;</span><span style="color: #800000">Exec</span> <span style="color: #ff0000">Command</span><span style="color: #0000ff">=&quot;$(CodePlexClient) checkout $(CodePlexProjectName)&quot;</span> <span style="color: #ff0000">WorkingDirectory</span><span style="color: #0000ff">=&quot;$(BuildFolder)&quot;</span><span style="color: #0000ff">/&gt;</span></pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">&#160;</pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">    <span style="color: #0000ff">&lt;</span><span style="color: #800000">Message</span> <span style="color: #ff0000">Text</span><span style="color: #0000ff">=&quot;##Updating build number $(SetVersion) $(BuildFolder)$(ProjectFolder)AssemblyVersionInfo.vb $(Version)&quot;</span> <span style="color: #ff0000">Importance</span><span style="color: #0000ff">=&quot;high&quot;</span><span style="color: #0000ff">/&gt;</span></pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">    <span style="color: #0000ff">&lt;</span><span style="color: #800000">Exec</span> <span style="color: #ff0000">Command</span><span style="color: #0000ff">=&quot;$(SetVersion) $(BuildFolder)$(ProjectFolder)AssemblyVersionInfo.vb $(Version)&quot;</span><span style="color: #0000ff">/&gt;</span></pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">&#160;</pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">    <span style="color: #0000ff">&lt;</span><span style="color: #800000">Message</span> <span style="color: #ff0000">Text</span><span style="color: #0000ff">=&quot;##Building&quot;</span> <span style="color: #ff0000">Importance</span><span style="color: #0000ff">=&quot;high&quot;</span><span style="color: #0000ff">/&gt;</span></pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">    <span style="color: #0000ff">&lt;</span><span style="color: #800000">MSBuild</span> <span style="color: #ff0000">Projects</span><span style="color: #0000ff">=&quot;$(BuildFolder)$(BuildProject)&quot;</span> <span style="color: #ff0000">Targets</span><span style="color: #0000ff">=&quot;Publish&quot;</span> <span style="color: #ff0000">Properties</span><span style="color: #0000ff">=&quot;Configuration=Release;ApplicationVersion=$(Version)&quot;</span> <span style="color: #0000ff">/&gt;</span></pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">&#160;</pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">    <span style="color: #0000ff">&lt;</span><span style="color: #800000">Message</span> <span style="color: #ff0000">Text</span><span style="color: #0000ff">=&quot;##Commiting version change&quot;</span> <span style="color: #ff0000">Importance</span><span style="color: #0000ff">=&quot;high&quot;</span><span style="color: #0000ff">/&gt;</span></pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">    <span style="color: #0000ff">&lt;</span><span style="color: #800000">Exec</span> <span style="color: #ff0000">Command</span><span style="color: #0000ff">=&quot;$(CodePlexClient) commit /username $(CodePlexUser) /password $(CodePlexPassword) /message ---Automated-Build---$(Version)&quot;</span> <span style="color: #ff0000">WorkingDirectory</span><span style="color: #0000ff">=&quot;$(BuildFolder)&quot;</span><span style="color: #0000ff">/&gt;</span></pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">&#160;</pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">    <span style="color: #0000ff">&lt;</span><span style="color: #800000">Message</span> <span style="color: #ff0000">Text</span><span style="color: #0000ff">=&quot;##Publishing&quot;</span> <span style="color: #ff0000">Importance</span><span style="color: #0000ff">=&quot;high&quot;</span><span style="color: #0000ff">/&gt;</span></pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">    <span style="color: #0000ff">&lt;</span><span style="color: #800000">Exec</span> <span style="color: #ff0000">Command</span><span style="color: #0000ff">=&quot;rd $(IISPublishFolder) /s /q&quot;</span><span style="color: #0000ff">/&gt;</span></pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">    <span style="color: #0000ff">&lt;</span><span style="color: #800000">Exec</span> <span style="color: #ff0000">Command</span><span style="color: #0000ff">=&quot;xcopy $(BuildFolder)$(BuildPublishFolder)\*.* $(IISPublishFolder) /e /i /y&quot;</span><span style="color: #0000ff">/&gt;</span></pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">    <span style="color: #0000ff">&lt;</span><span style="color: #800000">Exec</span> <span style="color: #ff0000">Command</span><span style="color: #0000ff">=&quot;xcopy $(IISPublishFolder)..\default.htm $(IISPublishFolder)&quot;</span><span style="color: #0000ff">/&gt;</span></pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">  <span style="color: #0000ff">&lt;/</span><span style="color: #800000">Target</span><span style="color: #0000ff">&gt;</span></pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #0000ff">&lt;/</span><span style="color: #800000">Project</span><span style="color: #0000ff">&gt;</span></pre>
</p></div>
</div>
<p>Although I’ve worked with MSBuild files in the past this was the very first time I wrote one so a few things to remember. Items defined in the &lt;PropertGroup&gt; node are like declaring variables. You can then use them anywhere in your script in this format $(VariableName). </p>
<p>What&#8217;s even better is that you can override the default values you provide in the build file with values from the command line like. For example to force a particular version number I can peform the build like this:</p>
<p><font face="Courier New">MSBuild ReleaseBuild.proj /p:Version=1.6.0.0</font></p>
<p>When getting the latest version I opted to create a new folder for each build and pull the files into that folder. This way I didn’t have to worry about cleaning the bin folders. Every new build would start from an empty folder. </p>
<p>In my case rather than building the solution file I opted to build just the Client project since that would compile all the dependant projects. The key part that helped me create the necessary files for the ClickOnce publishing was the Targets=”Publish” parameter, that along with the ability to set the ClickOnce version using the properties provided an elegant solution for the tricky problem of keeping the AssemblyVersion and the ClickOnce application version in sync.</p>
<div>
<div style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #0000ff">&lt;</span><span style="color: #800000">MSBuild</span> <span style="color: #ff0000">Projects</span><span style="color: #0000ff">=&quot;$(BuildFolder)$(BuildProject)&quot;</span> <span style="color: #ff0000">Targets</span><span style="color: #0000ff">=&quot;Publish&quot;</span> <span style="color: #ff0000">Properties</span><span style="color: #0000ff">=&quot;Configuration=Release;ApplicationVersion=$(Version)&quot;</span> <span style="color: #0000ff">/&gt;</span></pre>
</p></div>
</div>
<p>I use CruiseControl to kick off the build process as well as drive the version numbering. CruiseControl is not absolutely necessary though, as the build file can be run from the command line, as long as a version number is specified.</p>
<p>I’ve packaged the build file along with the SetVersion.exe, cpc.exe (codeplex client) and the ccnet.config for download <a href="http://code.msdn.microsoft.com/CodePlexBuidAutomate/">here</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://merill.net/2008/10/automate-build-for-a-clickonce-application-hosted-on-codeplex-using-msbuild/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>WCF Performance Optimization Tips</title>
		<link>http://merill.net/2008/10/wcf-performance-optimization-tips/</link>
		<comments>http://merill.net/2008/10/wcf-performance-optimization-tips/#comments</comments>
		<pubDate>Fri, 17 Oct 2008 10:48:50 +0000</pubDate>
		<dc:creator>Merill Fernando</dc:creator>
				<category><![CDATA[.NET]]></category>

		<guid isPermaLink="false">/post/2008/10/WCF-Performance-Optimization-Tips.aspx</guid>
		<description><![CDATA[I wound up work on my last project and thought of sharing some performance challenges we faced when the product went live. Keep in mind though that optimization options heavily rely on your application design and its usage scenarios. Usage Scenario The usage scenario for which the following optimizations worked are as follows. The WCF [...]]]></description>
			<content:encoded><![CDATA[<p>I wound up work on my last project and thought of sharing some performance challenges we faced when the product went live.</p>
<p>Keep in mind though that optimization options heavily rely on your application design and its usage scenarios.</p>
<p><strong>Usage Scenario</strong></p>
<p>The usage scenario for which the following optimizations worked are as follows. The WCF services are hosted under IIS and currently only serve requests that come from the desktop client application through the intranet. Roughly 300 instances of the client application will be used concurrently.</p>
<p><strong>Long running calls      <br /></strong>The application design used the BackgroundWorker when making calls to the server but the actual WCF call was synchronous. Synchronous calls work well in most scenarios but when your service performs a long running task (&gt;1 sec) it blocks other clients from connecting to the server. Asynchronous calls make better sense in this scenario.     <br />Ref: <a href="http://msdn.microsoft.com/en-us/library/ms734701.aspx">Synchronous and Asynchronous Operations</a> </p>
<p><strong>Bindings      <br /></strong>When designing your application pick the binding carefully as this also affects performance. The WCF services were initially designed to use WSHttpBinding. This binding though affects performance especially when options such as security, reliable sessions and transaction flow are enabled. </p>
<p>As part of the performance tuning we switched to using BasicHttpBinding as none of the WS features were actually being used by the application. This dramatically improved performance because we cut down on all the acknowledgements. </p>
<p>&#160;</p>
<table border="0" cellspacing="0" cellpadding="2" width="400">
<tbody>
<tr>
<td valign="top">Default WSHttpBinding          <br />with Reliable Session Enabled (9 messages)</td>
<td valign="top">BasicHttpBinding (2 messages)</td>
</tr>
<tr>
<td valign="top"><img style="display: inline" title="WsHttpBinding-Messages" border="0" alt="WsHttpBinding-Messages" src="http://www.merill.net/wp-content/uploads/binary/WCFPerformanceOptimizationTips_7C4A/WsHttpBindingMessages.jpg" width="388" height="264" /> </td>
<td valign="top"><img style="display: inline" title="BasicBinding-Messages" border="0" alt="BasicBinding-Messages" src="http://www.merill.net/wp-content/uploads/binary/WCFPerformanceOptimizationTips_7C4A/BasicBindingMessages.jpg" width="388" height="197" /> </td>
</tr>
</tbody>
</table>
<p>&#160;&#160; </p>
<p>The security we lost when switching over to BasicHttpBinding will be enforced at the network level by locking down the machines that are allowed to make calls to the service. </p>
<p>In our case we could have squeezed out more performance if we had used NetTcpBinding but that would have required IIS7 and WAS. </p>
<p>Ref:    <br />-&#160;&#160;&#160; <a href="http://www.pluralsight.com/community/blogs/aaron/archive/2007/03/22/46560.aspx">WCF Binding Comparison</a>     <br />-&#160;&#160;&#160; <a href="http://geekswithblogs.net/claeyskurt/archive/2008/04/22/121508.aspx">BasicHttpBinding compared to WSHttpBinding at SOAP packet level</a> [Note: Although this author recommends WS over Basic, Microsoft specifies that the secure and reliable sessions be disabled for Load Balanced environments which basically brings it down to Basic].     <br />-&#160;&#160;&#160; <a href="http://msdn.microsoft.com/en-us/library/ms730128.aspx">Load Balancing</a> </p>
<p><strong>Service Model Throttling      <br /></strong>The service throttling parameters are another key element to look at when performance tuning services. The name is a little misleading though as it tends to imply that you want to throttle your service when in fact these are the default settings that the Microsoft engineers have put in place to prevent DOS attacks against your service. </p>
<p>In our case due to the nature of our application usage these settings caused the server to queue new requests once the default throttling levels of 10 concurrent sessions were reached. What effectively happened was that once long running queries were being processed other requests started getting queued up even though the server memory and processor usage were very low. </p>
<p>The resolution for this was to increase the default values for these settings (shown below) to a few thousand. </p>
<div>
<div style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #0000ff">&lt;</span><span style="color: #800000">behaviors</span><span style="color: #0000ff">&gt;</span> </pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">  <span style="color: #0000ff">&lt;</span><span style="color: #800000">serviceBehaviors</span><span style="color: #0000ff">&gt;</span> </pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">    <span style="color: #0000ff">&lt;</span><span style="color: #800000">behavior</span> <span style="color: #ff0000">name</span><span style="color: #0000ff">=&quot;DefaultThrottlingBehavior&quot;</span><span style="color: #0000ff">&gt;</span> </pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">      <span style="color: #0000ff">&lt;</span><span style="color: #800000">serviceThrottling</span> <span style="color: #ff0000">maxConcurrentCalls</span><span style="color: #0000ff">=&quot;16&quot;</span> </pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">                         <span style="color: #ff0000">maxConcurrentSessions</span><span style="color: #0000ff">=&quot;10&quot;</span> </pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">                         <span style="color: #ff0000">maxConcurrentInstances</span><span style="color: #0000ff">=&quot;[Int32.MaxValue]&quot;</span> <span style="color: #0000ff">/&gt;</span> </pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">    <span style="color: #0000ff">&lt;/</span><span style="color: #800000">behavior</span><span style="color: #0000ff">&gt;</span> </pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">  <span style="color: #0000ff">&lt;/</span><span style="color: #800000">serviceBehaviors</span><span style="color: #0000ff">&gt;</span> </pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #0000ff">&lt;/</span><span style="color: #800000">behaviors</span><span style="color: #0000ff">&gt;</span> </pre>
</p></div>
</div>
<p>
  <br />Ref: </p>
<p>-&#160;&#160;&#160; <a href="http://msdn.microsoft.com/en-us/library/ms731379.aspx">&lt;serviceThrottling&gt;</a> </p>
<p>-&#160;&#160;&#160; <a href="http://msdn.microsoft.com/en-us/library/ms735114(VS.85).aspx">Using ServiceThrottlingBehavior to Control WCF Service Performance</a> </p>
<p><strong>General guidelines when tuning performance </strong></p>
<p><u>Benchmarks<br />
    <br /></u>When tasked with tuning for performance the first requirement is to establish benchmarks on the current service levels and the expected service level once the tuning is completed. </p>
<p><u>Identify the bottleneck<br />
    <br /></u>The next key point is to identify the area that is causing the bottleneck. For the WCF services we tracked the time taken on the client side against the actual execution of the web service to eliminate the network being the bottleneck. </p>
<p>We worked backwards from the database call to ensure that they completed within the specified time. </p>
<p>Having your application instrumented is a key part of the initial design. The Enterprise Library provides instrumentation and open source tools such as log4net are lightweight and effective as well. </p>
<p><u>Replicate in your dev environment<br />
    <br /></u>Effectively testing out any tuning options can only be done if you can repro the issue in your development environment. The built-in load tester in Visual Studio will be a key part of your load testing armoury. </p>
<p><u>Code Profiling<br />
    <br /></u>If the bottleneck points to your code, code profiling tools will help your isolate the problem areas. At the time of this writing <a href="http://www.red-gate.com/Products/ants_profiler/index.htm">Red Gate ANTS Profiler</a> and <a href="http://www.jetbrains.com/profiler/">JetBrains dotTrace</a> are capable solutions. The code profiler built into Visual Studio 2008 is not as effective as these tools.</p>
</p>
<p>Finally a shout-out to WCF MVP <a href="http://geeksdiary.com/">Buddhike</a> who saved my day by quickly pointing me towards the binding and security modes as the perf culprits.</p>
]]></content:encoded>
			<wfw:commentRss>http://merill.net/2008/10/wcf-performance-optimization-tips/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>Silverlight</title>
		<link>http://merill.net/2008/10/silverlight/</link>
		<comments>http://merill.net/2008/10/silverlight/#comments</comments>
		<pubDate>Wed, 15 Oct 2008 14:46:52 +0000</pubDate>
		<dc:creator>Merill Fernando</dc:creator>
				<category><![CDATA[.NET]]></category>

		<guid isPermaLink="false">/post/2008/10/Silverlight.aspx</guid>
		<description><![CDATA[Silverlight&#160; 2.0 just went live. If you are a .NET developer building ASP.NET or WinForms/WPF applications this is a HUGE deal. Your .NET code can now run within a browser and across platforms (including Mac and on Linux using Moonlight) without requiring the .NET framework installed. I have never spent much time learning AJAX but [...]]]></description>
			<content:encoded><![CDATA[<p>Silverlight&#160; 2.0 just went live. If you are a .NET developer building ASP.NET or WinForms/WPF applications this is a HUGE deal. Your .NET code can now run within a browser and across platforms (including Mac and on Linux using Moonlight) without requiring the .NET framework installed.</p>
<p>I have never spent much time learning AJAX but I see XAML/WPF basing used heavily in the future. When Silverlight 1.0 was first released I was excited at the prospect of re-using WPF knowledge to build web applications but was sorely disappointed with the lack of tooling and controls. Fast forward today and you have rich tooling support in Visual Studio a number of control (including a grid view and date picker) plus more controls being released by the Client Controls team.</p>
<p>Start learning Silverlight today your going to need it soon. Goodbye AJAX I will avoid you whenever I can. </p>
<p>To get started on Silverlight see the great <a href="http://weblogs.asp.net/scottgu/archive/2008/10/14/silverlight-2-released.aspx">ScottGu</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://merill.net/2008/10/silverlight/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>WCF Add Service Reference gotcha with Windows Server</title>
		<link>http://merill.net/2008/04/wcf-add-service-reference-gotcha-with-windows-server/</link>
		<comments>http://merill.net/2008/04/wcf-add-service-reference-gotcha-with-windows-server/#comments</comments>
		<pubDate>Fri, 18 Apr 2008 09:11:00 +0000</pubDate>
		<dc:creator>Merill Fernando</dc:creator>
				<category><![CDATA[.NET]]></category>

		<guid isPermaLink="false">/post/2008/04/WCF-Add-Service-Reference-gotcha-with-Windows-Server.aspx</guid>
		<description><![CDATA[We recently switched from developing in Vista to Windows Server 2003. Someone had the bright idea that we should develop in the same environment the application is going to be hosted on. Go figure. What that meant is that you run into wierd issues like this one. When trying to add a Service Reference to [...]]]></description>
			<content:encoded><![CDATA[<p>
We recently switched from developing in Vista to Windows Server 2003. Someone had the bright idea that we should develop in the same environment the application is going to be hosted on. Go figure.
</p>
<p>
What that meant is that you run into wierd issues like this one. When trying to add a Service Reference to a WCF service hosted under IIS you keep getting this &#39;Add Service Reference&nbsp;Error&#39;:
</p>
<p>
<font face="courier new,courier">Metadata contains a reference that cannot be resolved: &#39;http://merill/Services.Host/ClientProfile.svc?wsdl&#39;.<br />
The WSDL document contains links that could not be resolved.<br />
There was an error downloading &#39;http://merill/Services.Host/ClientProfile.svc?xsd=xsd0&#39;.<br />
The underlying connection was closed: An unexpected error occurred on a receive.<br />
Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host.<br />
An existing connection was forcibly closed by the remote host<br />
Metadata contains a reference that cannot be resolved: &#39;http://localhost/Services.Host/ClientProfile.svc&#39;.<br />
Metadata contains a reference that cannot be resolved: &#39;http://localhost/Services.Host/ClientProfile.svc&#39;.<br />
If the service is defined in the current solution, try building the solution and adding the service reference again.</font>
</p>
<p>
The key part of this message is the reference to the downloading of the xsd. When I tried accessing the .svc url in a browser it worked fine, but trying to access the .svc?xsd=xsd0 brings up the generic &#39;cannot display webpage&#39; message.
</p>
<p>
When you unleash your&nbsp;weapon (<a href="http://www.microsoft.com/technet/sysinternals/fileanddisk/processmonitor.mspx">Process Monitor</a>) on the csc.exe process (this is the compiler generating the xsd) you&#39;ll realise that the IIS&nbsp;identity IIS_WPG does not have access to the Windows\Temp folder. Give enough rights to the folder and viola problemo solved.
</p>
<p>
Happy WCF programming on Windows Server!</p>
]]></content:encoded>
			<wfw:commentRss>http://merill.net/2008/04/wcf-add-service-reference-gotcha-with-windows-server/feed/</wfw:commentRss>
		<slash:comments>26</slash:comments>
		</item>
		<item>
		<title>Making use of the &#8216;??&#8217; operator in C#</title>
		<link>http://merill.net/2008/02/making-use-of-the-operator-in-c/</link>
		<comments>http://merill.net/2008/02/making-use-of-the-operator-in-c/#comments</comments>
		<pubDate>Mon, 18 Feb 2008 04:40:00 +0000</pubDate>
		<dc:creator>Merill Fernando</dc:creator>
				<category><![CDATA[.NET]]></category>

		<guid isPermaLink="false">/post/2008/02/Making-use-of-the--operator-in-C.aspx</guid>
		<description><![CDATA[The ?? operator was introduced to C# in 2.0 and I made a mental note to myself to use it when possible. Recently I had to do some tinkering with good ole Request.Form and Request.QueryString and I kept trying get the neurons to connect and figure out the shorter way of doing it. I knew [...]]]></description>
			<content:encoded><![CDATA[<p>
The <a href="http://msdn2.microsoft.com/en-us/library/ms173224(VS.80).aspx">?? operator</a> was introduced to C# in 2.0 and I made a mental note to myself to use it when possible.
</p>
<p>
Recently I had to do some tinkering with good ole Request.Form and Request.QueryString and I kept trying get the neurons to connect and figure out the shorter way of doing it. I knew there was another way to do it than write all this.
</p>
<div>
<div style="border-style: none; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: #f4f4f4">
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white">
<span style="color: #606060">   1:</span> <span style="color: #0000ff">string</span> filter = Request.QueryString[<span style="color: #006080">&quot;Filter&quot;</span>];
</pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: #f4f4f4">
<span style="color: #606060">   2:</span> <span style="color: #0000ff">if</span> (filter == <span style="color: #0000ff">null</span>)
</pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white">
<span style="color: #606060">   3:</span> {
</pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: #f4f4f4">
<span style="color: #606060">   4:</span>     filter = <span style="color: #006080">&quot;&quot;</span>;
</pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white">
<span style="color: #606060">   5:</span> }
</pre>
</div>
</div>
<p>
And Google is no help when you have no keyword to search. This is when <a href="http://www.jetbrains.com/resharper">ReSharper</a> came in handy and prompted to replace the above code with this succinct version.
</p>
<div>
<div style="border-style: none; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: #f4f4f4">
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white">
<span style="color: #606060">   1:</span> filter = Request.QueryString[<span style="color: #006080">&quot;Filter&quot;</span>] ?? <span style="color: #006080">&quot;&quot;</span>;
</pre>
</div>
</div>
<p>
BTW: If you are coding in VS 2008 check out the <a href="http://www.jetbrains.net/confluence/display/ReSharper/ReSharper+4.0+EAP+Notes">ReSharper 4.0 nightly builds</a>, it&#39;s awesome.</p>
]]></content:encoded>
			<wfw:commentRss>http://merill.net/2008/02/making-use-of-the-operator-in-c/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

