<?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>Chris Danielson&#039;s Blog &#187; .Net Development</title>
	<atom:link href="http://www.chrisdanielson.com/category/net-development/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.chrisdanielson.com</link>
	<description>Trials and Tribulations of a Software Developer</description>
	<lastBuildDate>Wed, 14 Sep 2011 00:00:51 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Windows 2008 IIS .Net SecurityException</title>
		<link>http://www.chrisdanielson.com/2010/09/18/windows-2008-iis-net-securityexception/</link>
		<comments>http://www.chrisdanielson.com/2010/09/18/windows-2008-iis-net-securityexception/#comments</comments>
		<pubDate>Sat, 18 Sep 2010 15:50:09 +0000</pubDate>
		<dc:creator>Chris Danielson</dc:creator>
				<category><![CDATA[.Net Development]]></category>
		<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[.Net]]></category>
		<category><![CDATA[AspNetHostingPermission]]></category>
		<category><![CDATA[caspol.exe]]></category>
		<category><![CDATA[SecurityException]]></category>
		<category><![CDATA[UNC]]></category>
		<category><![CDATA[Windows 2008]]></category>

		<guid isPermaLink="false">http://www.chrisdanielson.com/?p=374</guid>
		<description><![CDATA[<script type="text/javascript"><!--
google_ad_client = "pub-4268725654361605";
google_alternate_color = "FFFFFF";
google_ad_width = 234;
google_ad_height = 60;
google_ad_format = "234x60_as";
google_ad_type = "text_image";
google_ad_channel ="2722938917";
google_color_border = "FFFFFF";
google_color_link = "0022C9";
google_color_bg = "FFFFFF";
google_color_text = "000000";
google_color_url = "128A00";
google_ui_features = "rc:0";
//--></script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>I was attempting to install a .Net 3.5 application written in C# onto a Windows 2008 Enterprise R2 (64 bit) virtualized system.  What makes this a little unique is that the ASP.Net code is stored on a UNC file share.  Because of this issue, I received the following error: Security Exception Description: The application attempted [...]]]></description>
			<content:encoded><![CDATA[<script type="text/javascript"><!--
google_ad_client = "pub-ca-pub-7445498461482554";
google_alternate_color = "FFFFFF";
google_ad_width = 234;
google_ad_height = 60;
google_ad_format = "234x60_as";
google_ad_type = "text_image";
google_ad_channel ="";
google_color_border = "FFFFFF";
google_color_link = "0022C9";
google_color_bg = "FFFFFF";
google_color_text = "000000";
google_color_url = "128A00";
google_ui_features = "rc:0";
//--></script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script><p>I was attempting to install a .Net 3.5 application written in C# onto a Windows 2008 Enterprise R2 (64 bit) virtualized system.  What makes this a little unique is that the ASP.Net code is stored on a <strong>UNC file share</strong>.  Because of this issue, I received the following error:</p>
<blockquote><p><code>Security Exception<br />
Description: The application attempted to perform an operation not allowed by the security policy. To grant this application the required permission please contact your system administrator or change the application’s trust level in the configuration file.</code></p>
<p><code>Exception Details: System.Security.SecurityException: Request for the permission of type ‘System.Web.AspNetHostingPermission, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089′ failed.</code></p></blockquote>
<p>Initially I was baffled and with enough searching I came across the &#8220;caspol&#8221; <a href="http://support.microsoft.com/kb/320268">solution from Microsoft</a>.</p>
<p>Which in essence is:<br />
<code><br />
C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\caspol.exe -m -ag 1 -url "file:////\\fs\share\*" FullTrust -exclusive on<br />
</code></p>
<p>And of course, this doesn&#8217;t work!  I had overlooked that inside each .Net framework directory (yes there are two on 64 bit systems) is a separate configuration file.</p>
<p>By running the 64 bit caspol.exe command, I was able to quickly fix the issue.<br />
<code><br />
C:\WINDOWS\Microsoft.NET\Framework64\v2.0.50727\caspol.exe -m -ag 1 -url "file:////\\fs\share\*" FullTrust -exclusive on</code></p>
<p>I restarted the IIS service for good measure and we&#8217;re off to the races.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.chrisdanielson.com/2010/09/18/windows-2008-iis-net-securityexception/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>.Net C Sharp Date Range Check Method</title>
		<link>http://www.chrisdanielson.com/2009/07/21/net-c-sharp-date-range-check-method/</link>
		<comments>http://www.chrisdanielson.com/2009/07/21/net-c-sharp-date-range-check-method/#comments</comments>
		<pubDate>Tue, 21 Jul 2009 16:04:50 +0000</pubDate>
		<dc:creator>Chris Danielson</dc:creator>
				<category><![CDATA[.Net Development]]></category>
		<category><![CDATA[C Sharp]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[Date Range]]></category>
		<category><![CDATA[Development]]></category>

		<guid isPermaLink="false">http://www.chrisdanielson.com/?p=58</guid>
		<description><![CDATA[<script type="text/javascript"><!--
google_ad_client = "pub-ca-pub-7445498461482554";
google_alternate_color = "FFFFFF";
google_ad_width = 234;
google_ad_height = 60;
google_ad_format = "234x60_as";
google_ad_type = "text_image";
google_ad_channel ="";
google_color_border = "FFFFFF";
google_color_link = "0022C9";
google_color_bg = "FFFFFF";
google_color_text = "000000";
google_color_url = "128A00";
google_ui_features = "rc:0";
//--></script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>This function is a trivial example of how to do a basic date range check in .Net. I do a few silly conversions from string to timestamp only to serve as an example. View Code CSHARP/* Assumes the local culture. Does a check to see if the current time is within the range of 7 [...]]]></description>
			<content:encoded><![CDATA[<p>This function is a trivial example of how to do a basic date range check in .Net.  I do a few silly conversions from string to timestamp only to serve as an example.</p>

<div class="wp_codebox_msgheader"><span class="right"></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p58code3'); return false;">View Code</a> CSHARP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p583"><td class="code" id="p58code3"><pre class="csharp" style="font-family:monospace;"><span style="color: #008080; font-style: italic;">/*
Assumes the local culture.  
Does a check to see if the current time is within the range 
  of 7 AM and 1 PM.  If so, returns true.
*/</span>
<span style="color: #0600FF; font-weight: bold;">if</span> <span style="color: #008000;">&#40;</span>IsCurrentDateInRange<span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;7:00&quot;</span>, <span style="color: #666666;">&quot;13:00&quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span> <span style="color: #008000;">&#123;</span>
   <span style="color: #008080; font-style: italic;">//The current date is in range.</span>
<span style="color: #008000;">&#125;</span> <span style="color: #0600FF; font-weight: bold;">else</span> <span style="color: #008000;">&#123;</span>
  <span style="color: #008080; font-style: italic;">//The current date is out of range.</span>
<span style="color: #008000;">&#125;</span></pre></td></tr></table></div>


<div class="wp_codebox_msgheader"><span class="right"></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p58code4'); return false;">View Code</a> CSHARP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p584"><td class="code" id="p58code4"><pre class="csharp" style="font-family:monospace;"><span style="color: #0600FF; font-weight: bold;">using</span> <span style="color: #008080;">System</span><span style="color: #008000;">;</span>
<span style="color: #008080; font-style: italic;">/*
startTime should be in the format HH:mm such as 09:45
endTime should be in the format HH:mm such as 18:45
The culture is assumed to be the local one which can be 
troubling in applications that extend themselves internationally.
*/</span>
<span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #6666cc; font-weight: bold;">bool</span> IsCurrentDateInRange<span style="color: #008000;">&#40;</span><span style="color: #6666cc; font-weight: bold;">string</span> startTime, <span style="color: #6666cc; font-weight: bold;">string</span> endTime<span style="color: #008000;">&#41;</span> <span style="color: #008000;">&#123;</span>
  DateTime dtNow <span style="color: #008000;">=</span> DateTime<span style="color: #008000;">.</span><span style="color: #0000FF;">Now</span><span style="color: #008000;">;</span>
  DateTime dtStart, dtEnd<span style="color: #008000;">;</span>
  <span style="color: #6666cc; font-weight: bold;">int</span> hour <span style="color: #008000;">=</span> <span style="color: #FF0000;">0</span>, minute <span style="color: #008000;">=</span> <span style="color: #FF0000;">0</span><span style="color: #008000;">;</span>
&nbsp;
  <span style="color: #6666cc; font-weight: bold;">string</span><span style="color: #008000;">&#91;</span><span style="color: #008000;">&#93;</span> strDt <span style="color: #008000;">=</span> startTime<span style="color: #008000;">.</span><span style="color: #0000FF;">Split</span><span style="color: #008000;">&#40;</span><a href="http://www.google.com/search?q=new+msdn.microsoft.com"><span style="color: #008000;">new</span></a> <span style="color: #6666cc; font-weight: bold;">char</span><span style="color: #008000;">&#91;</span><span style="color: #008000;">&#93;</span> <span style="color: #008000;">&#123;</span> <span style="color: #666666;">':'</span> <span style="color: #008000;">&#125;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
  <span style="color: #0600FF; font-weight: bold;">if</span> <span style="color: #008000;">&#40;</span>strDt<span style="color: #008000;">.</span><span style="color: #0000FF;">Length</span> <span style="color: #008000;">&gt;</span> <span style="color: #FF0000;">1</span><span style="color: #008000;">&#41;</span>
  <span style="color: #008000;">&#123;</span>
     Int32<span style="color: #008000;">.</span><span style="color: #0000FF;">TryParse</span><span style="color: #008000;">&#40;</span>strDt<span style="color: #008000;">&#91;</span><span style="color: #FF0000;">0</span><span style="color: #008000;">&#93;</span>, <span style="color: #0600FF; font-weight: bold;">out</span> hour<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
     Int32<span style="color: #008000;">.</span><span style="color: #0000FF;">TryParse</span><span style="color: #008000;">&#40;</span>strDt<span style="color: #008000;">&#91;</span><span style="color: #FF0000;">1</span><span style="color: #008000;">&#93;</span>, <span style="color: #0600FF; font-weight: bold;">out</span> minute<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
     dtStart <span style="color: #008000;">=</span> <a href="http://www.google.com/search?q=new+msdn.microsoft.com"><span style="color: #008000;">new</span></a> DateTime<span style="color: #008000;">&#40;</span>dtNow<span style="color: #008000;">.</span><span style="color: #0000FF;">Year</span>, dtNow<span style="color: #008000;">.</span><span style="color: #0000FF;">Month</span>, dtNow<span style="color: #008000;">.</span><span style="color: #0000FF;">Day</span>, hour, minute, <span style="color: #FF0000;">0</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
  <span style="color: #008000;">&#125;</span>
  <span style="color: #0600FF; font-weight: bold;">else</span>
  <span style="color: #008000;">&#123;</span>
     <span style="color: #008080; font-style: italic;">//TODO: log an error in formatting.</span>
     <span style="color: #0600FF; font-weight: bold;">return</span> <span style="color: #0600FF; font-weight: bold;">false</span><span style="color: #008000;">;</span>
  <span style="color: #008000;">&#125;</span>               
&nbsp;
  strDt <span style="color: #008000;">=</span> endTime<span style="color: #008000;">.</span><span style="color: #0000FF;">Split</span><span style="color: #008000;">&#40;</span><a href="http://www.google.com/search?q=new+msdn.microsoft.com"><span style="color: #008000;">new</span></a> <span style="color: #6666cc; font-weight: bold;">char</span><span style="color: #008000;">&#91;</span><span style="color: #008000;">&#93;</span> <span style="color: #008000;">&#123;</span> <span style="color: #666666;">':'</span> <span style="color: #008000;">&#125;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
  <span style="color: #0600FF; font-weight: bold;">if</span> <span style="color: #008000;">&#40;</span>strDt<span style="color: #008000;">.</span><span style="color: #0000FF;">Length</span> <span style="color: #008000;">&gt;</span> <span style="color: #FF0000;">1</span><span style="color: #008000;">&#41;</span>
  <span style="color: #008000;">&#123;</span>
     hour <span style="color: #008000;">=</span> minute <span style="color: #008000;">=</span> <span style="color: #FF0000;">0</span><span style="color: #008000;">;</span>
     Int32<span style="color: #008000;">.</span><span style="color: #0000FF;">TryParse</span><span style="color: #008000;">&#40;</span>strDt<span style="color: #008000;">&#91;</span><span style="color: #FF0000;">0</span><span style="color: #008000;">&#93;</span>, <span style="color: #0600FF; font-weight: bold;">out</span> hour<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
     Int32<span style="color: #008000;">.</span><span style="color: #0000FF;">TryParse</span><span style="color: #008000;">&#40;</span>strDt<span style="color: #008000;">&#91;</span><span style="color: #FF0000;">1</span><span style="color: #008000;">&#93;</span>, <span style="color: #0600FF; font-weight: bold;">out</span> minute<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
     dtEnd <span style="color: #008000;">=</span> <a href="http://www.google.com/search?q=new+msdn.microsoft.com"><span style="color: #008000;">new</span></a> DateTime<span style="color: #008000;">&#40;</span>dtNow<span style="color: #008000;">.</span><span style="color: #0000FF;">Year</span>, dtNow<span style="color: #008000;">.</span><span style="color: #0000FF;">Month</span>, dtNow<span style="color: #008000;">.</span><span style="color: #0000FF;">Day</span>, hour, minute, <span style="color: #FF0000;">0</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
  <span style="color: #008000;">&#125;</span>
  <span style="color: #0600FF; font-weight: bold;">else</span>
  <span style="color: #008000;">&#123;</span>
     <span style="color: #008080; font-style: italic;">//TODO: log an error in formatting.</span>
    <span style="color: #0600FF; font-weight: bold;">return</span> <span style="color: #0600FF; font-weight: bold;">false</span><span style="color: #008000;">;</span>
  <span style="color: #008000;">&#125;</span>
&nbsp;
  TimeSpan tsEndDiff <span style="color: #008000;">=</span> dtEnd <span style="color: #008000;">-</span> dtNow<span style="color: #008000;">;</span>
  TimeSpan tsStartDiff <span style="color: #008000;">=</span> dtNow <span style="color: #008000;">-</span> dtStart<span style="color: #008000;">;</span>
  <span style="color: #0600FF; font-weight: bold;">if</span> <span style="color: #008000;">&#40;</span>tsStartDiff<span style="color: #008000;">.</span><span style="color: #0000FF;">TotalSeconds</span> <span style="color: #008000;">&gt;=</span> <span style="color: #FF0000;">0</span> <span style="color: #008000;">&amp;&amp;</span> tsEndDiff<span style="color: #008000;">.</span><span style="color: #0000FF;">TotalSeconds</span> <span style="color: #008000;">&gt;=</span> <span style="color: #FF0000;">0</span><span style="color: #008000;">&#41;</span>
  <span style="color: #008000;">&#123;</span>
     <span style="color: #0600FF; font-weight: bold;">return</span> <span style="color: #0600FF; font-weight: bold;">true</span><span style="color: #008000;">;</span>
  <span style="color: #008000;">&#125;</span>
  <span style="color: #0600FF; font-weight: bold;">else</span> 
     <span style="color: #0600FF; font-weight: bold;">return</span> <span style="color: #0600FF; font-weight: bold;">false</span><span style="color: #008000;">;</span>
<span style="color: #008000;">&#125;</span></pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://www.chrisdanielson.com/2009/07/21/net-c-sharp-date-range-check-method/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

