<?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/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>Hoa Chau's weblog</title>
	<atom:link href="http://hoachau.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://hoachau.wordpress.com</link>
	<description>Random access...</description>
	<lastBuildDate>Tue, 13 Mar 2012 06:24:51 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='hoachau.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://1.gravatar.com/blavatar/b7ec5dadb0de8c016cd8a6a9680d6845?s=96&#038;d=http%3A%2F%2Fs2.wp.com%2Fi%2Fbuttonw-com.png</url>
		<title>Hoa Chau's weblog</title>
		<link>http://hoachau.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://hoachau.wordpress.com/osd.xml" title="Hoa Chau&#039;s weblog" />
	<atom:link rel='hub' href='http://hoachau.wordpress.com/?pushpress=hub'/>
		<item>
		<title>Troubleshooting!</title>
		<link>http://hoachau.wordpress.com/2012/03/13/troubleshooting/</link>
		<comments>http://hoachau.wordpress.com/2012/03/13/troubleshooting/#comments</comments>
		<pubDate>Tue, 13 Mar 2012 06:24:01 +0000</pubDate>
		<dc:creator>hoachau</dc:creator>
				<category><![CDATA[.Net]]></category>
		<category><![CDATA[Asp.Net]]></category>
		<category><![CDATA[Security]]></category>
		<category><![CDATA[WCF]]></category>
		<category><![CDATA[WIF]]></category>

		<guid isPermaLink="false">http://hoachau.wordpress.com/?p=177</guid>
		<description><![CDATA[1. m_safeCertContext is an invalid handle I got this issue when try to assign a X509SigningCredentials to the custom STSConfiguration. Solutions: Make sure don&#8217;t call cert.Reset() before passing the cert to X509SigningCredentials constructor 2. Keyset does not exist Solutions: http://stackoverflow.com/questions/602345/cryptographicexception-keyset-does-not-exist-but-only-through-wcf http://msdn.microsoft.com/en-us/library/aa702621.aspx 3. A potentially dangerous Request.Form value was detected from the client (wresult=&#8221;&#60;trust:RequestSecuri&#8230;&#8221;). Solutions: Make [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=hoachau.wordpress.com&#038;blog=6974136&#038;post=177&#038;subd=hoachau&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<h2><em>1. m_safeCertContext is an invalid handle</em></h2>
<p>I got this issue when try to assign a X509SigningCredentials to the custom STSConfiguration.</p>
<p><pre class="brush: csharp;">

this.SigningCredentials = new X509SigningCredentials(cert);

</pre></p>
<p>Solutions:</p>
<p>Make sure don&#8217;t call cert.Reset() before passing the cert to X509SigningCredentials constructor</p>
<h2><em>2. Keyset does not exist</em></h2>
<p>Solutions:</p>
<p><a title="http://stackoverflow.com/questions/602345/cryptographicexception-keyset-does-not-exist-but-only-through-wcf" href="http://stackoverflow.com/questions/602345/cryptographicexception-keyset-does-not-exist-but-only-through-wcf">http://stackoverflow.com/questions/602345/cryptographicexception-keyset-does-not-exist-but-only-through-wcf</a></p>
<p><a title="http://msdn.microsoft.com/en-us/library/aa702621.aspx" href="http://msdn.microsoft.com/en-us/library/aa702621.aspx">http://msdn.microsoft.com/en-us/library/aa702621.aspx</a></p>
<h2><em>3. A potentially dangerous Request.Form value was detected from the client (wresult=&#8221;&lt;trust:RequestSecuri&#8230;&#8221;).</em></h2>
<p>Solutions:</p>
<p>Make sure you have this setting in your web.config (under system.web)</p>
<p><pre class="brush: xml;">

&lt;httpRuntime requestValidationMode=&quot;2.0&quot;/&gt;

</pre></p>
<p><a title="http://social.msdn.microsoft.com/Forums/en-US/Geneva/thread/b6428ea6-e705-4c66-a6fe-8e9f51f73311" href="http://social.msdn.microsoft.com/Forums/en-US/Geneva/thread/b6428ea6-e705-4c66-a6fe-8e9f51f73311">http://social.msdn.microsoft.com/Forums/en-US/Geneva/thread/b6428ea6-e705-4c66-a6fe-8e9f51f73311</a></p>
<p><a title="http://volkanuzun.com/blog/post/2010/10/14/A-potentially-dangerous-RequestForm-value-was-detected-from-the-client-(wresult3d3ctrustRequestSecuri).aspx" href="http://volkanuzun.com/blog/post/2010/10/14/A-potentially-dangerous-RequestForm-value-was-detected-from-the-client-(wresult3d3ctrustRequestSecuri).aspx">http://volkanuzun.com/blog/post/2010/10/14/A-potentially-dangerous-RequestForm-value-was-detected-from-the-client-(wresult3d3ctrustRequestSecuri).aspx</a></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/hoachau.wordpress.com/177/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/hoachau.wordpress.com/177/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=hoachau.wordpress.com&#038;blog=6974136&#038;post=177&#038;subd=hoachau&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://hoachau.wordpress.com/2012/03/13/troubleshooting/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://2.gravatar.com/avatar/e2870042f2876cf45af75f17cc5098bd?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">hoachau</media:title>
		</media:content>
	</item>
		<item>
		<title>Generating Federation Metadata using WIF APIs</title>
		<link>http://hoachau.wordpress.com/2012/02/22/generating-federation-metadata-using-wif-apis/</link>
		<comments>http://hoachau.wordpress.com/2012/02/22/generating-federation-metadata-using-wif-apis/#comments</comments>
		<pubDate>Wed, 22 Feb 2012 07:00:12 +0000</pubDate>
		<dc:creator>hoachau</dc:creator>
				<category><![CDATA[.Net]]></category>
		<category><![CDATA[WIF]]></category>

		<guid isPermaLink="false">http://hoachau.wordpress.com/?p=172</guid>
		<description><![CDATA[Just like all the Service Oriented approaches, metadata is the key, for example, with web services, you just have to build the service (using ASMX file or WCF) it will generate the WSDL file for your service automatically, so the client code can easily consume. We expect the same thing with WIF, unfortunately, we cannot [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=hoachau.wordpress.com&#038;blog=6974136&#038;post=172&#038;subd=hoachau&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>Just like all the Service Oriented approaches, metadata is the key, for example, with web services, you just have to build the service (using ASMX file or WCF) it will generate the WSDL file for your service automatically, so the client code can easily consume. We expect the same thing with WIF, unfortunately, we cannot just build a STS and then somehow it exposes the federation metadata for that.</p>
<p>Most of the samples in WIF SDK and the Programming WIF book are showing you how to generate the metadata from a Visual Studio template. But there is almost no documentation on how to create the federation metadata manually (or dynamically), especially when you build a custom STS using MVC (hopefully we will have the template for MVC soon, but still not solving the dynamic issue).</p>
<p>WIF itself does provide APIs for this task, below are some very simple codes (I copy most of them from <a title="http://netpl.blogspot.com/2011/08/quest-for-customizing-adfs-sign-in-web.html" href="http://netpl.blogspot.com/2011/08/quest-for-customizing-adfs-sign-in-web.html">http://netpl.blogspot.com/2011/08/quest-for-customizing-adfs-sign-in-web.html</a>). I just tried to put thing together and see how to use the WIF metadata API. For a more complete sample, please see the link above.</p>
<p><pre class="brush: csharp;">

const string _endpoint = &quot;http://yoursts.com&quot;;

static void Main(string[] args)
{
 string endpointId = _endpoint;
 EntityDescriptor entityDescriptor = new EntityDescriptor(
 new EntityId(endpointId));

 // Signature, I created a certificate using portecle and installed
 // it under TrustedPeople/CurrentUser
 X509Certificate2 cert =
 CertificateUtil.GetCertificate(
 StoreName.TrustedPeople, StoreLocation.CurrentUser, &quot;CN=HoaSTSCert, C=US&quot;);

 entityDescriptor.SigningCredentials = new X509SigningCredentials(cert);

 SecurityTokenServiceDescriptor roleDescriptor = new SecurityTokenServiceDescriptor();

 // required protocols supported
 roleDescriptor.ProtocolsSupported.Add(new Uri(WSFederationMetadataConstants.Namespace));
 roleDescriptor.Contacts.Add(new ContactPerson(ContactType.Administrative));

 // This section is for key descriptor
 SecurityKeyIdentifierClause clause = new X509RawDataKeyIdentifierClause(cert);
 SecurityKeyIdentifier ski = new SecurityKeyIdentifier(clause);
 KeyDescriptor signingKey = new KeyDescriptor(ski);
 signingKey.Use = KeyType.Signing;
 roleDescriptor.Keys.Add(signingKey);

// This section is for endpoint
 string activeSTSUrl = _endpoint;
 EndpointAddress endpointAddress = new EndpointAddress(
 new Uri(activeSTSUrl),
 null,
 null,
 (XmlDictionaryReader)null,
 null);

 // Active endpoint
 roleDescriptor.SecurityTokenServiceEndpoints.Add(endpointAddress);
 // Passive endpoint
 roleDescriptor.PassiveRequestorEndpoints.Add(endpointAddress);

 roleDescriptor.ClaimTypesOffered.Add(new DisplayClaim(ClaimTypes.Role));
 roleDescriptor.ClaimTypesOffered.Add(new DisplayClaim(ClaimTypes.Name));

 entityDescriptor.RoleDescriptors.Add(roleDescriptor);

 // Serialize process...
 MetadataSerializer serializer = new MetadataSerializer();

 //MemoryStream stream = new MemoryStream();
 string fileName = @&quot;FederationMetadata.xml&quot;;
 XmlWriter writer = XmlWriter.Create(fileName);
 XmlWriterSettings settings = new XmlWriterSettings();
 settings.Indent = true;

 serializer.WriteMetadata(writer, entityDescriptor);

 writer.Flush();

 Console.WriteLine(&quot;done...&quot;);
 Console.WriteLine(string.Format(&quot;Output: {0}&quot;,
 Path.Combine(Environment.CurrentDirectory, fileName)));
}

</pre></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/hoachau.wordpress.com/172/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/hoachau.wordpress.com/172/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=hoachau.wordpress.com&#038;blog=6974136&#038;post=172&#038;subd=hoachau&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://hoachau.wordpress.com/2012/02/22/generating-federation-metadata-using-wif-apis/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://2.gravatar.com/avatar/e2870042f2876cf45af75f17cc5098bd?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">hoachau</media:title>
		</media:content>
	</item>
		<item>
		<title>ASP.NET Error pages</title>
		<link>http://hoachau.wordpress.com/2012/01/05/asp-net-error-pages/</link>
		<comments>http://hoachau.wordpress.com/2012/01/05/asp-net-error-pages/#comments</comments>
		<pubDate>Thu, 05 Jan 2012 05:37:21 +0000</pubDate>
		<dc:creator>hoachau</dc:creator>
				<category><![CDATA[.Net]]></category>
		<category><![CDATA[Asp.Net]]></category>
		<category><![CDATA[Design patterns]]></category>
		<category><![CDATA[Fun]]></category>
		<category><![CDATA[Lessons Learned]]></category>

		<guid isPermaLink="false">http://hoachau.wordpress.com/?p=165</guid>
		<description><![CDATA[That is interesting that my previous post talked about error pages in asp.net and yesterday I got this (see image below) when I tried to access blackberry online shopping site That is good to know that this website is built using ASP.NET MVC, WCF and a Controller-Service-Repository pattern, so instead of disappointed cause the website [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=hoachau.wordpress.com&#038;blog=6974136&#038;post=165&#038;subd=hoachau&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>That is interesting that my previous post talked about error pages in asp.net and yesterday I got this (see image below) when I tried to access blackberry online shopping site</p>
<p><a href="http://hoachau.files.wordpress.com/2012/01/blackberry.jpg"><img class="alignnone size-full wp-image-166" title="blackberry" src="http://hoachau.files.wordpress.com/2012/01/blackberry.jpg?w=869" alt=""   /></a></p>
<p>That is good to know that this website is built using ASP.NET MVC, WCF and a Controller-Service-Repository pattern, so instead of disappointed cause the website crashed, I felt like this is built by some of my &#8220;friends&#8221; <img src='http://s0.wp.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>PS: the good news is it was fixed right after that!</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/hoachau.wordpress.com/165/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/hoachau.wordpress.com/165/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=hoachau.wordpress.com&#038;blog=6974136&#038;post=165&#038;subd=hoachau&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://hoachau.wordpress.com/2012/01/05/asp-net-error-pages/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://2.gravatar.com/avatar/e2870042f2876cf45af75f17cc5098bd?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">hoachau</media:title>
		</media:content>

		<media:content url="http://hoachau.files.wordpress.com/2012/01/blackberry.jpg" medium="image">
			<media:title type="html">blackberry</media:title>
		</media:content>
	</item>
		<item>
		<title>404 on MVC</title>
		<link>http://hoachau.wordpress.com/2011/12/02/404-on-mvc/</link>
		<comments>http://hoachau.wordpress.com/2011/12/02/404-on-mvc/#comments</comments>
		<pubDate>Fri, 02 Dec 2011 07:07:14 +0000</pubDate>
		<dc:creator>hoachau</dc:creator>
				<category><![CDATA[Asp.Net]]></category>

		<guid isPermaLink="false">http://hoachau.wordpress.com/?p=160</guid>
		<description><![CDATA[If you are running IIS 7.x, there is a very simple solution to handle 404 (Page Not Found). I found this solution from http://stackoverflow.com/questions/619895/how-can-i-properly-handle-404-in-asp-net-mvc/7967759#7967759<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=hoachau.wordpress.com&#038;blog=6974136&#038;post=160&#038;subd=hoachau&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>If you are running IIS 7.x, there is a very simple solution to handle 404 (Page Not Found). I found this solution from</p>
<p><a title="http://stackoverflow.com/questions/619895/how-can-i-properly-handle-404-in-asp-net-mvc/7967759#7967759" href="http://stackoverflow.com/questions/619895/how-can-i-properly-handle-404-in-asp-net-mvc/7967759#7967759">http://stackoverflow.com/questions/619895/how-can-i-properly-handle-404-in-asp-net-mvc/7967759#7967759</a></p>
<p><pre class="brush: xml;">
&lt;system.webServer&gt;
&lt;httpErrors errorMode=&quot;Custom&quot; existingResponse=&quot;Replace&quot;&gt;
&lt;remove statusCode=&quot;404&quot; /&gt;
&lt;error statusCode=&quot;404&quot; responseMode=&quot;ExecuteURL&quot; path=&quot;/Error/PageNotFound&quot; /&gt;
&lt;/httpErrors&gt;
&lt;/system.webServer&gt;
</pre></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/hoachau.wordpress.com/160/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/hoachau.wordpress.com/160/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=hoachau.wordpress.com&#038;blog=6974136&#038;post=160&#038;subd=hoachau&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://hoachau.wordpress.com/2011/12/02/404-on-mvc/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://2.gravatar.com/avatar/e2870042f2876cf45af75f17cc5098bd?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">hoachau</media:title>
		</media:content>
	</item>
		<item>
		<title>Default browser</title>
		<link>http://hoachau.wordpress.com/2011/04/20/default-browser/</link>
		<comments>http://hoachau.wordpress.com/2011/04/20/default-browser/#comments</comments>
		<pubDate>Wed, 20 Apr 2011 07:53:58 +0000</pubDate>
		<dc:creator>hoachau</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://hoachau.wordpress.com/?p=157</guid>
		<description><![CDATA[Recently, I&#8217;m having some issues when deal with the default browser. There is breaking change on Vista (and Win7) as described here http://newoldthing.wordpress.com/2007/03/23/how-does-your-browsers-know-that-its-not-the-default-browser/<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=hoachau.wordpress.com&#038;blog=6974136&#038;post=157&#038;subd=hoachau&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>Recently, I&#8217;m having some issues when deal with the default browser. There is breaking change on Vista (and Win7) as described here</p>
<p><a title="http://newoldthing.wordpress.com/2007/03/23/how-does-your-browsers-know-that-its-not-the-default-browser/" href="http://newoldthing.wordpress.com/2007/03/23/how-does-your-browsers-know-that-its-not-the-default-browser/" target="_blank">http://newoldthing.wordpress.com/2007/03/23/how-does-your-browsers-know-that-its-not-the-default-browser/</a></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/hoachau.wordpress.com/157/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/hoachau.wordpress.com/157/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=hoachau.wordpress.com&#038;blog=6974136&#038;post=157&#038;subd=hoachau&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://hoachau.wordpress.com/2011/04/20/default-browser/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://2.gravatar.com/avatar/e2870042f2876cf45af75f17cc5098bd?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">hoachau</media:title>
		</media:content>
	</item>
		<item>
		<title>Database diagram support objects cannot be installed&#8230;</title>
		<link>http://hoachau.wordpress.com/2011/02/22/database-diagram-support-objects-cannot-be-installed/</link>
		<comments>http://hoachau.wordpress.com/2011/02/22/database-diagram-support-objects-cannot-be-installed/#comments</comments>
		<pubDate>Tue, 22 Feb 2011 00:33:51 +0000</pubDate>
		<dc:creator>hoachau</dc:creator>
				<category><![CDATA[SQL]]></category>

		<guid isPermaLink="false">http://hoachau.wordpress.com/?p=151</guid>
		<description><![CDATA[This is the second time I ran into this issue and think I should copy it here so that I don&#8217;t have to google it next time. The solution has been posted on http://social.msdn.microsoft.com/Forums/en/sqldatabaseengine/thread/9a9bf26c-bb14-4353-a4ec-ab53d68d6afc Below is the script from that post<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=hoachau.wordpress.com&#038;blog=6974136&#038;post=151&#038;subd=hoachau&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>This is the second time I ran into this issue and think I should copy it here so that I don&#8217;t have to google it next time. The solution has been posted on</p>
<p><a href="http://social.msdn.microsoft.com/Forums/en/sqldatabaseengine/thread/9a9bf26c-bb14-4353-a4ec-ab53d68d6afc"> http://social.msdn.microsoft.com/Forums/en/sqldatabaseengine/thread/9a9bf26c-bb14-4353-a4ec-ab53d68d6afc</a></p>
<p>Below is the script from that post</p>
<p><pre class="brush: sql;">

EXEC sp_dbcmptlevel 'yourDB', '90';
go
ALTER AUTHORIZATION ON DATABASE::yourDB TO &quot;yourLogin&quot;
go
use [yourDB]
go
EXECUTE AS USER = N'dbo' REVERT

go

</pre></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/hoachau.wordpress.com/151/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/hoachau.wordpress.com/151/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=hoachau.wordpress.com&#038;blog=6974136&#038;post=151&#038;subd=hoachau&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://hoachau.wordpress.com/2011/02/22/database-diagram-support-objects-cannot-be-installed/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://2.gravatar.com/avatar/e2870042f2876cf45af75f17cc5098bd?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">hoachau</media:title>
		</media:content>
	</item>
		<item>
		<title>Run Windows Explorer as Administrator</title>
		<link>http://hoachau.wordpress.com/2010/12/07/run-windows-explorer-as-administrator/</link>
		<comments>http://hoachau.wordpress.com/2010/12/07/run-windows-explorer-as-administrator/#comments</comments>
		<pubDate>Tue, 07 Dec 2010 06:08:27 +0000</pubDate>
		<dc:creator>hoachau</dc:creator>
				<category><![CDATA[Security]]></category>

		<guid isPermaLink="false">http://hoachau.wordpress.com/?p=142</guid>
		<description><![CDATA[Have you ever frustrated when right click on Windows Explorer icon and select “Run as Administrator” but still got some kind of “Access Is Denied” message? The reason is Windows Explorer still doesn’t run under Admin right. Below is how to solve the problem according to http://www.msfn.org/board/topic/144776-unable-to-open-an-elevated-windows-explorer-window/ But I just want to put it here [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=hoachau.wordpress.com&#038;blog=6974136&#038;post=142&#038;subd=hoachau&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>Have you ever frustrated when right click on Windows Explorer icon and select “Run as Administrator” but still got some kind of “Access Is Denied” message? The reason is Windows Explorer still doesn’t run under Admin right. Below is how to solve the problem according to <a title="http://www.msfn.org/board/topic/144776-unable-to-open-an-elevated-windows-explorer-window/" href="http://www.msfn.org/board/topic/144776-unable-to-open-an-elevated-windows-explorer-window/">http://www.msfn.org/board/topic/144776-unable-to-open-an-elevated-windows-explorer-window/</a></p>
<p>But I just want to put it here for my reference<br />
1. Run dcomcnfg.exe<br />
2. Flow screens below</p>
<p><a href="http://hoachau.files.wordpress.com/2010/12/explorer.jpg"><img class="alignnone size-full wp-image-143" title="explorer" src="http://hoachau.files.wordpress.com/2010/12/explorer.jpg?w=869" alt=""   /></a></p>
<p>This is particularly useful when you want to install assemblies into GAC in your production servers those don’t have Windows SDK.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/hoachau.wordpress.com/142/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/hoachau.wordpress.com/142/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=hoachau.wordpress.com&#038;blog=6974136&#038;post=142&#038;subd=hoachau&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://hoachau.wordpress.com/2010/12/07/run-windows-explorer-as-administrator/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://2.gravatar.com/avatar/e2870042f2876cf45af75f17cc5098bd?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">hoachau</media:title>
		</media:content>

		<media:content url="http://hoachau.files.wordpress.com/2010/12/explorer.jpg" medium="image">
			<media:title type="html">explorer</media:title>
		</media:content>
	</item>
		<item>
		<title>Test Expected Exception with NUnit 2.5</title>
		<link>http://hoachau.wordpress.com/2010/12/05/test-expected-exception-with-nunit-2-5/</link>
		<comments>http://hoachau.wordpress.com/2010/12/05/test-expected-exception-with-nunit-2-5/#comments</comments>
		<pubDate>Sun, 05 Dec 2010 10:54:57 +0000</pubDate>
		<dc:creator>hoachau</dc:creator>
				<category><![CDATA[.Net]]></category>
		<category><![CDATA[Unit Test]]></category>

		<guid isPermaLink="false">http://hoachau.wordpress.com/?p=135</guid>
		<description><![CDATA[Testing the expected exceptions has been improved a lot by NUnit 2.5, let says you have a scenario that a method checks for the input parameters and throws some ArgumentNullException exceptions, it was kind of cumbersome to cover all those cases in your tests, normally, you will have multiple test methods using ExpectedExceptionAttribute. But with [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=hoachau.wordpress.com&#038;blog=6974136&#038;post=135&#038;subd=hoachau&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>Testing the expected exceptions has been improved a lot by NUnit 2.5, let says you have a scenario that a method checks for the input parameters and throws some ArgumentNullException exceptions, it was kind of cumbersome to cover all those cases in your tests, normally, you will have multiple test methods using ExpectedExceptionAttribute. But with NUnit 2.5.x, we can write something likes</p>
<p><pre class="brush: csharp;">

[Test]

public void AndSpecification_Construction_With_Null_Inputs_Test()

{

   // Arrange
   ISpecification&lt;MockEntity&gt; spec = new Moq.Mock&lt;ISpecification&lt;MockEntity&gt;&gt;().Object;

   // Passing null for the left specification
   Assert.That(() =&gt; new AndSpecification&lt;MockEntity&gt;(null, spec),
      Throws.TypeOf&lt;ArgumentNullException&gt;()
         .With.Property(&quot;ParamName&quot;).EqualTo(&quot;left&quot;));

   // Passing null for the right specification
   Assert.That(() =&gt; new AndSpecification&lt;MockEntity&gt;(spec, null),
      Throws.TypeOf&lt;ArgumentNullException&gt;()
         .With.Property(&quot;ParamName&quot;).EqualTo(&quot;right&quot;));

}

</pre></p>
<p>One single method can handle multiple cases.</p>
<p>You can find more details information from <a title="http://nunit.net/blogs/?p=63" href="http://nunit.net/blogs/?p=63">http://nunit.net/blogs/?p=63</a></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/hoachau.wordpress.com/135/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/hoachau.wordpress.com/135/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=hoachau.wordpress.com&#038;blog=6974136&#038;post=135&#038;subd=hoachau&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://hoachau.wordpress.com/2010/12/05/test-expected-exception-with-nunit-2-5/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://2.gravatar.com/avatar/e2870042f2876cf45af75f17cc5098bd?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">hoachau</media:title>
		</media:content>
	</item>
		<item>
		<title>Reuse is good!</title>
		<link>http://hoachau.wordpress.com/2010/10/21/resue-is-good/</link>
		<comments>http://hoachau.wordpress.com/2010/10/21/resue-is-good/#comments</comments>
		<pubDate>Thu, 21 Oct 2010 06:44:53 +0000</pubDate>
		<dc:creator>hoachau</dc:creator>
				<category><![CDATA[Design patterns]]></category>

		<guid isPermaLink="false">http://hoachau.wordpress.com/?p=128</guid>
		<description><![CDATA[One of the theme that I’ve always seen in design when people try to create some kind of “framework” is the heavily use of inheritance. Because one of the thing that people has been taught is “reuse is good”. Looks at the design below (noted that this design has nothing to do with DDD) The [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=hoachau.wordpress.com&#038;blog=6974136&#038;post=128&#038;subd=hoachau&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>One of the theme that I’ve always seen in design when people try to create some kind of “framework” is the heavily use of inheritance. Because one of the thing that people has been taught is “reuse is good”. Looks at the design below (noted that this design has nothing to do with DDD)</p>
<p><a href="http://hoachau.files.wordpress.com/2010/10/1.jpg"><img class="alignnone size-full wp-image-129" title="1" src="http://hoachau.files.wordpress.com/2010/10/1.jpg?w=869" alt=""   /></a></p>
<p>The same design is applied for repositories…</p>
<p>And the only reason to have this kind of design is for reusability, no infrastructure codes can easily deal with IService&lt;T&gt; or any other base classes in this design. (And there is no reason for infrastructure codes to deal with those things)</p>
<p>The next question is what happens if the UserService (or any service class) doesn’t need all functions implemented in the base class? What happens if there are some business rules need to be checked? (Then the workaround is to add more abstract methods around all functions in the base class)</p>
<p>The point here is: There is no reason to create a complex but not very useful design. My preferable design is something likes</p>
<p><a href="http://hoachau.files.wordpress.com/2010/10/2.jpg"><img class="alignnone size-full wp-image-130" title="2" src="http://hoachau.files.wordpress.com/2010/10/2.jpg?w=869" alt=""   /></a></p>
<p>We can still reuse some of the codes through composition but not inheritance, there is a well written blog post discuss almost the same issue here <a href="http://codebetter.com/blogs/gregyoung/archive/2009/01/16/ddd-the-generic-repository.aspx">http://codebetter.com/blogs/gregyoung/archive/2009/01/16/ddd-the-generic-repository.aspx</a></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/hoachau.wordpress.com/128/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/hoachau.wordpress.com/128/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=hoachau.wordpress.com&#038;blog=6974136&#038;post=128&#038;subd=hoachau&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://hoachau.wordpress.com/2010/10/21/resue-is-good/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://2.gravatar.com/avatar/e2870042f2876cf45af75f17cc5098bd?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">hoachau</media:title>
		</media:content>

		<media:content url="http://hoachau.files.wordpress.com/2010/10/1.jpg" medium="image">
			<media:title type="html">1</media:title>
		</media:content>

		<media:content url="http://hoachau.files.wordpress.com/2010/10/2.jpg" medium="image">
			<media:title type="html">2</media:title>
		</media:content>
	</item>
		<item>
		<title>When LTRIM() and RTRIM() do not work</title>
		<link>http://hoachau.wordpress.com/2010/10/15/when-ltrim-and-rtrim-do-not-work/</link>
		<comments>http://hoachau.wordpress.com/2010/10/15/when-ltrim-and-rtrim-do-not-work/#comments</comments>
		<pubDate>Fri, 15 Oct 2010 06:57:11 +0000</pubDate>
		<dc:creator>hoachau</dc:creator>
				<category><![CDATA[SQL]]></category>

		<guid isPermaLink="false">http://hoachau.wordpress.com/?p=124</guid>
		<description><![CDATA[When I analyzed the data from an Access database before import into our SQL database, I saw some strings with extra spaces at the end. So I thought I could simply use the RTRIM() function, I quickly put together a script and ran -&#62; NOTHING WORKED Tried couple times, the result still the same. It [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=hoachau.wordpress.com&#038;blog=6974136&#038;post=124&#038;subd=hoachau&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>When I analyzed the data from an Access database before import into our SQL database, I saw some strings with extra spaces at the end. So I thought I could simply use the RTRIM() function, I quickly put together a script and ran -&gt; NOTHING WORKED</p>
<p>Tried couple times, the result still the same. It turns out there is a note in SQL Online Book</p>
<blockquote><p>LTRIM does not remove white-space characters such as the tab or line feed  characters&#8230;</p></blockquote>
<p>And the spaces in the data are LFs (char(10)).  The solution is to replace those char(10) with a space (char(32)) before calling RTRIM()</p>
<p><pre class="brush: sql;">

UPDATE dbo.Cause_1
SET Result =  (RTRIM(REPLACE(Result, CHAR(10), CHAR(32))))

</pre></p>
<p>A more complete solution can be found at</p>
<p><a href="http://blog.programmingsolution.net/sql-server-2008/removing-leading-and-trailing-white-space-characters-in-tsql/">http://blog.programmingsolution.net/sql-server-2008/removing-leading-and-trailing-white-space-characters-in-tsql/</a></p>
<p>&nbsp;</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/hoachau.wordpress.com/124/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/hoachau.wordpress.com/124/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=hoachau.wordpress.com&#038;blog=6974136&#038;post=124&#038;subd=hoachau&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://hoachau.wordpress.com/2010/10/15/when-ltrim-and-rtrim-do-not-work/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://2.gravatar.com/avatar/e2870042f2876cf45af75f17cc5098bd?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">hoachau</media:title>
		</media:content>
	</item>
	</channel>
</rss>
