<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss 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/" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0">

<channel>
	<title>Chinh Do</title>
	
	<link>http://www.chinhdo.com</link>
	<description>Chinh's not quite random thoughts on software development, .NET, gadgets, and other things.</description>
	<lastBuildDate>Sat, 20 Feb 2010 18:32:00 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.1</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/ChinhDo" /><feedburner:info uri="chinhdo" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><geo:lat>37.661647</geo:lat><geo:long>-77.526326</geo:long><feedburner:emailServiceId>ChinhDo</feedburner:emailServiceId><feedburner:feedburnerHostname>http://feedburner.google.com</feedburner:feedburnerHostname><feedburner:feedFlare href="http://add.my.yahoo.com/rss?url=http%3A%2F%2Ffeeds.feedburner.com%2FChinhDo" src="http://us.i1.yimg.com/us.yimg.com/i/us/my/addtomyyahoo4.gif">Subscribe with My Yahoo!</feedburner:feedFlare><feedburner:feedFlare href="http://www.newsgator.com/ngs/subscriber/subext.aspx?url=http%3A%2F%2Ffeeds.feedburner.com%2FChinhDo" src="http://www.newsgator.com/images/ngsub1.gif">Subscribe with NewsGator</feedburner:feedFlare><feedburner:feedFlare href="http://feeds.my.aol.com/add.jsp?url=http%3A%2F%2Ffeeds.feedburner.com%2FChinhDo" src="http://o.aolcdn.com/favorites.my.aol.com/webmaster/ffclient/webroot/locale/en-US/images/myAOLButtonSmall.gif">Subscribe with My AOL</feedburner:feedFlare><feedburner:feedFlare href="http://www.bloglines.com/sub/http://feeds.feedburner.com/ChinhDo" src="http://www.bloglines.com/images/sub_modern11.gif">Subscribe with Bloglines</feedburner:feedFlare><feedburner:feedFlare href="http://www.netvibes.com/subscribe.php?url=http%3A%2F%2Ffeeds.feedburner.com%2FChinhDo" src="http://www.netvibes.com/img/add2netvibes.gif">Subscribe with Netvibes</feedburner:feedFlare><feedburner:feedFlare href="http://fusion.google.com/add?feedurl=http%3A%2F%2Ffeeds.feedburner.com%2FChinhDo" src="http://buttons.googlesyndication.com/fusion/add.gif">Subscribe with Google</feedburner:feedFlare><feedburner:feedFlare href="http://www.pageflakes.com/subscribe.aspx?url=http%3A%2F%2Ffeeds.feedburner.com%2FChinhDo" src="http://www.pageflakes.com/ImageFile.ashx?instanceId=Static_4&amp;fileName=ATP_blu_91x17.gif">Subscribe with Pageflakes</feedburner:feedFlare><item>
		<title>SQL Server Implicit String Conversion/Concatenation (XML parsing: line &lt;x&gt;, character &lt;y&gt;, unexpected end of input)</title>
		<link>http://feedproxy.google.com/~r/ChinhDo/~3/pthV_oJCmJk/</link>
		<comments>http://www.chinhdo.com/20100220/sql-server-concatenation/#comments</comments>
		<pubDate>Sat, 20 Feb 2010 18:32:00 +0000</pubDate>
		<dc:creator>Chinh Do</dc:creator>
				<category><![CDATA[Database]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://www.chinhdo.com/20100220/sql-server-concatenation/</guid>
		<description><![CDATA[If you are getting this error in your SQL Server T-SQL script:, you may be running into an issue with implicit string conversion in SQL Server:
declare @xml varchar(max), @doc XML, @stringVariable varchar(256)
set @stringVariable = 'a string value'

-- @doc is set by concatenating multiple string literals
-- and string variables, with all the variables having less than
-- [...]]]></description>
			<content:encoded><![CDATA[<p>If you are getting this error in your SQL Server T-SQL script:, you may be running into an issue with implicit string conversion in SQL Server:</p>
<pre class="brush: sql;">declare @xml varchar(max), @doc XML, @stringVariable varchar(256)
set @stringVariable = 'a string value'

-- @doc is set by concatenating multiple string literals
-- and string variables, with all the variables having less than
-- or equal to 8000 characters
set @xml = '&lt;root&gt;' +
... + @stringVariable +
...
'&lt;/root&gt;'

print len(@xml)

set @doc = @xml</pre>
<p><strong>Output</strong> </p>
<pre style="padding-left: 15px; font-family: monospace">8000
<font color="#ff0000">Msg 9400, Level 16, State 1, Line 4
XML parsing: line 64, character 74, unexpected end of input</font></pre>
<p>As you can see in the output, the @xml variable was truncated to 8000 characters, resulting in an invalid XML. This is due to the way SQL Server performs implicit string conversions when concatenating strings. When all the string literals/variables involved in the concatenation are 8000 characters or less, the resulting string will be exactly 8000 characters.</p>
<p>The same issue occurs with NVARCHAR data type. Instead of the 8000-character limit, it’s 4000 characters.</p>
<p>A simple fix is to make sure at least one of the string variables is of type VARCHAR(MAX):</p>
<pre class="brush: sql;">declare @xml varchar(max), @doc XML, @stringVariable varchar(256)
declare @x varchar(max)

set @stringVariable = 'a string value'
set @x = ''

set @xml = @x + '&lt;root&gt;' +
... + @stringVariable +
...
'&lt;/root&gt;'

print len(@xml)

set @doc = @xml</pre>
<p>&#160;</p>
<h3>More Info</h3>
<ul>
<li><a href="http://hrubaru.blogspot.com/2010/01/string-concatenation-issues.html">String Concatenation Issues</a> (Hrubaru&#8217;s blog) </li>
</ul>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/ChinhDo?a=pthV_oJCmJk:_btYYAI2nQI:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/ChinhDo?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/ChinhDo?a=pthV_oJCmJk:_btYYAI2nQI:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/ChinhDo?i=pthV_oJCmJk:_btYYAI2nQI:D7DqB2pKExk" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/ChinhDo/~4/pthV_oJCmJk" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.chinhdo.com/20100220/sql-server-concatenation/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.chinhdo.com/20100220/sql-server-concatenation/</feedburner:origLink></item>
		<item>
		<title>Instant Messaging Etiquette for the Workplace</title>
		<link>http://feedproxy.google.com/~r/ChinhDo/~3/j5sSxkD5g58/</link>
		<comments>http://www.chinhdo.com/20100213/work-instant-messaging-etiquette/#comments</comments>
		<pubDate>Sat, 13 Feb 2010 16:25:00 +0000</pubDate>
		<dc:creator>Chinh Do</dc:creator>
				<category><![CDATA[Technology]]></category>
		<category><![CDATA[Tips]]></category>

		<guid isPermaLink="false">http://www.chinhdo.com/20100213/work-instant-messaging-etiquette/</guid>
		<description><![CDATA[The use of instant messaging at the workplace is very prevalent these days. While instant messaging is very convenient for everyday communication, don’t treat it the same as email, face-to-face meetings, or phone calls. There are several significant differences between instant messaging and traditional forms of communications:

Instant messaging is not necessarily one-one-one. At any given [...]]]></description>
			<content:encoded><![CDATA[<p>The use of instant messaging at the workplace is very prevalent these days. While instant messaging is very convenient for everyday communication, don’t treat it the same as email, face-to-face meetings, or phone calls. There are several significant differences between instant messaging and traditional forms of communications:</p>
<ul>
<li>Instant messaging is not necessarily one-one-one. At any given moment, one person may be engaged in several simultaneous instant messaging conversations. </li>
<li>Even though your messages will be displayed on the recipient’s screen immediately, the recipient may not be able to read the messages and respond immediately. </li>
<li>With most instant messaging applications, the recipient cannot read your messages until you press the Enter key to send it. This limitation inherently makes instant messaging significantly slower than voice conversations.</li>
<li>Most people can speak faster than they can type.</li>
</ul>
<p>Here are some guidelines on basic/everyday instant messaging etiquette that will help you and your co-workers make the most out of this communication medium.</p>
<p><img title="Instant Messaging apps - AIM, MSN Messenger, Windows Live Messenger, Yahoo Messenger, Google Talk, ICQ" style="border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="290" alt="Instant Messaging apps - AIM, MSN Messenger, Windows Live Messenger, Yahoo Messenger, Google Talk, ICQ" src="http://www.chinhdo.com/wp-content/uploads/2010/01/image6.png" width="251" border="0" />&#160;</p>
<h3>Include Relevant Info/Questions in The First Message</h3>
<p>Avoid typing greetings or non-essential messages separately first. Include the question or relevant information in your first message.</p>
<h4><strong>Not-so-good examples (avoid this)</strong></h4>
<blockquote><p><strong>Conversation 1</strong></p>
<ul>
<li><font size="+0">Jane (10:54:50 AM): Hi</font> </li>
<li><em><font color="#008000">Mike (10:55:01 AM): Hello</font></em> </li>
<li><font color="#800000">Jane (10:55:06 AM): The test server will be restarted in 1 minute.</font> </li>
<li><em><font color="#008000">Mike (10:56:11 AM): Thanks for the info</font></em> </li>
</ul>
<p><strong>Conversation 2</strong></p>
<ul>
<li><em><font color="#800000">Jane (2:15:08 PM): Good afternoon</font></em> </li>
<li><font color="#008000">Mike (2:15:13 PM): Good afternoon</font> </li>
<li><em><font color="#800000">Jane (2:15:13 PM): Do you have a few minutes to talk on the phone re project A? </font></em></li>
<li><font color="#008000">Mike (2:15:18 PM): Sure, let me call you.</font> </li>
</ul>
<p><strong>Conversation 3</strong></p>
<ul>
<li><font color="#800000">Jane (4:03:30 PM): You there? </font></li>
<li><em><font color="#008000">Mike (4:03:35 PM): Yes</font></em> </li>
<li><font color="#800000">Jane (4:03:42 PM): Can we have a short team meeting in conf room A</font> </li>
<li><em><font color="#008000">Mike (4:03:50 PM): Sure. Be there in 5.</font></em> </li>
</ul>
</blockquote>
<h4><strong>Good examples</strong></h4>
<blockquote><p><strong>Conversation 1</strong></p>
<ul>
<li><font color="#800000">Jane (10:54:50 AM): Hi, the test server will be restarted in 1 minute. </font></li>
<li><em><font color="#008000">Mike (10:54:55 AM): Thanks for the info </font></em></li>
</ul>
<p><strong>Conversation 2</strong></p>
<ul>
<li><font color="#800000">Jane (2:15:08 PM): Good afternoon, do you have a few minutes to talk on the phone re project A? </font></li>
<li><em><font color="#008000">Mike (2:15:13 PM): Sure I will call you.</font></em> </li>
</ul>
<p><strong>Conversation 3</strong></p>
<ul>
<li><font color="#800000">Jane (4:03:30 PM): Can we have a short team meeting in conf room A? </font></li>
<li><em><font color="#008000">Mike (4:03:35 PM): Sure, be right there.</font></em> </li>
</ul>
</blockquote>
<p>Every time you send a message, the recipient is disrupted from whatever he/she is doing. The more you can delay this disruption the better, even if it’s only seconds. It’s also not necessary to ask the recipient if he/she is there. That’s what the online status (away/available) is for. You can just type your message or ask your question. One exception to this would be if your message contains sensitive information.</p>
<h3></h3>
<h3>Send Complete Messages</h3>
<p>Good:</p>
<ul>
<li><font color="#800000">Jane (9:15:23 AM): Hi, all integration tests are failing in the integration environment for the admin user group. Can you take a look?”</font> </li>
</ul>
<p>No so good:</p>
<ul>
<li><font color="#800000">Jane (9:15:23 AM): Hi, all integration tests are failing…</font> </li>
<li><font color="#800000">Jane (9:15:27 AM): the integration environment…</font> </li>
<li><font color="#800000">Jane (9:15:32 AM): for the admin user group…”</font> </li>
<li><font color="#800000">Jane (9:15:38 AM): Can you take a look?</font> </li>
</ul>
<p>If you have to send several sentences in sequence, compose them in a separate editor first (notepad would do), then type them out quickly in succession. That way the recipient does not have to wait for you while you type your next message, make editing corrections, etc.</p>
<h3>Do Not Expect Responses Immediately</h3>
<p>Unless the recipient reports to you, do not expect a response immediately after you type a message. The recipient may be in the middle of five other instant message conversations, on the phone, or working on something else more important. If the recipient’s status is not set to “Away”, and you have not received a response after a few minutes, it’s ok to ping him/her again. Maybe they forgot about your message.</p>
<h3>Update Your Status and Respect Others’ Status</h3>
<p>If you need to step out, change your status to “Away”, or “In a Meeting”, or “Back in an Hour”, or whatever is appropriate for the situation. This tells everyone else that you are not available to respond to messages immediately and save them from having to wait for your responses.</p>
<h3><strong>Pick Up the Phone</strong></h3>
<p>If the instant messaging conversation starts to go into lots of details and may make take longer than a few minutes, consider picking up the phone and continue the conversation there.</p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/ChinhDo?a=j5sSxkD5g58:vyCx8CTfRhA:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/ChinhDo?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/ChinhDo?a=j5sSxkD5g58:vyCx8CTfRhA:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/ChinhDo?i=j5sSxkD5g58:vyCx8CTfRhA:D7DqB2pKExk" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/ChinhDo/~4/j5sSxkD5g58" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.chinhdo.com/20100213/work-instant-messaging-etiquette/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.chinhdo.com/20100213/work-instant-messaging-etiquette/</feedburner:origLink></item>
		<item>
		<title>Using a Different Configured Binding in WCF Client</title>
		<link>http://feedproxy.google.com/~r/ChinhDo/~3/P9es3FauYOE/</link>
		<comments>http://www.chinhdo.com/20100206/wcf-switch-binding/#comments</comments>
		<pubDate>Sat, 06 Feb 2010 23:38:00 +0000</pubDate>
		<dc:creator>Chinh Do</dc:creator>
				<category><![CDATA[Dotnet/.NET - C#]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://www.chinhdo.com/20100206/wcf-switch-binding/</guid>
		<description><![CDATA[To programmatically switch bindings on the fly, you can do it via the constructor of the generated client:
var client = new WeatherClient(“MyEndpoint”);
“MyEndpoint” is the name of the endpoint defined in your config file:
&#60;client&#62;
    &#60;endpoint address=&#34;&#34; binding=&#34;basicHttpBinding&#34; bindingConfiguration=&#34;http1&#34; contract=&#34;MyContract&#34; name=&#34;MyEndpoint&#34; /&#62;
&#60;/client&#62;
]]></description>
			<content:encoded><![CDATA[<p>To programmatically switch bindings on the fly, you can do it via the constructor of the generated client:</p>
<pre class="brush: csharp;">var client = new WeatherClient(“MyEndpoint”);</pre>
<p>“MyEndpoint” is the name of the endpoint defined in your config file:</p>
<pre class="brush: xml;">&lt;client&gt;
    &lt;endpoint address=&quot;&quot; binding=&quot;basicHttpBinding&quot; bindingConfiguration=&quot;http1&quot; contract=&quot;MyContract&quot; name=&quot;MyEndpoint&quot; /&gt;</pre>
<pre class="brush: xml;">&lt;/client&gt;</pre>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/ChinhDo?a=P9es3FauYOE:CuhNErbhaN4:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/ChinhDo?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/ChinhDo?a=P9es3FauYOE:CuhNErbhaN4:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/ChinhDo?i=P9es3FauYOE:CuhNErbhaN4:D7DqB2pKExk" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/ChinhDo/~4/P9es3FauYOE" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.chinhdo.com/20100206/wcf-switch-binding/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.chinhdo.com/20100206/wcf-switch-binding/</feedburner:origLink></item>
		<item>
		<title>Show Your Papers!</title>
		<link>http://feedproxy.google.com/~r/ChinhDo/~3/pBo5s-MaeFw/</link>
		<comments>http://www.chinhdo.com/20100130/show-your-paper/#comments</comments>
		<pubDate>Sun, 31 Jan 2010 02:28:00 +0000</pubDate>
		<dc:creator>Chinh Do</dc:creator>
				<category><![CDATA[Technology]]></category>

		<guid isPermaLink="false">http://www.chinhdo.com/20100203/show-your-paper/</guid>
		<description><![CDATA[They say a man’s home is his castle, and since my computer is my virtual home, I must have complete control over what goes on in it.&#160; When I see a stranger person walking around in my yard, he’s better be ready to tell me who he is, what company he works for, why he’s [...]]]></description>
			<content:encoded><![CDATA[<p>They say a man’s home is his castle, and since my computer is my virtual home, I must have complete control over what goes on in it.&#160; When I see a stranger person walking around in my yard, he’s better be ready to tell me who he is, what company he works for, why he’s in there. Likewise, when I see a strange window running in my computer, I must have the ability to easily tell what it is, who makes it, when it was installed, etc.</p>
<p>Yes, one would think that being able to quickly identify any running window would be a basic feature of any modern so called window operation system. It’s 25 years after the first release of Microsoft Windows, and the sad truth is that you still often cannot easily identify running windows.</p>
<p>Look at the example below. If you are not familiar with this utility, and you came back to your laptop seeing this, would you know what it&#8217;s about? Should you click Yes or No? Is this a legitimate application, or something more sinister?</p>
<p><a href="http://www.chinhdo.com/wp-content/uploads/2010/01/image2.png"><img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="130" alt="image" src="http://www.chinhdo.com/wp-content/uploads/2010/01/image-thumb1.png" width="189" border="0" /></a>&#160;</p>
<p>The first obvious problem is the missing message. That&#8217;s forgivable however. Bugs happen, files get corrupted, language resource files go missing, etc. What’s not acceptable is for the <strong>Windows</strong> OS not to provide any method to identify misbehaving windows.</p>
<p>So how about it Microsoft? Let us easily find out identifying information about any running Windows. Perhaps with with a click of a button, we can see:</p>
<ul>
<li>Name of owning application/process </li>
<li>Name of vendor (if available) </li>
<li>Folder where executable resides </li>
<li>Date the application was installed </li>
<li>User who installed the application </li>
<li>If the user didn&#8217;t run the application himself, identify the parent process or service that launches the application (shortcut in Startup folder, registry, etc.) </li>
<li>Available code signatures </li>
</ul>
<p>For now, if you want to identify any visible window, use <a href="http://technet.microsoft.com/en-us/sysinternals/bb896653.aspx" target="_blank">Sysinternals’ Process Explorer</a>. Drag the “Find Window’s Process” icon and drop it on top of the target window and Process Explorer will highlight the owner process in its window. From there, you can get the executable name, company name, folder location, etc.</p>
<p><img title="Process Explorer Find Window&#39;s Process" style="border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="120" alt="Process Explorer Find Window&#39;s Process" src="http://www.chinhdo.com/wp-content/uploads/2010/01/image3.png" width="240" border="0" /></p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/ChinhDo?a=pBo5s-MaeFw:IhHGTPemOGU:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/ChinhDo?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/ChinhDo?a=pBo5s-MaeFw:IhHGTPemOGU:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/ChinhDo?i=pBo5s-MaeFw:IhHGTPemOGU:D7DqB2pKExk" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/ChinhDo/~4/pBo5s-MaeFw" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.chinhdo.com/20100130/show-your-paper/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.chinhdo.com/20100130/show-your-paper/</feedburner:origLink></item>
		<item>
		<title>WCF Client Error “The connection was closed unexpectedly” Calling Java/WebSphere 7 Web Service</title>
		<link>http://feedproxy.google.com/~r/ChinhDo/~3/M8n5vU4YmTs/</link>
		<comments>http://www.chinhdo.com/20100123/wcf-java-100-continue/#comments</comments>
		<pubDate>Sun, 24 Jan 2010 01:31:00 +0000</pubDate>
		<dc:creator>Chinh Do</dc:creator>
				<category><![CDATA[Dotnet/.NET - C#]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://www.chinhdo.com/20100127/wcf-java-100-continue/</guid>
		<description><![CDATA[If you get the following exception calling a WebSphere web service from your .NET WCF Client (service reference):
System.ServiceModel.CommunicationException: The underlying connection was closed: The connection was closed unexpectedly. &#8212;&#62;  System.Net.WebException: The underlying connection was closed: The connection was closed unexpectedly.
Try adding this code before the service call:
System.Net.ServicePointManager.Expect100Continue = false;
More info on the 100-Continue behavior from [...]]]></description>
			<content:encoded><![CDATA[<p>If you get the following exception calling a WebSphere web service from your .NET WCF Client (service reference):</p>
<blockquote><p>System.ServiceModel.CommunicationException: The underlying connection was closed: The connection was closed unexpectedly. &#8212;&gt;  System.Net.WebException: The underlying connection was closed: The connection was closed unexpectedly.</p></blockquote>
<p>Try adding this code before the service call:</p>
<pre class="brush: csharp;">System.Net.ServicePointManager.Expect100Continue = false;</pre>
<p><a href="http://msdn.microsoft.com/en-us/library/system.net.servicepointmanager.expect100continue.aspx">More info</a> on the 100-Continue behavior from MSDN.</p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/ChinhDo?a=M8n5vU4YmTs:R3nX5UytuYE:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/ChinhDo?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/ChinhDo?a=M8n5vU4YmTs:R3nX5UytuYE:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/ChinhDo?i=M8n5vU4YmTs:R3nX5UytuYE:D7DqB2pKExk" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/ChinhDo/~4/M8n5vU4YmTs" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.chinhdo.com/20100123/wcf-java-100-continue/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.chinhdo.com/20100123/wcf-java-100-continue/</feedburner:origLink></item>
		<item>
		<title>Give The Power of Speech and Sound to Your PowerShell Scripts</title>
		<link>http://feedproxy.google.com/~r/ChinhDo/~3/ist52lH332o/</link>
		<comments>http://www.chinhdo.com/20100116/give-the-power-of-speech-and-sound-to-your-powershell-scripts/#comments</comments>
		<pubDate>Sat, 16 Jan 2010 05:34:00 +0000</pubDate>
		<dc:creator>Chinh Do</dc:creator>
				<category><![CDATA[PowerShell]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://www.chinhdo.com/20100120/give-the-power-of-speech-and-sound-to-your-powershell-scripts/</guid>
		<description><![CDATA[Do you ever have the problem where you start a long running script (such as running a code build), multi-task on something else on another monitor while waiting for the script to finish, and then totally forget about the script until half an hour later? Well, here’s a solution your problem: have your script give [...]]]></description>
			<content:encoded><![CDATA[<p>Do you ever have the problem where you start a long running script (such as running a code build), multi-task on something else on another monitor while waiting for the script to finish, and then totally forget about the script until half an hour later? Well, here’s a solution your problem: have your script give you holler at you when it’s done.</p>
<p><img title="Hello sir! I am done running your command!" style="border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="224" alt="Hello sir! I am done running your command!" src="http://www.chinhdo.com/wp-content/uploads/2010/01/image1.png" width="279" border="0" /> </p>
<p>In my library script file, I have the following functions to play sound files and to speak any text:</p>
<pre class="brush: csharp;">function PlayMp3($path) {
    # Use the default player to play. Hide the window.
    $si = new-object System.Diagnostics.ProcessStartInfo
    $si.fileName = $path
    $si.windowStyle = [System.Diagnostics.ProcessWindowStyle]::Hidden
    $process = New-Object System.Diagnostics.Process
    $process.startInfo=$si
    $process.start()
}

function PlayWav($path) {
    $sound = new-Object System.Media.SoundPlayer;
    $sound.SoundLocation=&quot;$path&quot;;
    $sound.Play();
}

function Say($msg) {
    $Voice = new-object -com SAPI.SpVoice
    $Voice.Speak($msg, 1 )
}</pre>
<p>If you like the text-to-speech feature but find Windows’ speech engine lacking, check out <a href="http://www.ivona.com/?tk=jtvleiDF">Ivona</a>. It’s a commercial text-to-speech engine but you are allow to generate and download short speech files for free personal use. Now, my script can nicely interrupt me to tell me when it’s done. Other online text-to-speech engines: <a href="http://vozme.com/index.php?lang=en">vozMe</a>, <a href="http://spokentext.net/">SpokenText</a>.</p>
<h3>If Making Noise Is Not Your Thing</h3>
<p>If making noise is not your thing, consider displaying a message in the Notification Area. Here’s the code (courtesy <a href="http://www.microsoft.com/technet/scriptcenter/resources/pstips/may08/pstip0523.mspx">Microsoft TechNet</a>):</p>
<p><img title="Build complete!" style="border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="96" alt="Build complete!" src="http://www.chinhdo.com/wp-content/uploads/2010/01/x.jpg" width="209" border="0" /> </p>
<pre class="brush: csharp;">function Get-ScriptName {
    $MyInvocation.ScriptName
} 

function DisplayNotificationInfo($msg, $title, $type) {
    # $type - &quot;info&quot; or &quot;error&quot;
    if ($type -eq $null) {$type = &quot;info&quot;}
    if ($title -eq $null) {$title = Get-ScriptName}

    [void] [System.Reflection.Assembly]::LoadWithPartialName(&quot;System.Windows.Forms&quot;)
    $objNotifyIcon = New-Object System.Windows.Forms.NotifyIcon
    # Specify your own icon below
    $objNotifyIcon.Icon = &quot;C:CdoScriptsFolder.ico&quot;
    $objNotifyIcon.BalloonTipIcon = &quot;Info&quot;
    $objNotifyIcon.BalloonTipTitle = $title
    $objNotifyIcon.BalloonTipText = $msg

    $objNotifyIcon.Visible = $True
    $objNotifyIcon.ShowBalloonTip(10000)
}</pre>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/ChinhDo?a=ist52lH332o:vkG-6Vxy1RU:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/ChinhDo?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/ChinhDo?a=ist52lH332o:vkG-6Vxy1RU:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/ChinhDo?i=ist52lH332o:vkG-6Vxy1RU:D7DqB2pKExk" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/ChinhDo/~4/ist52lH332o" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.chinhdo.com/20100116/give-the-power-of-speech-and-sound-to-your-powershell-scripts/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.chinhdo.com/20100116/give-the-power-of-speech-and-sound-to-your-powershell-scripts/</feedburner:origLink></item>
		<item>
		<title>Taking Control of Your Thermostat</title>
		<link>http://feedproxy.google.com/~r/ChinhDo/~3/kBRyP95xfRc/</link>
		<comments>http://www.chinhdo.com/20100114/control-your-thermostat/#comments</comments>
		<pubDate>Thu, 14 Jan 2010 04:14:00 +0000</pubDate>
		<dc:creator>Chinh Do</dc:creator>
				<category><![CDATA[Gadgets]]></category>
		<category><![CDATA[Technology]]></category>

		<guid isPermaLink="false">http://www.chinhdo.com/20100114/control-your-thermostat/</guid>
		<description><![CDATA[Once in a while I come across a new product that solves a problem so elegantly that I just have to ask myself, why didn’t think of this before? It’s been very cold recently in the East Coast and when it gets very cold, my house’s gas heating system goes completely nuts. If I set [...]]]></description>
			<content:encoded><![CDATA[<p>Once in a while I come across a new product that solves a problem so elegantly that I just have to ask myself, why didn’t think of this before? It’s been very cold recently in the East Coast and when it gets very cold, my house’s gas heating system goes completely nuts. If I set the thermostat desired temperature to 70 degrees, the temperature in the bedroom will be in the roasting 80’s. The temperature differential depends how how cold it is outside, so I can’t just simply set the thermostat to a specific offset and forget either. I constantly need to get up in the middle of the night to adjust the thermostat downstairs when it gets cold outside. Why do I have to do this? I guess nobody told my house that we are in the 21st century.</p>
<p><a href="http://www.chinhdo.com/wp-content/uploads/2010/01/image.png"><img title="image" style="border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="240" alt="image" src="http://www.chinhdo.com/wp-content/uploads/2010/01/image-thumb.png" width="201" border="0" /></a></p>
<p>So, the first thing I thought of is a remote control for the thermostat. Well, no surprise, they do make them. Apparently, my problem is fairly common for two-story homes with a single HVAC system. This <a href="http://www.amazon.com/Lux-TX9000RF-Programmable-Thermostat-Remote/dp/B000COHC3M/ref=cm_cr_pr_product_top">Lux TX9000RF Programmable Thermostat with Remote</a> looked very promising to me. A product like this would allow adjusting the thermostat temperature from anywhere in the house.</p>
<p>That still requires some work however. Hmm… what if there is a thermostat that can read the current temperature from a remote sensor? Bingo: they make those too. There are not many to be found, and after searching around, I decided to go for the&#160; <a href="http://www.amazon.com/Honeywell-YTHX9321R5003-Prestige-Thermostat-Kit/dp/B001O48A3U/ref=sr_1_1?ie=UTF8&amp;s=hi&amp;qid=1262832803&amp;sr=1-1">Honeywell YTHX9321R5003 Prestige HD Thermostat Kit</a> and I’ve been very happy with the result so far. This kit is expensive, but very well made and it works as advertised. It also looks very nice. The kit includes the thermostat, a remote control/sensor, and an outdoor sensor. This kit is in Honeywell Pro Install line, which means it’s sold mainly through HVAC contractors and installers. I found the installation process only slightly more complicated than a regular programmable thermostat. The only thing you need to watch out for is that this thermostat requires a 24vac Common wire (commonly black in color), which may not be available in your setup. If that is the case, then you will need to run/fish a new wire from your furnace &#8211; a pretty big job.</p>
<p>Now with this cool new gadget hooked up and everything humming, all I have to do is bring the remote with me to the bedroom and push the button on it named “Read temp from this device” and I am set for the night. If I ever want to tweak the temperature for some reason, I can do it right there with the remote. If only everything else was this easy!</p>
<p><img title="clip_image001" style="border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="243" alt="clip_image001" src="http://www.chinhdo.com/wp-content/uploads/2010/01/clip-image001.png" width="471" border="0" /></p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/ChinhDo?a=kBRyP95xfRc:5iw6N48eki4:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/ChinhDo?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/ChinhDo?a=kBRyP95xfRc:5iw6N48eki4:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/ChinhDo?i=kBRyP95xfRc:5iw6N48eki4:D7DqB2pKExk" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/ChinhDo/~4/kBRyP95xfRc" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.chinhdo.com/20100114/control-your-thermostat/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		<feedburner:origLink>http://www.chinhdo.com/20100114/control-your-thermostat/</feedburner:origLink></item>
		<item>
		<title>Automating Maven with PowerShell</title>
		<link>http://feedproxy.google.com/~r/ChinhDo/~3/5GVrUSR63mo/</link>
		<comments>http://www.chinhdo.com/20100107/powershell-mvn-integration/#comments</comments>
		<pubDate>Fri, 08 Jan 2010 02:10:00 +0000</pubDate>
		<dc:creator>Chinh Do</dc:creator>
				<category><![CDATA[PowerShell]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://www.chinhdo.com/20100107/powershell-mvn-integration/</guid>
		<description><![CDATA[I found out the hard way that mvn (Maven) on Windows always return a success code of true, which means you cannot use the return code ($?) to check whether the mvn command succeeded or failed. Why they decided to break this seemingly basic program contract is a mystery. A work-around is to scan the [...]]]></description>
			<content:encoded><![CDATA[<p>I found out the hard way that mvn (<a href="http://www.google.com/url?sa=t&amp;source=web&amp;ct=res&amp;cd=1&amp;ved=0CA0QFjAA&amp;url=http%3A%2F%2Fmaven.apache.org%2F&amp;ei=Qb9DS-HiBMTIlAfm_amRBw&amp;usg=AFQjCNEOM94DrY-KbHD2ionSrXoOiwwnDg&amp;sig2=UCki6L-5dzDdtQDasrKCYA">Maven</a>) on Windows always return a success code of true, which means you cannot use the return code ($?) to check whether the mvn command succeeded or failed. Why they decided to break this seemingly basic program contract is a mystery. A work-around is to scan the mvn output and look for specific strings such as “BUILD SUCCESSFUL”.</p>
<p>Here’s how:</p>
<pre class="brush: csharp;">function InvokeAndCheckStdOut($cmd, $successString, $failString) {
    Write-Host &quot;====&gt; InvokeAndCheckStdOut&quot;
    $fullCmd = &quot;$cmd|Tee-Object -variable result&quot; 

    Invoke-Expression $fullCmd
    $found = $false
    $success = $false
    foreach ($line in $result) {
      if ($line -match $failString) {
       $found = $true
       $success = $false
       break
      }
      else {
       if ($line -match $successString) {
        $found = $true
        $success = $true
        #&quot;[InvokeAndCheckStdOut] FOUND MATCH: $line&quot;
        break
       }
       else {
        #&quot;[InvokeAndCheckStdOut] $line&quot;
       }
      }
    }

    if (! $success) {
      PlayWav &quot;${env:windir}\Media\ding.wav&quot;
      throw &quot;Mvn command failed.&quot;
    }

    Write-Host &quot;InvokeAndCheckStdOut &lt;====&quot;
}

function InvokeMvn($cmd) {
    InvokeAndCheckStdOut $cmd &quot;BUILD SUCCESSFUL&quot; &quot;BUILD FAILED&quot;
}

InvokeMvn &quot;mvn clean install&quot;</pre>
<h3>See Also</h3>
<ul>
<li><a href="http://www.chinhdo.com/20100105/powershell-invoke-expression-tee-object/">Tee-Object and Invoke-Expression in PowerShell</a> </li>
</ul>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/ChinhDo?a=5GVrUSR63mo:C85WyNNYCW4:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/ChinhDo?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/ChinhDo?a=5GVrUSR63mo:C85WyNNYCW4:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/ChinhDo?i=5GVrUSR63mo:C85WyNNYCW4:D7DqB2pKExk" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/ChinhDo/~4/5GVrUSR63mo" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.chinhdo.com/20100107/powershell-mvn-integration/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.chinhdo.com/20100107/powershell-mvn-integration/</feedburner:origLink></item>
		<item>
		<title>Tee-Object and Invoke-Expression in PowerShell</title>
		<link>http://feedproxy.google.com/~r/ChinhDo/~3/IkAHY3NukOM/</link>
		<comments>http://www.chinhdo.com/20100105/powershell-invoke-expression-tee-object/#comments</comments>
		<pubDate>Wed, 06 Jan 2010 02:07:00 +0000</pubDate>
		<dc:creator>Chinh Do</dc:creator>
				<category><![CDATA[PowerShell]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://www.chinhdo.com/20100105/powershell-invoke-expression-tee-object/</guid>
		<description><![CDATA[The PowerShell Tee-Object Cmdlet allows you to send command output to a file or a variable, and display it in the console at the same time. This is very useful for those instances where you need to parse the text output of a command. I had a hard time getting it to work with Invoke-Expression. [...]]]></description>
			<content:encoded><![CDATA[<p>The PowerShell Tee-Object Cmdlet allows you to send command output to a file or a variable, and display it in the console at the same time. This is very useful for those instances where you need to parse the text output of a command. I had a hard time getting it to work with Invoke-Expression. After trying different things, I finally found the solution. To get Tee-Object to work with Invoke-Expression in PowerShell 1, include the Tee command in the Invoke-Expression command like this:</p>
<pre class="brush: csharp;">Invoke-Expression &quot;mvn clean install | Tee –variable result”</pre>
<p>The following, which I guess is what most people try first, doesn’t work (at least in PowerShell V1). I guess because you are storing the result of the “Invoke-Expression” command itself into the variable instead of “mvn clean install”.</p>
<pre class="brush: csharp;">    Invoke-Expression &quot;mvn clean install” | Tee -variable result</pre>
<p>Wrapping Invoke-Expression in parenthesis (see below) works, but has a drawback: the output is not written to Standard Out until the whole command finishes.</p>
<pre class="brush: csharp;">    (Invoke-Expression &quot;mvn clean install”) | Tee -variable result</pre>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/ChinhDo?a=IkAHY3NukOM:9cVjvUb_xLo:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/ChinhDo?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/ChinhDo?a=IkAHY3NukOM:9cVjvUb_xLo:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/ChinhDo?i=IkAHY3NukOM:9cVjvUb_xLo:D7DqB2pKExk" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/ChinhDo/~4/IkAHY3NukOM" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.chinhdo.com/20100105/powershell-invoke-expression-tee-object/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		<feedburner:origLink>http://www.chinhdo.com/20100105/powershell-invoke-expression-tee-object/</feedburner:origLink></item>
		<item>
		<title>Create a Temporary File in PowerShell</title>
		<link>http://feedproxy.google.com/~r/ChinhDo/~3/3JYDQCzeSX4/</link>
		<comments>http://www.chinhdo.com/20091210/create-a-temporary-file-in-powershell/#comments</comments>
		<pubDate>Fri, 11 Dec 2009 00:52:00 +0000</pubDate>
		<dc:creator>Chinh Do</dc:creator>
				<category><![CDATA[PowerShell]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://www.chinhdo.com/20091210/create-a-temporary-file-in-powershell/</guid>
		<description><![CDATA[$tempFile = [IO.Path]::GetTempFileName()
An empty file created immediately when you call this method. Remember to clean it up when are you done!

]]></description>
			<content:encoded><![CDATA[<p>$tempFile = [IO.Path]::GetTempFileName()</p>
<p>An empty file created immediately when you call this method. Remember to clean it up when are you done!</p>
<p><img title="image" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="154" alt="image" src="http://www.chinhdo.com/wp-content/uploads/2009/12/image.png" width="454" border="0" /></p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/ChinhDo?a=3JYDQCzeSX4:fa5wEGbNIjY:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/ChinhDo?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/ChinhDo?a=3JYDQCzeSX4:fa5wEGbNIjY:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/ChinhDo?i=3JYDQCzeSX4:fa5wEGbNIjY:D7DqB2pKExk" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/ChinhDo/~4/3JYDQCzeSX4" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.chinhdo.com/20091210/create-a-temporary-file-in-powershell/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.chinhdo.com/20091210/create-a-temporary-file-in-powershell/</feedburner:origLink></item>
	</channel>
</rss>
