<?xml version="1.0" encoding="UTF-8"?>
<!-- generator="wordpress/2.3.3" -->
<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/"
	>

<channel>
	<title>Makiwa &#187; C#</title>
	<link>http://www.makiwa.com</link>
	<description>Stuart Campbell's occasional musings about software development, etc.</description>
	<pubDate>Thu, 08 May 2008 11:04:13 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.3.3</generator>
	<language>en</language>
			<item>
		<title>FormsAuthentication.Encrypt returns null</title>
		<link>http://www.makiwa.com/index.php/2007/02/13/formsauthenticationencrypt-returns-null/</link>
		<comments>http://www.makiwa.com/index.php/2007/02/13/formsauthenticationencrypt-returns-null/#comments</comments>
		<pubDate>Tue, 13 Feb 2007 11:27:53 +0000</pubDate>
		<dc:creator>Stu</dc:creator>
		
		<category><![CDATA[ASP.NET]]></category>

		<category><![CDATA[C#]]></category>

		<category><![CDATA[Development]]></category>

		<guid isPermaLink="false">http://www.makiwa.com/index.php/2007/02/13/formsauthenticationencrypt-returns-null/</guid>
		<description><![CDATA[I was writing some ASP.NET authentication code last night and was trying to encrypt an authentication ticket using FormsAuthentication.Encrypt(). However, it kept returning null. I banged my head against the wall for about an hour and then went home. As so often happens, I came in in the morning and spotted the problem immediately: the [...]]]></description>
			<content:encoded><![CDATA[<p>I was writing some ASP.NET authentication code last night and was trying to encrypt an authentication ticket using FormsAuthentication.Encrypt(). However, it kept returning null. I banged my head against the wall for about an hour and then went home. As so often happens, I came in in the morning and spotted the problem immediately: <strong>the authentication ticket's user data was null</strong>. Doh! I had only put null in there for test purposes!</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;">FormsAuthenticationTicket authTicket =</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <a href="http://www.google.com/search?q=new+msdn.microsoft.com"><span style="color: #008000;">new</span></a> FormsAuthenticationTicket<span style="color: #000000;">&#40;</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;color:#800000;">1</span>, <span style="color: #008080; font-style: italic;">// version</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: #808080;">"stu@me.com"</span>, <span style="color: #008080; font-style: italic;">// email</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; DateTime.<span style="color: #0000FF;">Now</span>, <span style="color: #008080; font-style: italic;">// creation</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; DateTime.<span style="color: #0000FF;">Now</span>.<span style="color: #0000FF;">AddMinutes</span><span style="color: #000000;">&#40;</span><span style="color: #FF0000;color:#800000;">60</span><span style="color: #000000;">&#41;</span>,<span style="color: #008080; font-style: italic;">// Expiration</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: #0600FF;">false</span>, <span style="color: #008080; font-style: italic;">// Persistent</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: #0600FF;">null</span><span style="color: #000000;">&#41;</span>; <span style="color: #008080; font-style: italic;">// User data (TICKET WON'T BE ENCRYPTED IF THIS IS NULL)</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;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #FF0000;">string</span> encryptedTicket = FormsAuthentication.<span style="color: #0000FF;">Encrypt</span><span style="color: #000000;">&#40;</span>authTicket<span style="color: #000000;">&#41;</span>; </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
]]></content:encoded>
			<wfw:commentRss>http://www.makiwa.com/index.php/2007/02/13/formsauthenticationencrypt-returns-null/feed/</wfw:commentRss>
		</item>
		<item>
		<title>WebDD 2007</title>
		<link>http://www.makiwa.com/index.php/2007/02/05/webdd-2007/</link>
		<comments>http://www.makiwa.com/index.php/2007/02/05/webdd-2007/#comments</comments>
		<pubDate>Mon, 05 Feb 2007 10:14:27 +0000</pubDate>
		<dc:creator>Stu</dc:creator>
		
		<category><![CDATA[C#]]></category>

		<category><![CDATA[Development]]></category>

		<category><![CDATA[Events]]></category>

		<category><![CDATA[WPF]]></category>

		<category><![CDATA[WPF/E]]></category>

		<category><![CDATA[WebDD]]></category>

		<guid isPermaLink="false">http://www.makiwa.com/index.php/2007/02/05/webdd-2007/</guid>
		<description><![CDATA[I went to WebDD on Saturday. It was quite an interesting event, indeed. 
I attended several interesting sessions; from HTML microformats, to Ruby on Rails, to WPF and Microsoft Expression Blend.
Scott Guthrie was the man of the day: large throngs of developers vied for seats in his sessions. His talk on WPF/E was extremely interesting. [...]]]></description>
			<content:encoded><![CDATA[<p>I went to <a href="http://www.webdd.org.uk/">WebDD</a> on Saturday. It was quite an interesting event, indeed. </p>
<p>I attended several interesting sessions; from HTML microformats, to Ruby on Rails, to WPF and Microsoft Expression Blend.<br />
<a href="http://weblogs.asp.net/scottgu/">Scott Guthrie</a> was the man of the day: large throngs of developers vied for seats in his sessions. His talk on WPF/E was extremely interesting. He was bombarded with questions from all of us and, while he obviously had to "chest his cards" about Microsoft's strategy, he did drop a few hints.<br />
Things I took away from the session include:</p>
<ul>
<li>WPF/E is currently cross-platform (Windows and Mac OSX) and cross-browser (IE, Firefox, Safari). Linux isn't currently supported because a) there are so many different distributions, and b) although Linux has a lot of penetration on the server market, it doesn't have a big client presence; WPF/E is obviously a client technology. However, <strong>MS will support a Linux version in future if there is significant demand for it.</strong></li>
<li>Right now you can only use JavaScript with WPF/E and it doesn't support layout management and other advanced controls - however this is going to change as WPF/E will be getting a version of the CLR and some of the .NET Framework. So we be able to use C# in Safari!</li>
<li>Following on from that, and reading between the lines a little: <strong>expect the .NET Framework in general to pitch up on Mac OS X</strong>. In my opinion, this is the single most exciting development of the century. Yes, forget the breakthroughs in stem-cell research and cognitive neuroscience: Microsoft is committed to going cross-platform. I've been waiting for this news since I first saw the promising Environment.NewLine property (which claims to return 'a string containing "\r\n" for non-Unix platforms, or a string containing "\n" for Unix platforms.')</li>
<li>WPF/E isn't hardware accelerated - it's software-only. So there is no 3D support in WPF/E. However, Scott's cheeky grins and evasive diplomacy seemed to indicate that in a future rev we could expect hardware acceleration and all the wholesome goodness that comes with it.</li>
</ul>
<p>The session was recorded, and will be available online - but no link as yet.</p>
<p>The day ended with drinks at a bar and a "geek" dinner which was enjoyable and great for networking. We've gotta find a better name for these "geek" dinners. I'm sure I'm not the only developer who doesn't like to think of himself as a geek. How about Dev Dinners? <img src='http://www.makiwa.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /></p>
]]></content:encoded>
			<wfw:commentRss>http://www.makiwa.com/index.php/2007/02/05/webdd-2007/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Reflecting over properties in .NET</title>
		<link>http://www.makiwa.com/index.php/2006/10/06/reflecting-over-properties-in-net/</link>
		<comments>http://www.makiwa.com/index.php/2006/10/06/reflecting-over-properties-in-net/#comments</comments>
		<pubDate>Fri, 06 Oct 2006 11:47:59 +0000</pubDate>
		<dc:creator>Stu</dc:creator>
		
		<category><![CDATA[C#]]></category>

		<category><![CDATA[Development]]></category>

		<guid isPermaLink="false">http://www.makiwa.com/index.php/2006/10/06/reflecting-over-properties-in-net/</guid>
		<description><![CDATA[I always forget the binding flags needed to reflect over properties in .NET. So this is mainly an aide-mÃ©moire for myself.
PLAIN TEXT
C#:




PropertyInfo&#91;&#93; props = typeof&#40;MyType&#41;.GetProperties&#40;BindingFlags.Instance &#124; BindingFlags.Public &#124; BindingFlags.NonPublic&#41;; 






I ALWAYS forget that you need to include the BindingFlags.NonPublic flag!
]]></description>
			<content:encoded><![CDATA[<p>I always forget the binding flags needed to reflect over properties in .NET. So this is mainly an aide-mÃ©moire for myself.</p>
<div class="igBar"><span id="lcsharp-4"><a href="#" onclick="javascript:showPlainTxt('csharp-4'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">C#:</span>
<div id="csharp-4">
<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;">PropertyInfo<span style="color: #000000;">&#91;</span><span style="color: #000000;">&#93;</span> props = <a href="http://www.google.com/search?q=typeof+msdn.microsoft.com"><span style="color: #008000;">typeof</span></a><span style="color: #000000;">&#40;</span>MyType<span style="color: #000000;">&#41;</span>.<span style="color: #0000FF;">GetProperties</span><span style="color: #000000;">&#40;</span>BindingFlags.<span style="color: #0000FF;">Instance</span> | BindingFlags.<span style="color: #0600FF;">Public</span> | BindingFlags.<span style="color: #0000FF;">NonPublic</span><span style="color: #000000;">&#41;</span>; </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>I ALWAYS forget that you need to include the BindingFlags.NonPublic flag!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.makiwa.com/index.php/2006/10/06/reflecting-over-properties-in-net/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Structs vs Classes: Revisted</title>
		<link>http://www.makiwa.com/index.php/2005/10/05/structs-vs-classes-revisted/</link>
		<comments>http://www.makiwa.com/index.php/2005/10/05/structs-vs-classes-revisted/#comments</comments>
		<pubDate>Wed, 05 Oct 2005 11:30:20 +0000</pubDate>
		<dc:creator>Stu</dc:creator>
		
		<category><![CDATA[C#]]></category>

		<category><![CDATA[Development]]></category>

		<guid isPermaLink="false">http://www.makiwa.com/?p=34</guid>
		<description><![CDATA[Just thought I&#8217;d mention Microsoft&#8217;s advice on the Structs vs. Classes issue

Consider defining a structure instead of a class if instances of the type are small and commonly short-lived or are commonly embedded in other objects.
Do not define a structure unless the type has all of the following characteristics:

It logically represents a single value, similar [...]]]></description>
			<content:encoded><![CDATA[<p>Just thought I&#8217;d mention Microsoft&#8217;s advice on the <a href="http://www.makiwa.com/index.php/2005/06/07/structs-vs-classes/">Structs vs. Classes issue</a></p>
<blockquote><p>
Consider defining a structure instead of a class if instances of the type are small and commonly short-lived or are commonly embedded in other objects.<br />
Do not define a structure unless the type has all of the following characteristics:</p>
<ul>
<li>It logically represents a single value, similar to primitive types (integer, double, and so on).</li>
<li>It has an instance size smaller than 16 bytes.</li>
<li>It is immutable.</li>
<li>It will not have to be boxed frequently. </li>
</ul>
<p>If one or more of these conditions are not met, create a reference type instead of a structure. Failure to adhere to this guideline can negatively impact performance.
</p>
</blockquote>
<p>See  <a target="_blank" href="http://msdn2.microsoft.com/en-us/library/ms229017.aspx">Choosing Between Classes and Structures</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.makiwa.com/index.php/2005/10/05/structs-vs-classes-revisted/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Structs vs. Classes</title>
		<link>http://www.makiwa.com/index.php/2005/06/07/structs-vs-classes/</link>
		<comments>http://www.makiwa.com/index.php/2005/06/07/structs-vs-classes/#comments</comments>
		<pubDate>Tue, 07 Jun 2005 10:36:32 +0000</pubDate>
		<dc:creator>Stu</dc:creator>
		
		<category><![CDATA[C#]]></category>

		<category><![CDATA[Development]]></category>

		<guid isPermaLink="false">http://www.makiwa.com/index.php/2005/06/07/structs-vs-classes/</guid>
		<description><![CDATA[I've never quite been convinced of the value of using structs (pun intended).
Sure, structs are 

stack allocated instead of heap allocated
value types instead of reference types

But that doesn't really help you when deciding whether to use them or not. And besides, I read somewhere (can't remember where) that the CLR optimizes heap allocations to the [...]]]></description>
			<content:encoded><![CDATA[<p>I've never quite been convinced of the value of using structs (pun intended).<br />
Sure, structs are </p>
<ul>
<li>stack allocated instead of heap allocated</li>
<li>value types instead of reference types</li>
</ul>
<p>But that doesn't really help you when deciding whether to use them or not. And besides, I read somewhere (can't remember where) that the CLR optimizes heap allocations to the extent that the performance benefit of stack allocated structs is almost negligable over heap allocated "objects" (class instances).</p>
<p>So I've largely avoided structs. Today I found an article that kind of vindicates this decision - although for a different reason. It claims (and while I'm not sure of the authority of the author, he/she makes a good case) that structs should not be used because they violate the Principle of Uniformity. You can read it here:</p>
<p><a target="_blank" href="http://www.geocities.com/csharpfaq/structs.html">http://www.geocities.com/csharpfaq/structs.html</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.makiwa.com/index.php/2005/06/07/structs-vs-classes/feed/</wfw:commentRss>
		</item>
	</channel>
</rss>
