<?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>spiroville.com &#187; .Net</title>
	<atom:link href="http://spiroville.com/blog/category/net/feed/" rel="self" type="application/rss+xml" />
	<link>http://spiroville.com/blog</link>
	<description></description>
	<lastBuildDate>Mon, 07 Dec 2009 18:16:03 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.6</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Exception Shielding</title>
		<link>http://spiroville.com/blog/2009/07/07/exception-shielding/</link>
		<comments>http://spiroville.com/blog/2009/07/07/exception-shielding/#comments</comments>
		<pubDate>Tue, 07 Jul 2009 04:34:15 +0000</pubDate>
		<dc:creator>Randy</dc:creator>
				<category><![CDATA[.Net]]></category>

		<guid isPermaLink="false">http://spiroville.com/blog/?p=134</guid>
		<description><![CDATA[My previous post spent over 600 words knocking down the Exception Handling Block, but version 3 and higher does have one nice feature: WCF Exception Shielding.  This allows exceptions received by a WCF service to be mapped to Fault Contracts.
Exception shielding is important in order to hide internal implementation details from service consumers.  This can [...]]]></description>
			<content:encoded><![CDATA[<p>My <a href="http://spiroville.com/blog/2009/05/17/exception-handling-block-enterprise-library/" target="_blank">previous post</a> spent over 600 words knocking down the Exception Handling Block, but version 3 and higher does have one nice feature: WCF Exception <span class="il">Shielding</span>.  This allows exceptions received by a WCF service to be mapped to Fault Contracts.</p>
<p>Exception shielding is important in order to hide internal implementation details from service consumers.  This can make your service easier to use and, more importantly, prevent exposing sensitive internal information in your exceptions.</p>
<p><a href="http://www.devx.com/dotnet/Article/35736/0/page/4" target="_blank">Enterprise Library Exception Shielding </a>seems to be a good use of configuration to decouple a service interface from the underlying implementation.</p>
]]></content:encoded>
			<wfw:commentRss>http://spiroville.com/blog/2009/07/07/exception-shielding/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Exception Handling (Block) &amp; Enterprise Library</title>
		<link>http://spiroville.com/blog/2009/05/17/exception-handling-block-enterprise-library/</link>
		<comments>http://spiroville.com/blog/2009/05/17/exception-handling-block-enterprise-library/#comments</comments>
		<pubDate>Sun, 17 May 2009 04:38:14 +0000</pubDate>
		<dc:creator>Randy</dc:creator>
				<category><![CDATA[.Net]]></category>

		<guid isPermaLink="false">http://spiroville.com/blog/?p=104</guid>
		<description><![CDATA[Lately, I've been thinking about exceptions vs. error codes.  As usual, Joel On Software has a couple of well thought out posts on the topic.  The first post makes the point that exceptions "create too many possible exit points for a function".  The second post, Making Wrong Code Look Wrong makes some [...]]]></description>
			<content:encoded><![CDATA[<p>Lately, I've been thinking about exceptions vs. error codes.  As usual, <a href="http://www.joelonsoftware.com" target="_blank">Joel On Software</a> has a couple of well thought out posts on the topic.  The <a href="http://www.joelonsoftware.com/items/2003/10/13.html" target="_blank">first post</a> makes the point that exceptions "create too many possible exit points for a function".  The second post, <a href="http://www.joelonsoftware.com/articles/Wrong.html" target="_blank">Making Wrong Code Look Wrong</a> makes some very good points on exception handling as well as other topics.  In the same way that compile time errors are better than runtime errors, it is better to find errors in code simply by reading the code than by being forced to run or debug the code.  That seems like a pretty straight forward statement to me but I'm wondering if people actually agree with it -- what with the popularity of various frameworks where everything is hung together with configuration files.</p>
<p>Those two ideas -- exceptions as flow control and making code look wrong -- led me to think about why I really, really dislike <a href="http://www.codeplex.com/entlib" target="_blank">Microsoft's Enterprise Library</a> <a href="http://msdn.microsoft.com/en-us/library/cc309505.aspx" target="_blank">Exception Handling Block</a>: it combines the worst parts of both.</p>
<p>Consider the following:</p>
<div class="igBar"><span id="lcsharp-2"><a href="#" onclick="javascript:showPlainTxt('csharp-2'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">C#:</span>
<div id="csharp-2">
<div class="csharp">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #0600FF;">try</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #000000;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; DoSomething<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #000000;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #0600FF;">catch</span> <span style="color: #000000;">&#40;</span>Exception e<span style="color: #000000;">&#41;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #000000;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #FF0000;">bool</span> rethrow = </div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; ExceptionManager.<span style="color: #0000FF;">HandleException</span><span style="color: #000000;">&#40;</span>e, </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080;">"MySpecialPolicy"</span><span style="color: #000000;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #0600FF;">if</span> <span style="color: #000000;">&#40;</span>rethrow<span style="color: #000000;">&#41;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #000000;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF;">throw</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #000000;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #000000;">&#125;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>My objection: <strong>you have no idea what the exception handler does!</strong>  </p>
<p>Since you can't tell what will happen at this one point, you can't mentally trace the program flow to see if it's logically sound.  This makes development, tracking down bugs, and overall maintenance difficult. </p>
<p>"Wait, wait, wait", you say.  "You can create meaningful policy names to avoid this kind of confusion".  Yes, you can change the policy name to something more meaningful like "BusinessLayerMustRethrowPolicy" so you can understand the intent of the code -- which is a good thing.  However, you still have no idea of the actual behavior at run time since the configuration could be set to not rethrow (for some reason).  Plus, if you are making your exception handling configuration based, then you are implicitly saying that you allow the configuration to be changed to another setting (e.g. not rethrow an exception).  Isn't that the point of putting things in configuration?  To allow behavior to be changed without changing the code.</p>
<p>Since throwing an exception changes the flow of the program, if you modify the Exception Handling Block configuration (behavior) then you are actually creating a new execution path.  Does that mean the program should run "properly" for all possible settings of the configuration?  (Not likely!)  Do you then have to test all of those possible code paths?</p>
<p>Maybe you could implement a policy of no configuration changes without a full test cycle but then how is that much different than performing a code change?  You do skip the issue of introducing a new coding bug<br />
and you avoid a build but you still need to create some sort of deployment package and go through a release cycle (which is the most expensive part in this lifecycle).  Plus there is always the chance of the configuration becoming incorrect "by accident" and the new execution path may introduce some undesirable behavior.  e.g. maybe database changes are committed because, even though an exception occurred, the policy said to not throw an exception and the calling code assumed that all errors would be reported as exceptions.</p>
<p>Other objections to the Exception Handling Block: </p>
<ul>
<li>As a framework, the "if rethrow" construct doesn't really offer a lot of abstraction; you still need to pepper your code with "if rethrow" code in every catch block.
</li>
<li>If you try to use the logging block to log an exception, every log entry for that handler shares all of the same basic log entry information (e.g. event ID).  This can be restricting if you need that kind of control.</li>
</ul>
<p>In general, I avoid the Exception Handling Application Block because it obfuscates the functioning of the program which makes the program harder to understand and maintain.  To me this outweighs any functionality provided by the block.</p>
]]></content:encoded>
			<wfw:commentRss>http://spiroville.com/blog/2009/05/17/exception-handling-block-enterprise-library/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>&#8220;Project not found&#8221; problem loading a Solution with a Web Project in Visual Studio 2003 and VSS 6.0</title>
		<link>http://spiroville.com/blog/2007/03/07/project-not-found-problem-loading-a-solution-with-a-web-project-in-visual-studio-2003-and-vss-60/</link>
		<comments>http://spiroville.com/blog/2007/03/07/project-not-found-problem-loading-a-solution-with-a-web-project-in-visual-studio-2003-and-vss-60/#comments</comments>
		<pubDate>Thu, 08 Mar 2007 05:20:13 +0000</pubDate>
		<dc:creator>Randy</dc:creator>
				<category><![CDATA[.Net]]></category>

		<guid isPermaLink="false">http://spiroville.com/blog/?p=22</guid>
		<description><![CDATA[I was trying to integrate my solution which contains a web project with Visual Source Safe and was getting the message: "Unable to read the project file. The system can not find the file specified."
I found a good article on how to fix this at: http://www.inventua.com/blogs.content?EntryID=3
Unfortunately, this didn't fix my problem.
I had a variety of [...]]]></description>
			<content:encoded><![CDATA[<p align="left">I was trying to integrate my solution which contains a web project with Visual Source Safe and was getting the message: "Unable to read the project file. The system can not find the file specified."</p>
<p align="left">I found a good article on how to fix this at: <a href="http://www.inventua.com/blogs.content?EntryID=3" target="_blank">http://www.inventua.com/blogs.content?EntryID=3</a></p>
<p align="left">Unfortunately, this didn't fix my problem.</p>
<p align="left">I had a variety of issues with VSS asp.net integration.  What I specifically wanted to do was:</p>
<p align="left">1) Have my web project be under the same directory structure as my solution (not in c:\inetpub\wwwroot)<br />
2) Have the web location be different from the actual web project name.  e.g. the web project name is Com.TestApp.UI.Web but I actually want the location to be http://localhost/TestApp and not http://localhost/Com.TestApp.UI.Web .   It is possible to deploy the project to any URL but I wanted everything to be consistent in every environment.</p>
<p align="left">I've read a lot of articles which helped but no one article could solve my exact issues.  This is the procedure that I had to work through to get the Visual Studio/VSS integration working.</p>
<p align="left"><strong>Assumptions</strong></p>
<p align="left">1) Assume solution is [my solution]<br />
2) Assume web project is [my web project]<br />
3) Assume virtual root name is [my virtual root] -- this may be the same as [my web project]<br />
4) Assume user logged on is [user]</p>
<p align="left">If the project has been already attempted to be loaded, we should clean up first:</p>
<p align="left"><strong>Clean Up</strong></p>
<p align="left">1) Delete the VSWebCache directory C:\documents and settings\[user]\VSWebCache\[my virtual root] if it exists<br />
2) Delete the virtual root [my virtual root] from IIS<br />
3) delete the solution directory where [my solution] is currently located.  If any files are locked perform an IISRESET and also close VSS Explorer if applicable</p>
<p align="left"><strong>Configuration</strong></p>
<p align="left">1) Open up VSS Explorer.  Get latest version (recursive, build tree)<br />
2) Set permissions on the [my solution] directory.  Add IIS_WPG with the following permissions: Read, Read &amp; Execute, and List Folder Contents<br />
3) Open [my solution]<br />
4) The set project location dialog will open.  Hit cancel.<br />
5) Accept any other dialogs that may come up.<br />
6) Delete the project file from the [my web project] directory.<br />
7) Open IIS Admin and create a new virtual directory [my virtual root] that points to the directory that contains [my web project].   Accept all the defaults.  Open the [my virtual root] properties page and set the Execute Permissions to Scripts Only.  I did not add an application name.<br />
8 ) Now, back in Visual Studio, open the solution from source control.  (File-&gt;Source Control-&gt;Open From Source Control).  Browse to the solution folder in VSS.  Click overwrite when prompted.<br />
9) The set project location dialog will open again (as in step 4).  This time point to [my virtual root] and click OK.<br />
10) As a bonus delete the directory that was created by visual studio<br />
during step 4.  This will probably be in c:\inetpub\wwwroot\[my virtual root].  It's ok to delete this because the virtual root<br />
actually points some where else now.</p>
]]></content:encoded>
			<wfw:commentRss>http://spiroville.com/blog/2007/03/07/project-not-found-problem-loading-a-solution-with-a-web-project-in-visual-studio-2003-and-vss-60/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
