<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://decav.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>decav.com</title><link>http://decav.com/blogs/</link><description>Andre de Cavaignac's Personal Website</description><dc:language>en-US</dc:language><generator>CommunityServer 2007 (Build: 20423.869)</generator><item><title>Moving on...</title><link>http://decav.com/blogs/andre/archive/2008/09/18/moving-on.aspx</link><pubDate>Thu, 18 Sep 2008 22:38:00 GMT</pubDate><guid isPermaLink="false">1a6c50a2-1cc5-440d-a734-51a167eba982:38716</guid><dc:creator>mrdecav</dc:creator><slash:comments>1</slash:comments><description>To those that know me well, this post is of no surprise, however given that I haven&amp;#39;t been posting for a while, and probably won&amp;#39;t for a while more, I thought it was appropriate to post a quick, personal update.

As of a week ago, I left my colleagues at Lab49 to pursue an exciting new venture which I hope will make the lives of many people easier.  Because this venture is based on web technologies, I bought a mac and just to fit in a latte as well, and settled down in a world not as well known to me -- of Open Source and Unix/Linux.

Unfortunately due to the sensitivity of any new venture, my next several months of work will be as secretive as possible.  I will not be sharing technical secrets or what the project is about until a few months from now.  For that reason, this blog will remain sparse for the next few months.&lt;img src="http://decav.com/aggbug.aspx?PostID=38716" width="1" height="1"&gt;</description></item><item><title>Introducing PowerShell Pages - Script Style HTML Rendering</title><link>http://decav.com/blogs/andre/archive/2008/07/05/introducing-powershell-pages-script-style-html-rendering.aspx</link><pubDate>Sat, 05 Jul 2008 17:59:00 GMT</pubDate><guid isPermaLink="false">1a6c50a2-1cc5-440d-a734-51a167eba982:34706</guid><dc:creator>mrdecav</dc:creator><slash:comments>1</slash:comments><description>&lt;p&gt;Early in the web development world, scripting languages such as ASP or PHP were used to compose pages. Although this proved great for relatively static pages, the dynamic web, filled with rich applications called for a more powerful framework. Thus, frameworks like ASP.NET were born.&lt;br /&gt;&lt;br /&gt;ASP.NET solved a good number of problem spaces, but has made creating simple pages (such as a resume or menu, or other primitive list of data) more cumbersome. With the world of COM development becoming less common and less preferable, the gap for a scripting language to replace VBScript/ASP is needed. PowerShell scripting has filled the gap left by the demise of VBScript, but nothing has come along to replace ASP.&lt;br /&gt;&lt;br /&gt;PowerShell Pages is an ASP like language, based on the PowerShell runtime. Using a simple HTTP Handler, ASP.NET can render pages scripted using PowerShell script (including cmdlets, and CLR/.NET objects) to the web. Simple, fast and intuitive programming for simple pages that just need to display some content.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;The PowerShell Pages project is an open source project that I am starting.&lt;/strong&gt;&amp;nbsp; Its implementation will be based on ASP.NET using a simple handler capable of consuming &lt;strong&gt;PowerShell HTML (PSH)&lt;/strong&gt;&amp;nbsp;scripts and writing HTML.&amp;nbsp; Because the script is hosted in ASP.NET, the ASP.NET HttpContext and the other components of the object model are available.&amp;nbsp; PSH scripts can work side-by-side with ASPX pages.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Ready to see what PowerShell Pages look like?&lt;br /&gt;Sample Page: &lt;/strong&gt;&lt;a href="http://decav.com/psp/resume.psh"&gt;http://decav.com/psp/resume.psh&lt;/a&gt;&lt;br /&gt;&lt;strong&gt;Sample Page Code:&lt;/strong&gt; &lt;a href="http://decav.com/psp/viewsource.psh?page=resume.psh"&gt;http://decav.com/psp/viewsource.psh?page=resume.psh&lt;/a&gt;&lt;br /&gt;&lt;strong&gt;View Source Code:&lt;/strong&gt; &lt;a href="http://decav.com/psp/viewsource.psh?page=viewsource.psh"&gt;http://decav.com/psp/viewsource.psh?page=viewsource.psh&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;&lt;a class="" href="http://www.codeplex.com/PowerShellPages"&gt;Join the Project - Visit the PowerShell Pages CodePlex project workspace&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;&lt;img src="http://decav.com/aggbug.aspx?PostID=34706" width="1" height="1"&gt;</description><category domain="http://decav.com/blogs/andre/archive/tags/Web+2.0/default.aspx">Web 2.0</category><category domain="http://decav.com/blogs/andre/archive/tags/.NET_2F00_C_2300_+Development/default.aspx">.NET/C# Development</category><category domain="http://decav.com/blogs/andre/archive/tags/On+Software/default.aspx">On Software</category><category domain="http://decav.com/blogs/andre/archive/tags/PowerShell/default.aspx">PowerShell</category></item><item><title>Gatsb.com Now Open Source (A Case Study in Geotagging, Workflow Foundation, SMS/MMS Parsing)</title><link>http://decav.com/blogs/andre/archive/2008/06/14/gatsb-com-now-open-source-a-case-study-in-geotagging-workflow-foundation-sms-mms-parsing.aspx</link><pubDate>Sat, 14 Jun 2008 15:37:00 GMT</pubDate><guid isPermaLink="false">1a6c50a2-1cc5-440d-a734-51a167eba982:33940</guid><dc:creator>mrdecav</dc:creator><slash:comments>0</slash:comments><description>&lt;p&gt;After hosting Gatsb.com for a year, I have decided to open source the project.&amp;nbsp; I haven&amp;#39;t had time to promote it the way I wanted to promote it, and it therefore hasn&amp;#39;t caught on with too many users.&amp;nbsp; I&amp;#39;ve been busy with other projects, other (grander) ideas, and think that this one should now belong to the community.&lt;/p&gt;
&lt;p&gt;You can download the source code here: &lt;a href="http://code.google.com/p/gatsb/"&gt;http://code.google.com/p/gatsb/&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;If you want to contribute to the project, please feel free to contact me at &lt;a href="mailto:andreblog@decav.com"&gt;andreblog@decav.com&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;This project is a great case study of a bunch of new Microsoft technologies.&amp;nbsp; It includes Workflow Foundation, .NET 3.0, Microsoft Virtual Earth and ASP.NET Ajax.&lt;/p&gt;
&lt;p&gt;One of the coolest features is how it keeps open a &amp;quot;session&amp;quot; with an SMS client.&amp;nbsp; Workflow Foundation is used to persist the state and when a new SMS comes in, it checks if theres an existing session for that SMS.&amp;nbsp; If there is, then it will revive the workflow and continue the session.&amp;nbsp; Cool stuff!&lt;/p&gt;
&lt;p&gt;If you ever wondered how to create a database of geotagged entries, use ASP.NET ajax to make a snazzier site, or establish a user interface with any mobile device, I suggest checking out the code!&lt;/p&gt;&lt;img src="http://decav.com/aggbug.aspx?PostID=33940" width="1" height="1"&gt;</description><category domain="http://decav.com/blogs/andre/archive/tags/Web+2.0/default.aspx">Web 2.0</category><category domain="http://decav.com/blogs/andre/archive/tags/.NET_2F00_C_2300_+Development/default.aspx">.NET/C# Development</category><category domain="http://decav.com/blogs/andre/archive/tags/On+Software/default.aspx">On Software</category><category domain="http://decav.com/blogs/andre/archive/tags/Gatsb/default.aspx">Gatsb</category></item><item><title>PowerShell: Repeat Yourself with the Command "Scratch Pad"</title><link>http://decav.com/blogs/andre/archive/2008/05/21/powershell-repeat-yourself-with-the-command-quot-scratch-pad-quot.aspx</link><pubDate>Wed, 21 May 2008 13:08:00 GMT</pubDate><guid isPermaLink="false">1a6c50a2-1cc5-440d-a734-51a167eba982:33101</guid><dc:creator>mrdecav</dc:creator><slash:comments>0</slash:comments><description>&lt;p&gt;Heres a useful snippit of code I wrote as a utility and thought I&amp;#39;d post up for everyone.&amp;nbsp; Very often when using a command line, you need to repeat a set of commands.&amp;nbsp; For example, copy several files:&lt;/p&gt;
&lt;p&gt;copy &amp;quot;c:\blah.txt&amp;quot; &amp;quot;c:\otherPlace\blah.txt&amp;quot;&lt;br /&gt;copy &amp;quot;c:\dev\blah.txt&amp;quot; &amp;quot;c:\otherPlace\blah2.txt&amp;quot;&lt;/p&gt;
&lt;p&gt;History is okay for this, but if you have a set of commands you need to run, you need to run them each individually.&amp;nbsp; Also, if you go to do something else, they&amp;#39;ll eventually lose their spot in the command history.&lt;/p&gt;
&lt;p&gt;To solve this, I created a &amp;quot;scratch pad&amp;quot;.&amp;nbsp; Nothing special, but definately useful.&lt;/p&gt;
&lt;p&gt;new-scratch &amp;quot;MyFirstScratch&amp;quot;&lt;br /&gt;copy &amp;quot;c:\blah.txt&amp;quot; &amp;quot;c:\otherPlace\blah.txt&amp;quot;&lt;br /&gt;scratch&lt;br /&gt;copy &amp;quot;c:\dev\blah.txt&amp;quot; &amp;quot;c:\otherplace\blah2.txt&amp;quot;&lt;br /&gt;scratch&lt;br /&gt;## Do some other stuff here...&lt;br /&gt;get-scratch # prints out the contents of the scratch.&lt;br /&gt;invoke-scratch&lt;/p&gt;
&lt;p&gt;This scratch pad is holds a set of commands that you want to rerun later.&amp;nbsp; You can then call invoke-scratch to run the scratchpad.&amp;nbsp; You can have multiple scratch pads, and use them by just adding the name to the end of the function (&lt;strong&gt;get-scratch &amp;quot;MyFirstScratch&amp;quot;&lt;/strong&gt;).&amp;nbsp; By&amp;nbsp;default all scratch pad commands will default to the &lt;strong&gt;last used scratch pad&lt;/strong&gt;.&lt;/p&gt;
&lt;p&gt;The example below shows how to shorten the sample above:&lt;/p&gt;
&lt;p&gt;new-scratch &amp;quot;MyFirstScratch&amp;quot;&lt;br /&gt;copy &amp;quot;c:\blah.txt&amp;quot; &amp;quot;c:\otherPlace\blah.txt&amp;quot;&lt;br /&gt;copy &amp;quot;c:\dev\blah.txt&amp;quot; &amp;quot;c:\otherplace\blah2.txt&amp;quot;&lt;br /&gt;scratch 2&amp;nbsp;&amp;nbsp; # Saves the last 2 items to the scratch pad&lt;/p&gt;
&lt;p&gt;This can be very useful for writing scripts too.&amp;nbsp; the &lt;strong&gt;Save-Scratch&lt;/strong&gt; command lets you export your scratch to a file.&lt;/p&gt;
&lt;p&gt;Heres the code.&amp;nbsp; Add it to your profile and go.&amp;nbsp; Enjoy!&lt;/p&gt;
&lt;div style="BORDER-RIGHT:#ccc 1px solid;PADDING-RIGHT:10px;BORDER-TOP:#ccc 1px solid;PADDING-LEFT:10px;PADDING-BOTTOM:10px;BORDER-LEFT:#ccc 1px solid;PADDING-TOP:10px;BORDER-BOTTOM:#ccc 1px solid;"&gt;&lt;code&gt;function New-Scratch($name) {&lt;br /&gt;&amp;nbsp; if ($global:scratchPads -eq $null) {&lt;br /&gt;&amp;nbsp; &amp;nbsp; $global:scratchPads = @{}&lt;br /&gt;&amp;nbsp; }&lt;br /&gt;&amp;nbsp;&amp;nbsp;&lt;br /&gt;&amp;nbsp; $pad = new-object System.Collections.ArrayList&lt;br /&gt;&amp;nbsp; $global:scratchPads.Add($name, $pad)&lt;br /&gt;&amp;nbsp; $global:currentScratchPad = $pad&lt;br /&gt;&amp;nbsp; $global:currentScratchPadName = $name&lt;br /&gt;}&lt;br /&gt;function Get-Scratch($name=$null) {&lt;br /&gt;&amp;nbsp; if ($name -ne $null) {&lt;br /&gt;&amp;nbsp; &amp;nbsp; $global:currentScratchPad = $global:scratchPads[$name]&lt;br /&gt;&amp;nbsp; &amp;nbsp; $global:currentScratchPadName = $name&lt;br /&gt;&amp;nbsp; }&lt;br /&gt;&amp;nbsp;&amp;nbsp;&lt;br /&gt;&amp;nbsp; return $global:currentScratchPad&lt;br /&gt;}&lt;br /&gt;function Scratch([int]$count=1,$name=$null) {&lt;br /&gt;&amp;nbsp; if ($name -ne $null) {&lt;br /&gt;&amp;nbsp; &amp;nbsp; $global:currentScratchPad = $global:scratchPads[$name]&lt;br /&gt;&amp;nbsp; &amp;nbsp; $global:currentScratchPadName = $name&lt;br /&gt;&amp;nbsp; }&lt;br /&gt;&amp;nbsp;&amp;nbsp;&lt;br /&gt;&amp;nbsp; $hist = get-history&lt;br /&gt;&amp;nbsp;&amp;nbsp;&lt;br /&gt;&amp;nbsp; if ($name -eq $null) {&lt;br /&gt;&amp;nbsp; &amp;nbsp; $name = $global:currentScratchPadName&lt;br /&gt;&amp;nbsp; }&lt;br /&gt;&amp;nbsp;&amp;nbsp;&lt;br /&gt;&amp;nbsp; for ($i=$hist.Length-$count; $i -lt $hist.Length; $i++) {&lt;br /&gt;&amp;nbsp; &amp;nbsp; $global:currentScratchPad.Add($hist[$i].CommandLine) | out-null&lt;br /&gt;&amp;nbsp; }&lt;br /&gt;}&lt;br /&gt;function Invoke-Scratch($name=$null) {&lt;br /&gt;&amp;nbsp; if ($name -ne $null) {&lt;br /&gt;&amp;nbsp; &amp;nbsp; $global:currentScratchPad = $global:scratchPads[$name]&lt;br /&gt;&amp;nbsp; &amp;nbsp; $global:currentScratchPadName = $name&lt;br /&gt;&amp;nbsp; }&lt;br /&gt;&amp;nbsp;&amp;nbsp;&lt;br /&gt;&amp;nbsp; foreach ($item in $global:currentScratchPad) {&lt;br /&gt;&amp;nbsp; &amp;nbsp; write-host &amp;quot;&amp;gt;&amp;gt; $item&amp;quot;&lt;br /&gt;&amp;nbsp; &amp;nbsp; invoke-expression $item&lt;br /&gt;&amp;nbsp; }&lt;br /&gt;}&lt;br /&gt;function Save-Scratch($path, $name=$null) {&lt;br /&gt;&amp;nbsp; if ($name -ne $null) {&lt;br /&gt;&amp;nbsp; &amp;nbsp; $global:currentScratchPad = $global:scratchPads[$name]&lt;br /&gt;&amp;nbsp; &amp;nbsp; $global:currentScratchPadName = $name&lt;br /&gt;&amp;nbsp; }&lt;br /&gt;&amp;nbsp;&amp;nbsp;&lt;br /&gt;&amp;nbsp; $global:currentScratchPad | out-file $path&lt;br /&gt;}&lt;/code&gt;&lt;/div&gt;&lt;img src="http://decav.com/aggbug.aspx?PostID=33101" width="1" height="1"&gt;</description><category domain="http://decav.com/blogs/andre/archive/tags/On+Software/default.aspx">On Software</category><category domain="http://decav.com/blogs/andre/archive/tags/PowerShell/default.aspx">PowerShell</category></item><item><title>Invoking PowerShell Scripts from An Application</title><link>http://decav.com/blogs/andre/archive/2008/05/01/invoking-powershell-scripts-from-an-application.aspx</link><pubDate>Thu, 01 May 2008 20:01:00 GMT</pubDate><guid isPermaLink="false">1a6c50a2-1cc5-440d-a734-51a167eba982:32362</guid><dc:creator>mrdecav</dc:creator><slash:comments>0</slash:comments><description>&lt;p&gt;If you want to run your PowerShell scripts from a piece of code you&amp;#39;re writing, and would prefer not to use &lt;strong&gt;Process.Start&lt;/strong&gt;, you can easily use the PowerShell runtime classes to run those scripts for you, completely in-process.&lt;/p&gt;
&lt;p&gt;The code snippit below shows how you can create a &lt;strong&gt;Runspace&lt;/strong&gt; and pass it some simple commands.&lt;/p&gt;&lt;pre class="csharpcode"&gt;List&amp;lt;Command&amp;gt; commands = &lt;span class="kwrd"&gt;new&lt;/span&gt; List&amp;lt;Command&amp;gt;();
commands.Add(&lt;span class="kwrd"&gt;new&lt;/span&gt; Command(&lt;span class="str"&gt;&amp;quot;set-location c:\\&amp;quot;));
commands.Add(new Command(&amp;quot;&lt;/span&gt;./MyScript.ps1 &lt;span class="str"&gt;&amp;#39;myParameter&amp;#39;&lt;/span&gt;&amp;quot;, &lt;span class="kwrd"&gt;true&lt;/span&gt;));

&lt;span class="kwrd"&gt;using&lt;/span&gt; (Runspace runspace = RunspaceFactory.CreateRunspace())
{
    runspace.Open();
    &lt;span class="kwrd"&gt;using&lt;/span&gt; (Pipeline pipeline = runspace.CreatePipeline())
    {
        &lt;span class="kwrd"&gt;foreach&lt;/span&gt; (Command cmd &lt;span class="kwrd"&gt;in&lt;/span&gt; commands)
        {
            pipeline.Commands.Add(cmd);
        }
        pipeline.Invoke();
    }
    runspace.Close();
}&lt;/pre&gt;
&lt;p&gt;One thing to note here is you do not have a &lt;strong&gt;PSHost&lt;/strong&gt;, so if you have a &lt;strong&gt;write-host&lt;/strong&gt; anywhere, it will fail with the following exception:&lt;/p&gt;
&lt;p&gt;&lt;em&gt;CmdletInvocationException: Cannot invoke this function becasue the current host does not implement it.&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;To get around this, you can remove &lt;strong&gt;write-host&lt;/strong&gt; from your scripts and just have them write single lines, or you can implement a simple &lt;strong&gt;PSHost&lt;/strong&gt; (although this is a bit harder than it sounds).&lt;/p&gt;&lt;img src="http://decav.com/aggbug.aspx?PostID=32362" width="1" height="1"&gt;</description><category domain="http://decav.com/blogs/andre/archive/tags/.NET_2F00_C_2300_+Development/default.aspx">.NET/C# Development</category><category domain="http://decav.com/blogs/andre/archive/tags/On+Software/default.aspx">On Software</category><category domain="http://decav.com/blogs/andre/archive/tags/PowerShell/default.aspx">PowerShell</category></item><item><title>Solution: "Unknown error", LDAP connection strings and System.DirectoryServices</title><link>http://decav.com/blogs/andre/archive/2008/05/01/solution-quot-unknown-error-quot-ldap-connection-strings-and-system-directoryservices.aspx</link><pubDate>Thu, 01 May 2008 19:50:00 GMT</pubDate><guid isPermaLink="false">1a6c50a2-1cc5-440d-a734-51a167eba982:32360</guid><dc:creator>mrdecav</dc:creator><slash:comments>0</slash:comments><description>&lt;p&gt;If you&amp;#39;ve been using &lt;strong&gt;System.DirectoryServices&lt;/strong&gt;.&lt;strong&gt;DirectoryEntry&lt;/strong&gt; class, or the newer &lt;strong&gt;System.DirectoryServices.AccountManagement&lt;/strong&gt; namespace to access your LDAP or Active Directory server, you may have experienced the following error:&lt;/p&gt;
&lt;p&gt;&lt;em&gt;COMException: &amp;quot;Unknown error (0x80005000)&amp;quot;&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;This can happen for numerous reasons, but one of the most frustrating and overlooked reason&amp;#39;s I&amp;#39;ve found for this problem is when your LDAP connection string is malformed.&amp;nbsp; One of the most common malformations is in the case sensitivity of the &lt;strong&gt;LDAP://&lt;/strong&gt; component.&amp;nbsp; For example, &lt;strong&gt;LDAP://myServer/cn=users,dc=myserver,dc=com&lt;/strong&gt; is a valid connection string, however &lt;strong&gt;ldap://myServer/cn=users,dc=myserver,dc=com&lt;/strong&gt; is &lt;strong&gt;&lt;u&gt;not&lt;/u&gt;&lt;/strong&gt;.&lt;/p&gt;
&lt;p&gt;If you use the &lt;strong&gt;Uri&lt;/strong&gt; or &lt;strong&gt;UriBuilder&lt;/strong&gt; classes, the builder may lowecase your scheme.&amp;nbsp; Always make sure to recapitalize the scheme when passing it into &lt;strong&gt;DirectoryEntry&lt;/strong&gt; or any other API.&lt;/p&gt;&lt;img src="http://decav.com/aggbug.aspx?PostID=32360" width="1" height="1"&gt;</description><category domain="http://decav.com/blogs/andre/archive/tags/.NET_2F00_C_2300_+Development/default.aspx">.NET/C# Development</category><category domain="http://decav.com/blogs/andre/archive/tags/On+Software/default.aspx">On Software</category></item><item><title>Cluster Primitives: MPI, MPI.NET, Large Data, and Passing Classes</title><link>http://decav.com/blogs/andre/archive/2008/04/27/cluster-primitives-mpi-mpi-net-large-data-and-passing-classes.aspx</link><pubDate>Sun, 27 Apr 2008 05:06:00 GMT</pubDate><guid isPermaLink="false">1a6c50a2-1cc5-440d-a734-51a167eba982:32193</guid><dc:creator>mrdecav</dc:creator><slash:comments>2</slash:comments><description>&lt;p&gt;The &lt;a class="" href="http://www-unix.mcs.anl.gov/mpi/"&gt;Message Passing Interface (MPI) standard&lt;/a&gt;, and its .NET implementation, &lt;a class="" href="http://www.osl.iu.edu/research/mpi.net/"&gt;MPI.NET&lt;/a&gt;&amp;nbsp;have been some of the cornerstones of development on compute clusters.&amp;nbsp; The standard supplies a simple yet primitive way of both sending and receiving data between running compute processes.&lt;/p&gt;
&lt;p&gt;The large advantage of MPI has been a mix of its simplicity and speed.&amp;nbsp; A call to MPI Send on one node and MPI Receive on another block both callers until the operation is complete.&amp;nbsp; Some more complex calls, such as MPI Scatter and MPI Gather allow a single node to distribute data to a set of nodes or retrieve it from a set of nodes.&amp;nbsp; An MPI&amp;nbsp;Barrier allows all nodes to stop until they have all reached the agreed upon place in code, then allowing them to continue.&amp;nbsp; Such primitives allow a distributed set of processes to communicate, do some work, and then share values that each needs to continue with eachother.&amp;nbsp; Because this is all done with some low level, bare metal socket tricks and/or shared memory, the result is blazingly fast communication.&lt;/p&gt;
&lt;p&gt;With this simplicity however, comes a trade off.&amp;nbsp; MPI has been a standard for nearly 20 years and has changed very little since its inception.&amp;nbsp; The way we program today has changed drastically, especially with managed languages such as&amp;nbsp;C#.&amp;nbsp; No longer do we tend to worry about memory allocation, or dealing with raw memory.&amp;nbsp; Today, most languages have a concept of automatic memory allocations, garbage collection and type safety.&amp;nbsp; Although the primitives in MPI are unparalleled in simplicity for allowing multiple processors to communicate about a shared set of work, some striking limitations are found once we dig a bit deeper.&lt;/p&gt;
&lt;p&gt;When I started with MPI.NET, I found the interface very simple.&amp;nbsp; An &lt;strong&gt;Mpi.Send&amp;lt;T&amp;gt;(obj)&lt;/strong&gt; would send an object to a waiting client.&amp;nbsp; &lt;strong&gt;Mpi.Receive&amp;lt;T&amp;gt;() &lt;/strong&gt;would give you back that object.&amp;nbsp; Nothing could be simpler.&amp;nbsp; In my example, however &lt;strong&gt;T&lt;/strong&gt; happened to be a class that contained a &lt;strong&gt;byte[]&lt;/strong&gt; of an undetermined size.&amp;nbsp; Once run on the cluster, the size of the &lt;strong&gt;byte[] &lt;/strong&gt;I was passing increased dramatically, and an unexpected exception occured:&lt;/p&gt;
&lt;p&gt;&lt;em&gt;AccessViolationException: Attempted to read or write protected memory. This is often an indication that other memory has been corrupted.&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;After lengthy investigation, I found that MPI.NET was attempting to pin some memory in the .NET GC heap and pass that memory location as a buffer to the underlying MSMPI stack.&amp;nbsp; In doing so, it did not allocate enough memory for my large &lt;strong&gt;byte[]&lt;/strong&gt;, causing the write to try to write into the GC heap, thus throwing the exception.&amp;nbsp; In my case, to solve this, I created a large enough buffer and passed it into an override of &lt;strong&gt;Mpi.Receive&amp;lt;byte&amp;gt;(byte[])&lt;/strong&gt;.&amp;nbsp; This overload pins the entire array that was passed in on the GC, and then passes that to the MSMPI stack.&amp;nbsp; On the send side, I manually serialized my class, checked the length (to ensure I would not overflow the receive buffer) and sent the &lt;strong&gt;byte[]&lt;/strong&gt; instead of the raw class.&amp;nbsp; This solution does not take into accound messages larger than my expected buffer.&amp;nbsp; For that, I would have needed to chunk down the data.&lt;/p&gt;
&lt;p&gt;The moral of the story here is sending primitives, arrays of primitives or fixed-sized structs over MPI.NET (which is the most common scenario) is a great use of a very fast messaging interface.&amp;nbsp; Once your demands get more complex, the MPI stack gets less favorable, not because of its inability to send more complex messages, but because of the manual labor involved in serializing and chunking down data.&lt;/p&gt;
&lt;p&gt;It is no wonder that the HPC community is moving away from the traditional methods of MPI and communication across a set of processors to a Service Oriented (SOA) model. The benefits of using existing components, such as WCF and its NetTcpBinding, the threading models, serialization and transport models, and other features&amp;nbsp;already provided by these frameworks outweights the possible performance penalty.&amp;nbsp;&amp;nbsp;Problems such as the one explained above simply&amp;nbsp;do not happen with frameworks like WCF.&amp;nbsp; Furthermore, although the underlying concepts of MPI and its simple messaging model are very simple and appealing, the overall development, maintainence and debugging&amp;nbsp;of a SOA application is much simpler than that of a MPI application.&amp;nbsp; The amount of code complexity and custom code drops when compared to an MPI implemenation.&lt;/p&gt;
&lt;p&gt;The general industry trend seems to be towards SOA models.&amp;nbsp; &lt;a class="" href="http://www.microsoft.com/windowsserver2003/ccs/hpcplus.aspx"&gt;Microsoft Windows HPC Server 2008&lt;/a&gt; is&amp;nbsp;a great example of this.&amp;nbsp; HPC Server uses WCF to distribute load across the cluster, and can even dynamically scale resources depending on demand of a particular service.&amp;nbsp; &lt;a class="" href="http://www.platform.com/"&gt;Platform&lt;/a&gt;, another industry competior has been building with a SOA model for some time now.&amp;nbsp; &lt;/p&gt;
&lt;p&gt;I&amp;#39;m looking forward to playing with HPC Server 2008 and WCF more as time progresses.&amp;nbsp; I think that the WCF model will solve a whole bunch of headaches that one incurs when trying to communicate over perhaps over simple primitives such as MPI.&amp;nbsp; Many models and workloads simply do not require the type of communication MPI provides, and using MPI can be like fitting a square peg into a round hole.&amp;nbsp; This is not to say MPI does not have its place, many complex processes do require constant communication between a set of workers, however I believe many of the problems we use HPC for today can distributed using SOA in a much simpler fashion.&lt;/p&gt;&lt;img src="http://decav.com/aggbug.aspx?PostID=32193" width="1" height="1"&gt;</description><category domain="http://decav.com/blogs/andre/archive/tags/.NET_2F00_C_2300_+Development/default.aspx">.NET/C# Development</category><category domain="http://decav.com/blogs/andre/archive/tags/On+Software/default.aspx">On Software</category><category domain="http://decav.com/blogs/andre/archive/tags/Cluster+Computing/default.aspx">Cluster Computing</category></item><item><title>Ruby, From The Eyes of a C# .NET Developer</title><link>http://decav.com/blogs/andre/archive/2008/03/12/ruby-from-the-eyes-of-a-c-net-developer.aspx</link><pubDate>Wed, 12 Mar 2008 02:37:00 GMT</pubDate><guid isPermaLink="false">1a6c50a2-1cc5-440d-a734-51a167eba982:30515</guid><dc:creator>mrdecav</dc:creator><slash:comments>0</slash:comments><description>&lt;p&gt;I recently got to playing with Ruby, something that some colleagues in Lab49 have been big fans for some time.&amp;nbsp; I&amp;#39;ve never been a big fan of scripting languages, but have grown more of an appreciation for functional programming over the past several months and thought I would give it a try.&lt;/p&gt;
&lt;p&gt;Ruby is a very smart language, and I can certainly see why it has some appeal.&amp;nbsp; The &amp;quot;don&amp;#39;t repeat yourself&amp;quot; and &amp;quot;defaults over configuration&amp;quot; aspects of&amp;nbsp;the language&amp;nbsp;and its framework are really nice for cranking out simple applications.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;ORM and Inference of Properties from database&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;I am a big fan of the objects that automatically get their properties from the database (a &lt;strong&gt;Customer&lt;/strong&gt; object will automatically be linked with the &lt;strong&gt;Customers&lt;/strong&gt; table when pulled through the ORM).&amp;nbsp; Things like this make it dirt simple to crank out web projects of moderate size without writing tons of redundant code (as is the case with a classic OO approach, using adapters, abstractions, etc).&lt;/p&gt;
&lt;p&gt;Even though this is a nice feature, and great for many projects, I am concerned that this is simply not sufficient for larger enterprise apps.&amp;nbsp; Very often your app layer and database layer should be different, as one does not always properly map to the other.&amp;nbsp; I suppose that you could achieve this nicely with views, however for large applications, the lack of abstraction seems a little brittle to me.&amp;nbsp; At the same time, if you did change something in your database, you&amp;#39;d still have to change your abstraction logic, so maybe this isn&amp;#39;t all that bad.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Syntax&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;The syntax of Ruby is very clean and straight forward.&amp;nbsp; I like the bare bones structure, nothing more than needed is written.&amp;nbsp; Reading into it a bit more, I found it interesting that various things can be written in several ways, for example:&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;while i &amp;lt; 3&lt;br /&gt;&amp;nbsp;&amp;nbsp; print(i)&lt;br /&gt;&lt;/strong&gt;&lt;strong&gt;end&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;can also be written&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;print(i) while i &amp;lt; 3&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;While conceptually this is nice (the latter &amp;quot;reads&amp;quot; better), it is something I have a really hard time accepting.&amp;nbsp; Yes it is nice not to have to write things like &amp;quot;end&amp;quot;, however, syntactical differences like this (and others, such as the optional parenthesis around method parameters) concern me.&amp;nbsp; While its great that you can develop your own style, and do what feels comfortable to you, it may be very confusing to other developers.&amp;nbsp; An argument can be made either way, after call you can do this:&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;if (i &amp;lt; 3) Console.WriteLine(i);&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;in C#.&amp;nbsp; Nothing stops you.&amp;nbsp; At the end of the day, sloppy code is sloppy code, and its really a matter of having a well trained developer, not a strict language.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Naming Conventions&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Here&amp;#39;s something that threw me off.&amp;nbsp; Ruby does a very good job of making names intuitive, however some of their names seem to break their own concepts.&amp;nbsp; First of all, names like &lt;strong&gt;to_s&lt;/strong&gt; are just sloppy.&amp;nbsp; If you&amp;#39;re making a lanugage thats supposed to be readable, why write cryptic names like this?&amp;nbsp; Also, whats the deal with properties &lt;strong&gt;count&lt;/strong&gt; and &lt;strong&gt;length&lt;/strong&gt; being synonyms?&amp;nbsp; Why have both?&amp;nbsp; It seems relatively dangerous to me to have methods that mean the same thing on objects.&amp;nbsp; A developer who sees &lt;strong&gt;count&lt;/strong&gt; in one place and &lt;strong&gt;length&lt;/strong&gt; in another may think they are different, something that certainly doesn&amp;#39;t help code legibility.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Overall, Ruby has been fun to learn (although I&amp;#39;m still a novice), and I can certainly see its value.&amp;nbsp; I&amp;#39;m not sure if I agree with some of its &amp;quot;friendly&amp;quot; &lt;span style="FONT-SIZE:10pt;LINE-HEIGHT:115%;FONT-FAMILY:&amp;#39;Arial&amp;#39;,&amp;#39;sans-serif&amp;#39;;mso-fareast-font-family:Calibri;mso-fareast-theme-font:minor-latin;mso-ansi-language:EN-US;mso-fareast-language:EN-US;mso-bidi-language:AR-SA;"&gt;tendencies &lt;/span&gt;-- being able to write whatever you feel and have it probably compile is not &lt;span style="FONT-SIZE:10pt;LINE-HEIGHT:115%;FONT-FAMILY:&amp;#39;Arial&amp;#39;,&amp;#39;sans-serif&amp;#39;;mso-fareast-font-family:Calibri;mso-fareast-theme-font:minor-latin;mso-ansi-language:EN-US;mso-fareast-language:EN-US;mso-bidi-language:AR-SA;"&gt;necessarily &lt;/span&gt;good.&amp;nbsp; Just because code compiles doesn&amp;#39;t mean its good code -- some bugs the compiler may catch now become runtime bugs.&amp;nbsp; On the other hand, things like the ORM make it very easy to build rich apps with little code, something that .NET still comes up short on (just because designers generate LINQ classes doesn&amp;#39;t mean that the code isn&amp;#39;t there).&amp;nbsp; Looking forward to playing more!&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;img src="http://decav.com/aggbug.aspx?PostID=30515" width="1" height="1"&gt;</description><category domain="http://decav.com/blogs/andre/archive/tags/Web+2.0/default.aspx">Web 2.0</category><category domain="http://decav.com/blogs/andre/archive/tags/On+Software/default.aspx">On Software</category><category domain="http://decav.com/blogs/andre/archive/tags/Ruby/default.aspx">Ruby</category></item><item><title>WPF Compute Cluster Monitor Demo - Using 3D, Transparency and Styles</title><link>http://decav.com/blogs/andre/archive/2008/02/19/wpf-compute-cluster-montor-demo-using-3d-transparency-and-styles.aspx</link><pubDate>Tue, 19 Feb 2008 21:22:00 GMT</pubDate><guid isPermaLink="false">1a6c50a2-1cc5-440d-a734-51a167eba982:29564</guid><dc:creator>mrdecav</dc:creator><slash:comments>3</slash:comments><description>&lt;p&gt;Here&amp;#39;s a cool demo that Ronald Lintag&amp;nbsp;and I threw together for Lab49.&amp;nbsp; The application is supposed to demo a basic GUI that shows the status of nodes and jobs on a compute cluster.&amp;nbsp; We&amp;#39;re showing off the use of WPF 3D and styles to create a cool looking console for a sys-admin.&amp;nbsp; You can imagine how something developed off this base could turn into a real product.&lt;/p&gt;
&lt;p&gt;This demo is a bit rough around the edges, and definately needs polish, but its still worth a look.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;div&gt;Press &lt;strong&gt;J&lt;/strong&gt; to bring up the job list.&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;Use the dropdown at the bottom of the job list to add some jobs.&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;Click on job to view details about their tasks.&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;The nodes in the background vary from gray to green to red depending on their utilization&lt;/div&gt;&lt;/li&gt;&lt;/ul&gt;
&lt;p&gt;&lt;a class="" href="http://www.lab49.com/files/demos/GridDemo/GridDemo.application"&gt;Click here to launch the application (.NET 3.5 required)&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Here are a few screenshots for those of you who are not adveturous enough for the ClickOnce...&lt;/p&gt;
&lt;p&gt;&lt;a class="" href="http://decav.com/photos/misc/picture29562.aspx"&gt;&lt;img style="WIDTH:469px;HEIGHT:375px;" height="375" src="http://decav.com/photos/misc/images/29562/500x375.aspx" width="469" alt="" /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;a class="" href="http://decav.com/photos/misc/picture29563.aspx"&gt;&lt;img src="http://decav.com/photos/misc/images/29563/500x375.aspx" alt="" /&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://decav.com/aggbug.aspx?PostID=29564" width="1" height="1"&gt;</description><category domain="http://decav.com/blogs/andre/archive/tags/.NET_2F00_C_2300_+Development/default.aspx">.NET/C# Development</category><category domain="http://decav.com/blogs/andre/archive/tags/On+Software/default.aspx">On Software</category><category domain="http://decav.com/blogs/andre/archive/tags/Windows+Presentation+Foundation/default.aspx">Windows Presentation Foundation</category><category domain="http://decav.com/blogs/andre/archive/tags/Cluster+Computing/default.aspx">Cluster Computing</category></item><item><title>Distributed/Grid Computing with Silverlight</title><link>http://decav.com/blogs/andre/archive/2007/12/26/distributed-grid-computing-with-silverlight.aspx</link><pubDate>Wed, 26 Dec 2007 08:07:00 GMT</pubDate><guid isPermaLink="false">1a6c50a2-1cc5-440d-a734-51a167eba982:22708</guid><dc:creator>mrdecav</dc:creator><slash:comments>3</slash:comments><description>&lt;p&gt;Daniel Vaughan has a very cool project up on CodeProject.com.&amp;nbsp; He&amp;#39;s built an awesome grid computing &amp;quot;platform&amp;quot; using&amp;nbsp;Silverlight for his compute nodes.&amp;nbsp; Think &lt;a href="mailto:SETI@Home"&gt;SETI@Home&lt;/a&gt; style.&lt;/p&gt;
&lt;p&gt;CodeProject article: &lt;span style="FONT-SIZE:10pt;COLOR:navy;FONT-FAMILY:&amp;#39;Arial&amp;#39;,&amp;#39;sans-serif&amp;#39;;mso-fareast-font-family:Calibri;mso-fareast-theme-font:minor-latin;mso-ansi-language:EN-AU;mso-fareast-language:EN-US;mso-bidi-language:AR-SA;"&gt;&lt;a href="http://www.codeproject.com/KB/silverlight/GridComputing.aspx"&gt;http://www.codeproject.com/KB/silverlight/GridComputing.aspx&lt;/a&gt; &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="FONT-SIZE:10pt;COLOR:navy;FONT-FAMILY:&amp;#39;Arial&amp;#39;,&amp;#39;sans-serif&amp;#39;;mso-fareast-font-family:Calibri;mso-fareast-theme-font:minor-latin;mso-ansi-language:EN-AU;mso-fareast-language:EN-US;mso-bidi-language:AR-SA;"&gt;Online Demo: &lt;a href="http://www.orpius.com/Silverlight/Legion/"&gt;http://www.orpius.com/Silverlight/Legion/&lt;/a&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="FONT-SIZE:10pt;COLOR:navy;FONT-FAMILY:&amp;#39;Arial&amp;#39;,&amp;#39;sans-serif&amp;#39;;mso-fareast-font-family:Calibri;mso-fareast-theme-font:minor-latin;mso-ansi-language:EN-AU;mso-fareast-language:EN-US;mso-bidi-language:AR-SA;"&gt;Make sure you checkout the administration console in the demo!&lt;/span&gt;&lt;/p&gt;&lt;img src="http://decav.com/aggbug.aspx?PostID=22708" width="1" height="1"&gt;</description><category domain="http://decav.com/blogs/andre/archive/tags/.NET_2F00_C_2300_+Development/default.aspx">.NET/C# Development</category><category domain="http://decav.com/blogs/andre/archive/tags/On+Software/default.aspx">On Software</category><category domain="http://decav.com/blogs/andre/archive/tags/Windows+Presentation+Foundation/default.aspx">Windows Presentation Foundation</category><category domain="http://decav.com/blogs/andre/archive/tags/Cluster+Computing/default.aspx">Cluster Computing</category><category domain="http://decav.com/blogs/andre/archive/tags/Silverlight/default.aspx">Silverlight</category></item><item><title>Windows Compute Cluster (HPC) Basics: Running Map/Reduce Models on CCS 2003</title><link>http://decav.com/blogs/andre/archive/2007/12/26/windows-compute-cluster-hpc-basics-running-map-reduce-models-on-ccs-2003.aspx</link><pubDate>Wed, 26 Dec 2007 07:31:00 GMT</pubDate><guid isPermaLink="false">1a6c50a2-1cc5-440d-a734-51a167eba982:22703</guid><dc:creator>mrdecav</dc:creator><slash:comments>2</slash:comments><description>&lt;p&gt;After not writing anything about HPC or Windows Compute Cluster for a while, I figured its about time I write *something* about it because I&amp;#39;ve been working with it so much recently!&lt;/p&gt;
&lt;p&gt;&lt;a class="" href="http://decav.com/files/folders/22706/download.aspx"&gt;Download the Sample Project&lt;/a&gt; (Visual Studio 2008, Beta 2)&lt;/p&gt;
&lt;p&gt;&lt;a class="" title="Microsoft Windows Compute Cluster Server" href="http://www.windowshpc.net/"&gt;Windows Compute Cluster Server 2003&lt;/a&gt; is Microsoft&amp;#39;s relatively new implementation of cluster computing running on Windows.&amp;nbsp; Although Microsoft is starting behind in this game (Unix has been in grid computing for a long time now), the .NET development environment and ease of administration makes CCS a very compelling environment.&amp;nbsp; The first version of CCS is not very feature rich, but provides the core components required to build distributed applications.&amp;nbsp; Version 2 (named Windows HPC 2008) which is currently in beta&amp;nbsp;offers a much wider range of functionality and should add some new ideas and competitve edge to the Windows grid computing world.&lt;/p&gt;
&lt;p&gt;In my current project, I have gotten to experience quite a bit of what CCS has to offer, and have been building on top of the CCS system.&amp;nbsp; One of the common tasks that we&amp;#39;ve run accross is the ability to run &amp;quot;map-reduce&amp;quot; style financial models against the cluster.&amp;nbsp; These types of models require a wide range specified by an input parameter to be split into segments of work that can be executed in parallel against the cluster.&amp;nbsp; The segments generally create a significant amount of output data, which then must be summarized by a reduce process to produce a &amp;quot;meaningful&amp;quot; output.&amp;nbsp; In some cases, the summarized output will then be fed into another map, and the process continues.&lt;/p&gt;
&lt;p&gt;&lt;img title="A Simple Map/Reduce Diagram" style="WIDTH:561px;HEIGHT:469px;" height="469" alt="A Simple Map/Reduce Diagram" src="http://decav.com/photos/misc/images/22702/original.aspx" width="561" /&gt;&lt;/p&gt;
&lt;p&gt;The ability to run a simple process like the one shown above is an important capability of CCS, however CCS is designed to be a tool, not a means to the goal, and does not have built in support for a &amp;quot;map reduce&amp;quot;.&amp;nbsp; In the worlds of CCS, each step outline in the graph (the map, segments and reduce) would all be &amp;quot;tasks&amp;quot; grouped into one logical &amp;quot;job&amp;quot;.&lt;/p&gt;
&lt;p&gt;To handle this map/reduce scenario, a function of CCS jobs, task dependencies, can be used to ensure that the tasks run in the proper order (and that the reduce does not occur before all the segments have completed).&amp;nbsp; In the sample code included with this project, three console apps are included.&amp;nbsp; One does the split, one runs a&amp;nbsp;single map, and one does the reduce.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Split:&lt;/strong&gt;&amp;nbsp;&lt;br /&gt;The&amp;nbsp;split will add tasks to the job that it is currently a member of so that they can run as maps.&amp;nbsp; The maps will each get their own input file so that they know which segment they are responsible for.&amp;nbsp; Each map task also &amp;quot;depends&amp;quot; on the&amp;nbsp;split task, meaning that they will wait for the split to complete before they start.&lt;/p&gt;
&lt;p&gt;The split will also schedule a reduce task, and ensure that that task depends on all the maps, so it does not start until all maps are complete.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Map:&lt;br /&gt;&lt;/strong&gt;Each map/segment will run given its input prameters (written by the map) and output another file containing their results.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Reduce&lt;/strong&gt;:&lt;br /&gt;The reduce step will take all the map outputs and run an average on the values to come up with a &amp;quot;summarized&amp;quot; value, in this case, the average of the primes that were requested.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;How To Run This Project:&lt;/strong&gt;&lt;br /&gt;When you run this model, it is expected that you use a system such as the CCS job console, the command line interface or your own custom-built interface to submit a job with the following characteristics:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;div&gt;The only task specified to run within the job is the map task, where the first command line parameter is the input XML&amp;nbsp;file you want to use (this input file needs to&amp;nbsp;be&amp;nbsp;defined to be deserialized into a &lt;strong&gt;PrimeFinderInput&lt;/strong&gt; object)&amp;nbsp; (This task is responsible for creating the rest of the required tasks)&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;The &amp;quot;minimum processor count&amp;quot; is set to the number of nodes processors you wish to parallelize accross.&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;Your input parameters are well formed, and the &lt;strong&gt;Processors &lt;/strong&gt;property of the input is set to the number of segments you want to run.&amp;nbsp; Ideally this is equal to (or greater than) the &amp;quot;minimum processor count&amp;quot;.&lt;/div&gt;&lt;/li&gt;&lt;/ul&gt;
&lt;p&gt;There you have it.&amp;nbsp; The basics to a simple map/reduce job in CCS!&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;a class="" href="http://decav.com/files/folders/22706/download.aspx"&gt;Download the Sample Project&lt;/a&gt; (Visual Studio 2008, Beta 2)&lt;/p&gt;&lt;img src="http://decav.com/aggbug.aspx?PostID=22703" width="1" height="1"&gt;</description><category domain="http://decav.com/blogs/andre/archive/tags/.NET_2F00_C_2300_+Development/default.aspx">.NET/C# Development</category><category domain="http://decav.com/blogs/andre/archive/tags/On+Software/default.aspx">On Software</category><category domain="http://decav.com/blogs/andre/archive/tags/Cluster+Computing/default.aspx">Cluster Computing</category><category domain="http://decav.com/blogs/andre/archive/tags/Windows+HPC/default.aspx">Windows HPC</category></item><item><title>WTF: "Problems" with Anonymous Delegates, LINQ, Lambdas within "foreach" or "for" Loops</title><link>http://decav.com/blogs/andre/archive/2007/11/18/wtf-quot-problems-quot-with-anonymous-delegates-linq-lambdas-and-quot-foreach-quot-or-quot-for-quot-loops.aspx</link><pubDate>Sun, 18 Nov 2007 19:30:00 GMT</pubDate><guid isPermaLink="false">1a6c50a2-1cc5-440d-a734-51a167eba982:16567</guid><dc:creator>mrdecav</dc:creator><slash:comments>1</slash:comments><description>&lt;p&gt;&lt;a class="" href="http://decav.com/files/folders/16575/download.aspx"&gt;Sample code available here&amp;nbsp;that exemplifies this bug&amp;nbsp;(requires Visual Studio 2008 Beta 2 and SQL Server).&lt;/a&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;So here is an &lt;strong&gt;incredibly&lt;/strong&gt; unintuitive problem I ran into with &lt;strong&gt;anonymous delegates&lt;/strong&gt; (same will happen for &lt;strong&gt;lambda expressions&lt;/strong&gt;) in C# while using them &lt;strong&gt;inside loops&lt;/strong&gt;.&amp;nbsp; This will also happen in a few other circumstances (for example, in &lt;strong&gt;LINQ&lt;/strong&gt;) , as I will explain in a minute below.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Symptom:&lt;br /&gt;&lt;/strong&gt;When using an anonymous delegate or lambda expression inside a loop, the results of the delegates execution (outside of the loop) are unexpected.&amp;nbsp; For example:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;div&gt;Your expression is not evaluated as you expect and returns an unexpected value.&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;Your &lt;strong&gt;LINQ&lt;/strong&gt; or &lt;strong&gt;DLINQ&lt;/strong&gt; (&lt;strong&gt;LINQ2SQL&lt;/strong&gt;) execution creates SQL or a query result which is not consistant with your assumptions based on how your loop was constructed.&lt;/div&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/blockquote&gt;
&lt;p&gt;This problem exists when you create an anonymous delegate inside a loop, &lt;strong&gt;using the loop&amp;#39;s variable within the delegate&lt;/strong&gt;, or when you&lt;strong&gt; change a variable after creating an anonymous delegate&lt;/strong&gt;.&amp;nbsp; The result is sensibly by design but pretty misleading, especially the first time you see it.&amp;nbsp; Take the example below.&amp;nbsp; This example was sent to me by a Microsoft employee after I filed a bug with them.&amp;nbsp; He claims this is by design, and conceptually I agree with him.&amp;nbsp; Can you guess what would be returned with the statement below?&lt;/p&gt;
&lt;div class="csharpcode"&gt;&lt;pre&gt;&lt;span class="lnum"&gt;   1:  &lt;/span&gt;&lt;span class="kwrd"&gt;const&lt;/span&gt; &lt;span class="kwrd"&gt;int&lt;/span&gt; count = 10;&lt;/pre&gt;&lt;pre&gt;&lt;span class="lnum"&gt;   2:  &lt;/span&gt;Predicate&amp;lt;&lt;span class="kwrd"&gt;int&lt;/span&gt;&amp;gt;[] predicates = &lt;span class="kwrd"&gt;new&lt;/span&gt; Predicate&amp;lt;&lt;span class="kwrd"&gt;int&lt;/span&gt;&amp;gt;[count];&lt;/pre&gt;&lt;pre&gt;&lt;span class="lnum"&gt;   3:  &lt;/span&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre&gt;&lt;span class="lnum"&gt;   4:  &lt;/span&gt;&lt;span class="kwrd"&gt;for&lt;/span&gt; (&lt;span class="kwrd"&gt;int&lt;/span&gt; i = 0; i &amp;lt; count; i++)&lt;/pre&gt;&lt;pre&gt;&lt;span class="lnum"&gt;   5:  &lt;/span&gt;{&lt;/pre&gt;&lt;pre&gt;&lt;span class="lnum"&gt;   6:  &lt;/span&gt;    predicates[ i ] = &lt;span class="kwrd"&gt;delegate&lt;/span&gt;(&lt;span class="kwrd"&gt;int&lt;/span&gt; j) { &lt;span class="kwrd"&gt;return&lt;/span&gt; i == j; };&lt;/pre&gt;&lt;pre&gt;&lt;span class="lnum"&gt;   7:  &lt;/span&gt;}&lt;/pre&gt;&lt;pre&gt;&lt;span class="lnum"&gt;   8:  &lt;/span&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre&gt;&lt;span class="lnum"&gt;   9:  &lt;/span&gt;Console.WriteLine(predicates[0](0)); &lt;span class="rem"&gt;// False&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;&lt;span class="lnum"&gt;  10:  &lt;/span&gt;Console.WriteLine(predicates[0](count-1)); // True&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;When the first predicate (&lt;strong&gt;predicates[0]&lt;/strong&gt;) is called in above, one may expect it to return true because when it was created &lt;strong&gt;i == 0&lt;/strong&gt;.&amp;nbsp; This is where it gets confusing.&amp;nbsp; In the closure of the anonymous delegate, the variable &lt;strong&gt;i&lt;/strong&gt; is held &lt;strong&gt;by reference&lt;/strong&gt;, not by value.&amp;nbsp; Because &lt;strong&gt;int i&lt;/strong&gt; is declared outside of the loop, &lt;strong&gt;i&lt;/strong&gt; within the delegate&amp;#39;s closure will increment along with the for loop.&amp;nbsp; Once we leave the for loop, &lt;strong&gt;i&lt;/strong&gt; is the max value of &lt;strong&gt;i&lt;/strong&gt; throughout the loop (or &lt;strong&gt;count-1&lt;/strong&gt;).&amp;nbsp; Not what you were expecting?&amp;nbsp; Me either.&lt;/p&gt;
&lt;p&gt;The next example shows the &amp;quot;correct&amp;quot; way of dealing with this, such that &lt;strong&gt;line 9&lt;/strong&gt; of the code above returns true.&lt;/p&gt;
&lt;div class="csharpcode"&gt;&lt;pre&gt;&lt;span class="lnum"&gt;   1:  &lt;/span&gt;&lt;span class="kwrd"&gt;for&lt;/span&gt; (&lt;span class="kwrd"&gt;int&lt;/span&gt; k = 0; k &amp;lt; count; k++)&lt;/pre&gt;&lt;pre&gt;&lt;span class="lnum"&gt;   2:  &lt;/span&gt;{&lt;/pre&gt;&lt;pre&gt;&lt;span class="lnum"&gt;   3:  &lt;/span&gt;    &lt;span class="kwrd"&gt;int&lt;/span&gt; l = k;&lt;/pre&gt;&lt;pre&gt;&lt;span class="lnum"&gt;   4:  &lt;/span&gt;    predicates[k] = &lt;span class="kwrd"&gt;delegate&lt;/span&gt;(&lt;span class="kwrd"&gt;int&lt;/span&gt; m) { &lt;span class="kwrd"&gt;return&lt;/span&gt; l == m; };&lt;/pre&gt;&lt;pre&gt;&lt;span class="lnum"&gt;   5:  &lt;/span&gt;}&lt;/pre&gt;&lt;pre&gt;&lt;span class="lnum"&gt;   6:  &lt;/span&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre&gt;&lt;span class="lnum"&gt;   7:  &lt;/span&gt;Console.WriteLine(predicates[0](0)); &lt;span class="rem"&gt;// True&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;In this case, because variable &lt;strong&gt;l&lt;/strong&gt; is created within the for loop, holding reference to &lt;strong&gt;l&lt;/strong&gt; in the delegate is okay, because the value of &lt;strong&gt;l&lt;/strong&gt; will never change, and therefore we get our expected result.&amp;nbsp; Personally, I was originally expecting it to hold the value of the variable, not the reference to the variable.&lt;/p&gt;
&lt;p&gt;This brings us to another interesting example (my original, which you may download the source code to below), where I construct a DLINQ where clause in a loop.&amp;nbsp; Look at the where clause constructed below.&lt;/p&gt;
&lt;div class="csharpcode"&gt;&lt;pre&gt;&lt;span class="lnum"&gt;   1:  &lt;/span&gt;&lt;span class="rem"&gt;// Create a few new items that we can test with.&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;&lt;span class="lnum"&gt;   2:  &lt;/span&gt;TestEntity[] testData = &lt;span class="kwrd"&gt;new&lt;/span&gt; TestEntity[] {&lt;/pre&gt;&lt;pre&gt;&lt;span class="lnum"&gt;   3:  &lt;/span&gt;        &lt;span class="kwrd"&gt;new&lt;/span&gt; TestEntity(1, &lt;span class="str"&gt;&amp;quot;One&amp;quot;&lt;/span&gt;),&lt;/pre&gt;&lt;pre&gt;&lt;span class="lnum"&gt;   4:  &lt;/span&gt;        &lt;span class="kwrd"&gt;new&lt;/span&gt; TestEntity(2, &lt;span class="str"&gt;&amp;quot;Two&amp;quot;&lt;/span&gt;),&lt;/pre&gt;&lt;pre&gt;&lt;span class="lnum"&gt;   5:  &lt;/span&gt;        &lt;span class="kwrd"&gt;new&lt;/span&gt; TestEntity(3, &lt;span class="str"&gt;&amp;quot;Three&amp;quot;&lt;/span&gt;) };&lt;/pre&gt;&lt;pre&gt;&lt;span class="lnum"&gt;   6:  &lt;/span&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre&gt;&lt;span class="lnum"&gt;   7:  &lt;/span&gt;&lt;span class="rem"&gt;// Add all our test data and submit it to the server&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;&lt;span class="lnum"&gt;   8:  &lt;/span&gt;&lt;span class="kwrd"&gt;foreach&lt;/span&gt; (TestEntity item &lt;span class="kwrd"&gt;in&lt;/span&gt; testData)&lt;/pre&gt;&lt;pre&gt;&lt;span class="lnum"&gt;   9:  &lt;/span&gt;{&lt;/pre&gt;&lt;pre&gt;&lt;span class="lnum"&gt;  10:  &lt;/span&gt;    context.TestEntities.Add(item);&lt;/pre&gt;&lt;pre&gt;&lt;span class="lnum"&gt;  11:  &lt;/span&gt;    Console.WriteLine(item.Name);&lt;/pre&gt;&lt;pre&gt;&lt;span class="lnum"&gt;  12:  &lt;/span&gt;}&lt;/pre&gt;&lt;pre&gt;&lt;span class="lnum"&gt;  13:  &lt;/span&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre&gt;&lt;span class="lnum"&gt;  14:  &lt;/span&gt;context.SubmitChanges();&lt;/pre&gt;&lt;pre&gt;&lt;span class="lnum"&gt;  15:  &lt;/span&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre&gt;&lt;span class="lnum"&gt;  16:  &lt;/span&gt;var result = from item &lt;span class="kwrd"&gt;in&lt;/span&gt; context.TestEntities&lt;/pre&gt;&lt;pre&gt;&lt;span class="lnum"&gt;  17:  &lt;/span&gt;             select item;&lt;/pre&gt;&lt;pre&gt;&lt;span class="lnum"&gt;  18:  &lt;/span&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre&gt;&lt;span class="lnum"&gt;  19:  &lt;/span&gt;&lt;span class="rem"&gt;// Go through all our local items and append &amp;quot;WHERE&amp;quot; clauses to the&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;&lt;span class="lnum"&gt;  20:  &lt;/span&gt;&lt;span class="rem"&gt;// result statement.  This is kind of like doing a &amp;quot;NOT IN&amp;quot;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;&lt;span class="lnum"&gt;  21:  &lt;/span&gt;&lt;span class="kwrd"&gt;foreach&lt;/span&gt; (TestEntity localItem &lt;span class="kwrd"&gt;in&lt;/span&gt; testData)&lt;/pre&gt;&lt;pre&gt;&lt;span class="lnum"&gt;  22:  &lt;/span&gt;{&lt;/pre&gt;&lt;pre&gt;&lt;span class="lnum"&gt;  23:  &lt;/span&gt;    &lt;span class="rem"&gt;// See note in FixedTest for diagnosis.&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;&lt;span class="lnum"&gt;  24:  &lt;/span&gt;    result = result.Where(sqlItem =&amp;gt; sqlItem.Name != localItem.Name);&lt;/pre&gt;&lt;pre&gt;&lt;span class="lnum"&gt;  25:  &lt;/span&gt;}&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;One would expect that the WHERE clause would exclude all the items in the &lt;strong&gt;testData&lt;/strong&gt; array (&amp;quot;one&amp;quot;, &amp;quot;two&amp;quot; and &amp;quot;three&amp;quot; would not be selected).&amp;nbsp; However, because &lt;strong&gt;localItem&lt;/strong&gt; is held by reference, only the third item (&amp;quot;three&amp;quot;) is not selected.&amp;nbsp; The code below will print &amp;quot;one&amp;quot; and &amp;quot;two&amp;quot; on seperate lines:&lt;/p&gt;
&lt;div class="csharpcode"&gt;&lt;pre&gt;&lt;span class="lnum"&gt;   1:  &lt;/span&gt;&lt;span class="rem"&gt;// The WHERE clauses above should have effectively cancelled out all&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;&lt;span class="lnum"&gt;   2:  &lt;/span&gt;&lt;span class="rem"&gt;// the items in the database and left us selecting nothing.&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;&lt;span class="lnum"&gt;   3:  &lt;/span&gt;&lt;span class="kwrd"&gt;foreach&lt;/span&gt; (var item &lt;span class="kwrd"&gt;in&lt;/span&gt; result)&lt;/pre&gt;&lt;pre&gt;&lt;span class="lnum"&gt;   4:  &lt;/span&gt;{&lt;/pre&gt;&lt;pre&gt;&lt;span class="lnum"&gt;   5:  &lt;/span&gt;    Console.WriteLine(item.Name);&lt;/pre&gt;&lt;pre&gt;&lt;span class="lnum"&gt;   6:  &lt;/span&gt;}&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;One would have expected nothing to be printed to the console by simply reading the code.&lt;/p&gt;
&lt;p&gt;&lt;a class="" title="Sample code for known issue with Anonymous Delegates and LINQ in &amp;quot;foreach&amp;quot; loops." href="http://decav.com/files/folders/16575/download.aspx"&gt;You can download some sample code here for this bug (Visual Studio 2008 Beta 2)&lt;/a&gt;.&amp;nbsp; Note that you will need a SQL Server database at localhost to run this properly.&lt;/p&gt;
&lt;p&gt;Thank you to Colin Meek of Microsoft for contributing some of the sample code above, and helping clarify that this functionality is by design in C#.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Update:&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;To clarify, I&amp;#39;m not saying that this behavior doesn&amp;#39;t make sense, but more that its not expected.&amp;nbsp; I think this should at least provide a compiler warning (I believe VB does this) to tell you that you could possibly be confusing something in your logic.&amp;nbsp; Because of LINQ&amp;#39;s delay-execute, this problem becomes more obvious in the &amp;quot;Where&amp;quot; example.&lt;/p&gt;&lt;img src="http://decav.com/aggbug.aspx?PostID=16567" width="1" height="1"&gt;</description><category domain="http://decav.com/blogs/andre/archive/tags/.NET_2F00_C_2300_+Development/default.aspx">.NET/C# Development</category><category domain="http://decav.com/blogs/andre/archive/tags/On+Software/default.aspx">On Software</category></item><item><title>Tricky Generics: "New" Keyword and Generics</title><link>http://decav.com/blogs/andre/archive/2007/11/16/tricky-generics-quot-new-quot-keyword-and-generics.aspx</link><pubDate>Fri, 16 Nov 2007 19:42:00 GMT</pubDate><guid isPermaLink="false">1a6c50a2-1cc5-440d-a734-51a167eba982:16222</guid><dc:creator>mrdecav</dc:creator><slash:comments>1</slash:comments><description>&lt;p&gt;Trying to decide how to write some unit test helper classes, I ran into an interesting question.&amp;nbsp; What happens when you use the &lt;strong&gt;new&lt;/strong&gt; keyword along with .NET generics?&amp;nbsp; The example below shows my dilemma:&lt;/p&gt;
&lt;div class="csharpcode"&gt;&lt;pre&gt;&lt;span class="lnum"&gt;   1:  &lt;/span&gt;[TestMethod]&lt;/pre&gt;&lt;pre&gt;&lt;span class="lnum"&gt;   2:  &lt;/span&gt;&lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; DoBase()&lt;/pre&gt;&lt;pre&gt;&lt;span class="lnum"&gt;   3:  &lt;/span&gt;{&lt;/pre&gt;&lt;pre&gt;&lt;span class="lnum"&gt;   4:  &lt;/span&gt;    DoT&amp;lt;Base&amp;gt;(&lt;span class="kwrd"&gt;new&lt;/span&gt; Base());&lt;/pre&gt;&lt;pre&gt;&lt;span class="lnum"&gt;   5:  &lt;/span&gt;}&lt;/pre&gt;&lt;pre&gt;&lt;span class="lnum"&gt;   6:  &lt;/span&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre&gt;&lt;span class="lnum"&gt;   7:  &lt;/span&gt;[TestMethod]&lt;/pre&gt;&lt;pre&gt;&lt;span class="lnum"&gt;   8:  &lt;/span&gt;&lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; DoDerived()&lt;/pre&gt;&lt;pre&gt;&lt;span class="lnum"&gt;   9:  &lt;/span&gt;{&lt;/pre&gt;&lt;pre&gt;&lt;span class="lnum"&gt;  10:  &lt;/span&gt;    DoT&amp;lt;Derived&amp;gt;(&lt;span class="kwrd"&gt;new&lt;/span&gt; Derived());&lt;/pre&gt;&lt;pre&gt;&lt;span class="lnum"&gt;  11:  &lt;/span&gt;}&lt;/pre&gt;&lt;pre&gt;&lt;span class="lnum"&gt;  12:  &lt;/span&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre&gt;&lt;span class="lnum"&gt;  13:  &lt;/span&gt;&lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; DoT&amp;lt;T&amp;gt;(T item)&lt;/pre&gt;&lt;pre&gt;&lt;span class="lnum"&gt;  14:  &lt;/span&gt;    &lt;span class="kwrd"&gt;where&lt;/span&gt; T : Base&lt;/pre&gt;&lt;pre&gt;&lt;span class="lnum"&gt;  15:  &lt;/span&gt;{&lt;/pre&gt;&lt;pre&gt;&lt;span class="lnum"&gt;  16:  &lt;/span&gt;    item.Blah();&lt;/pre&gt;&lt;pre&gt;&lt;span class="lnum"&gt;  17:  &lt;/span&gt;}&lt;/pre&gt;&lt;pre&gt;&lt;span class="lnum"&gt;  18:  &lt;/span&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre&gt;&lt;span class="lnum"&gt;  19:  &lt;/span&gt;&lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;class&lt;/span&gt; Base&lt;/pre&gt;&lt;pre&gt;&lt;span class="lnum"&gt;  20:  &lt;/span&gt;{&lt;/pre&gt;&lt;pre&gt;&lt;span class="lnum"&gt;  21:  &lt;/span&gt;    &lt;span class="kwrd"&gt;public&lt;/span&gt; Base()&lt;/pre&gt;&lt;pre&gt;&lt;span class="lnum"&gt;  22:  &lt;/span&gt;    {&lt;/pre&gt;&lt;pre&gt;&lt;span class="lnum"&gt;  23:  &lt;/span&gt;    }&lt;/pre&gt;&lt;pre&gt;&lt;span class="lnum"&gt;  24:  &lt;/span&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre&gt;&lt;span class="lnum"&gt;  25:  &lt;/span&gt;    &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; Blah()&lt;/pre&gt;&lt;pre&gt;&lt;span class="lnum"&gt;  26:  &lt;/span&gt;    {&lt;/pre&gt;&lt;pre&gt;&lt;span class="lnum"&gt;  27:  &lt;/span&gt;        Console.WriteLine(&lt;span class="str"&gt;&amp;quot;Hello&amp;quot;&lt;/span&gt;);&lt;/pre&gt;&lt;pre&gt;&lt;span class="lnum"&gt;  28:  &lt;/span&gt;    }&lt;/pre&gt;&lt;pre&gt;&lt;span class="lnum"&gt;  29:  &lt;/span&gt;}&lt;/pre&gt;&lt;pre&gt;&lt;span class="lnum"&gt;  30:  &lt;/span&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre&gt;&lt;span class="lnum"&gt;  31:  &lt;/span&gt;&lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;class&lt;/span&gt; Derived : Base&lt;/pre&gt;&lt;pre&gt;&lt;span class="lnum"&gt;  32:  &lt;/span&gt;{&lt;/pre&gt;&lt;pre&gt;&lt;span class="lnum"&gt;  33:  &lt;/span&gt;    &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;new&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; Blah()&lt;/pre&gt;&lt;pre&gt;&lt;span class="lnum"&gt;  34:  &lt;/span&gt;    {&lt;/pre&gt;&lt;pre&gt;&lt;span class="lnum"&gt;  35:  &lt;/span&gt;        Console.WriteLine(&lt;span class="str"&gt;&amp;quot;Bye&amp;quot;&lt;/span&gt;);&lt;/pre&gt;&lt;pre&gt;&lt;span class="lnum"&gt;  36:  &lt;/span&gt;    }&lt;/pre&gt;&lt;pre&gt;&lt;span class="lnum"&gt;  37:  &lt;/span&gt;}&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;The question is what happens when you call &lt;strong&gt;DoDerived()&lt;/strong&gt;?&amp;nbsp; Because the class is typed as &lt;strong&gt;T&lt;/strong&gt; (which in this case is the &lt;strong&gt;Derived&lt;/strong&gt; class), you would expect &amp;quot;Bye&amp;quot; to be written to the console.&amp;nbsp; How would that work though, since the compiler has no concept of &lt;strong&gt;Derived.Blah&lt;/strong&gt;, and therefore cannot generate the IL to access it at compile time of the generic?&lt;/p&gt;
&lt;p&gt;Sure enough, &amp;quot;Hello&amp;quot; will be written from &lt;strong&gt;Base.Blah&lt;/strong&gt;, as if we were cast to &lt;strong&gt;Base&lt;/strong&gt; at the time of invocation.&lt;/p&gt;&lt;img src="http://decav.com/aggbug.aspx?PostID=16222" width="1" height="1"&gt;</description><category domain="http://decav.com/blogs/andre/archive/tags/.NET_2F00_C_2300_+Development/default.aspx">.NET/C# Development</category><category domain="http://decav.com/blogs/andre/archive/tags/On+Software/default.aspx">On Software</category></item><item><title>Life With ActionScript and AIR: The Command Pattern Is Your Best Friend</title><link>http://decav.com/blogs/andre/archive/2007/11/16/life-with-actionscript-and-air-the-command-pattern-is-your-best-friend.aspx</link><pubDate>Fri, 16 Nov 2007 16:02:00 GMT</pubDate><guid isPermaLink="false">1a6c50a2-1cc5-440d-a734-51a167eba982:16189</guid><dc:creator>mrdecav</dc:creator><slash:comments>0</slash:comments><description>&lt;p&gt;I&amp;#39;ve recently started a project (top secret!) using the new &lt;strong&gt;Adobe Integrated Runtime (AIR), Flex and ActionScript 3.0.&lt;/strong&gt;&amp;nbsp; Coming from a .NET and WPF world. this has been a step in a very different direction.&amp;nbsp; There are a lot of things I don&amp;#39;t really love about ActionScript, however it does do its job, and the Adobe AIR deployment strategy (along with its SQLLite database) is pretty damn good.&lt;/p&gt;
&lt;p&gt;One of the first things any developer will realize when trying to build a real&amp;nbsp;&lt;strong&gt;Rich Internet&amp;nbsp;Application (RIA)&lt;/strong&gt;&amp;nbsp;in ActionScript is the lack of threading.&amp;nbsp; This makes doing background tasks very difficult.&amp;nbsp; ActionScript, and its class library, works largely with callback methods (either from calling &lt;strong&gt;setInterval, &lt;/strong&gt;using a &lt;strong&gt;Timer&lt;/strong&gt; class, calling a &lt;strong&gt;SQLConnection&lt;/strong&gt; or using the &lt;strong&gt;HTTPService&lt;/strong&gt; or other class to make a data call).&amp;nbsp; From what I can tell, this works much like the Windows message loop, inurrupting synchronous code on your UI thread to process the callback.&lt;/p&gt;
&lt;p&gt;While this is great for simple actions (say, a UI that calls a &lt;strong&gt;web service&lt;/strong&gt; or &lt;strong&gt;REST service&lt;/strong&gt;), building a background process (such as a SQL Server synchronization engine) can get complicated.&amp;nbsp; Due to the number of callbacks you&amp;#39;ll receive each time you make a request (to &lt;strong&gt;SQLConnection&lt;/strong&gt; or &lt;strong&gt;HTTPService&lt;/strong&gt;), there is a great amount of&amp;nbsp;complexity in writing simple procedual background processes (that don&amp;#39;t freeze up the UI).&lt;/p&gt;
&lt;p&gt;To better handle this situation, and ensure that your discrete functions run in the proper order (for example, Authenticate -&amp;gt; Get Data), a &lt;strong&gt;command pattern&lt;/strong&gt; in ActionScript will become your best friend.&amp;nbsp; You can string together multiple callbacks, and ensure that the code for these operations stay in one logical class.&amp;nbsp; Furthermore, by using a queue, you can order your commands such that they run synchronously.&amp;nbsp; This provides much more flexibility than the traditional scripting approach in ActionScript.&lt;/p&gt;
&lt;p&gt;Unfortunately, I cannot currently provide code samples, as I do not want to compromise the intellectual property of my project, however, I hope that this will help you get an idea of how to best manage your code and synchronous operations in .NET.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Side Note:&lt;/strong&gt; If you&amp;#39;re using &lt;strong&gt;WCF&lt;/strong&gt; I suggest you use the &lt;strong&gt;Basic HTTP Binding&lt;/strong&gt; with Flex, as FlexBuilder gets confused with .NET Web Services&lt;/p&gt;&lt;img src="http://decav.com/aggbug.aspx?PostID=16189" width="1" height="1"&gt;</description><category domain="http://decav.com/blogs/andre/archive/tags/On+Software/default.aspx">On Software</category><category domain="http://decav.com/blogs/andre/archive/tags/ActionScript/default.aspx">ActionScript</category><category domain="http://decav.com/blogs/andre/archive/tags/Adobe+AIR/default.aspx">Adobe AIR</category><category domain="http://decav.com/blogs/andre/archive/tags/Flex/default.aspx">Flex</category></item><item><title>WCF: ConfigurationErrorsException When Defining Behavior Extensions</title><link>http://decav.com/blogs/andre/archive/2007/11/06/wcf-configurationerrorsexception-when-defining-behavior-extensions.aspx</link><pubDate>Tue, 06 Nov 2007 18:16:00 GMT</pubDate><guid isPermaLink="false">1a6c50a2-1cc5-440d-a734-51a167eba982:13546</guid><dc:creator>mrdecav</dc:creator><slash:comments>0</slash:comments><description>&lt;p&gt;Just a quick note:&amp;nbsp; There is a bug that looks like it won&amp;#39;t be fixed for a while in the configuration of the &lt;strong&gt;&amp;lt;behaviorExtensions&amp;gt;&lt;/strong&gt; section of the &lt;strong&gt;systm.serviceModel WCF&lt;/strong&gt; configuration.&amp;nbsp; You may get&amp;nbsp;the &lt;strong&gt;ConfigurationErrorsException&lt;/strong&gt; when adding a new type of behavior (see below):&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;System.Configuration.ConfigurationErrorsException: An error occurred creating the configuration section handler for system.serviceModel/behaviors: Extension element &amp;#39;myService&amp;#39; cannot be added to this element. Verify that the extension is registered in the extension collection at system.serviceModel/extensions/behaviorExtensions.Parameter name: element (...\Service.exe.config line 43) ---&amp;gt; System.ArgumentException: Extension element &amp;#39;wsdlNotice&amp;#39; cannot be added to this element. Verify that the extension is registered in the extension collection at &lt;strong&gt;system.serviceModel/extensions/behaviorExtensions&lt;/strong&gt;.&lt;/p&gt;&lt;/blockquote&gt;
&lt;p&gt;This is a known bug, but was not accepted by Microsoft as a bug.&amp;nbsp; See bug Microsoft feedback:&lt;br /&gt;&lt;a href="https://connect.microsoft.com/wcf/feedback/ViewFeedback.aspx?FeedbackID=216431"&gt;https://connect.microsoft.com/wcf/feedback/ViewFeedback.aspx?FeedbackID=216431&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;To fix this issue, you will need to use the fully qualified type name, as shown in the sample below:&amp;nbsp;&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;&amp;lt;add name=&amp;quot;myService&amp;quot; &lt;br /&gt;type=&amp;quot;Decav.FreeCode.MyServiceBehaviorElement, &lt;br /&gt;Decav.FreeCode, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null&amp;quot;&lt;br /&gt;/&amp;gt;&lt;/p&gt;&lt;/blockquote&gt;&lt;img src="http://decav.com/aggbug.aspx?PostID=13546" width="1" height="1"&gt;</description><category domain="http://decav.com/blogs/andre/archive/tags/.NET_2F00_C_2300_+Development/default.aspx">.NET/C# Development</category><category domain="http://decav.com/blogs/andre/archive/tags/On+Software/default.aspx">On Software</category><category domain="http://decav.com/blogs/andre/archive/tags/Windows+Communication+Foundation/default.aspx">Windows Communication Foundation</category></item><item><title>WCF: Throwing Exceptions With WebHttpBinding</title><link>http://decav.com/blogs/andre/archive/2007/11/03/wcf-throwing-exceptions-with-webhttpbinding.aspx</link><pubDate>Sat, 03 Nov 2007 22:42:00 GMT</pubDate><guid isPermaLink="false">1a6c50a2-1cc5-440d-a734-51a167eba982:13057</guid><dc:creator>mrdecav</dc:creator><slash:comments>2</slash:comments><description>&lt;p&gt;One of the very cool new features in &lt;strong&gt;Windows Communication Foundation&lt;/strong&gt; is the ability to create REST or POX services.&amp;nbsp; Unfortunately, you will quickly find that &lt;strong&gt;WebHttpBinding&lt;/strong&gt; and &lt;strong&gt;WebHttpBehavior&lt;/strong&gt; (both the binding and behavior that are used to pull off the REST operations in WCF) will swallow your exceptions, and worse, leave you with a very generic error message, like the following:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p class="heading1"&gt;Request Error&lt;br /&gt;The server encountered an error processing the request. See server logs for more details.&lt;/p&gt;&lt;/blockquote&gt;
&lt;p class="heading1"&gt;This is no good when your client is expecting back XML or a fault code!&amp;nbsp; How to get around this?&amp;nbsp; Implement your own WebHttpBehavior and add a custom error handler.&amp;nbsp; This will let you return a message of your choice.&amp;nbsp; The code below will return a standard SOAP-like fault message.&amp;nbsp; Note that you can use &lt;strong&gt;Message.CreateMessage&lt;/strong&gt; and &lt;strong&gt;XmlDocument&lt;/strong&gt; to create a differently formatted message if you want.&lt;/p&gt;
&lt;p class="heading1"&gt;Also, this example wraps ALL exceptions, regardless of their type.&amp;nbsp; The standard WCF way of protecting sensitive server-side information (like stack traces) is to use &lt;strong&gt;FaultException&lt;/strong&gt;, or &lt;strong&gt;FaultException&amp;lt;T&amp;gt;&lt;/strong&gt; in your code, and only show the message if the exception is of one of those types.&amp;nbsp; I would suggest adding this type filter if you care about your server-side intellecual property rights.&lt;/p&gt;
&lt;p class="heading1"&gt;&lt;strong&gt;FaultingWebHttpBehavior:&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;
&lt;div class="csharpcode"&gt;&lt;pre&gt;&lt;span class="lnum"&gt;   1:  &lt;/span&gt;&lt;span class="kwrd"&gt;using&lt;/span&gt; System;&lt;/pre&gt;&lt;pre&gt;&lt;span class="lnum"&gt;   2:  &lt;/span&gt;&lt;span class="kwrd"&gt;using&lt;/span&gt; System.Collections.Generic;&lt;/pre&gt;&lt;pre&gt;&lt;span class="lnum"&gt;   3:  &lt;/span&gt;&lt;span class="kwrd"&gt;using&lt;/span&gt; System.Linq;&lt;/pre&gt;&lt;pre&gt;&lt;span class="lnum"&gt;   4:  &lt;/span&gt;&lt;span class="kwrd"&gt;using&lt;/span&gt; System.Text;&lt;/pre&gt;&lt;pre&gt;&lt;span class="lnum"&gt;   5:  &lt;/span&gt;&lt;span class="kwrd"&gt;using&lt;/span&gt; System.ServiceModel.Description;&lt;/pre&gt;&lt;pre&gt;&lt;span class="lnum"&gt;   6:  &lt;/span&gt;&lt;span class="kwrd"&gt;using&lt;/span&gt; System.ServiceModel.Dispatcher;&lt;/pre&gt;&lt;pre&gt;&lt;span class="lnum"&gt;   7:  &lt;/span&gt;&lt;span class="kwrd"&gt;using&lt;/span&gt; System.ServiceModel.Channels;&lt;/pre&gt;&lt;pre&gt;&lt;span class="lnum"&gt;   8:  &lt;/span&gt;&lt;span class="kwrd"&gt;using&lt;/span&gt; System.Xml;&lt;/pre&gt;&lt;pre&gt;&lt;span class="lnum"&gt;   9:  &lt;/span&gt;&lt;span class="kwrd"&gt;using&lt;/span&gt; System.ServiceModel;&lt;/pre&gt;&lt;pre&gt;&lt;span class="lnum"&gt;  10:  &lt;/span&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre&gt;&lt;span class="lnum"&gt;  11:  &lt;/span&gt;&lt;span class="kwrd"&gt;namespace&lt;/span&gt; Decav.FreeCode.ServiceModel&lt;/pre&gt;&lt;pre&gt;&lt;span class="lnum"&gt;  12:  &lt;/span&gt;{&lt;/pre&gt;&lt;pre&gt;&lt;span class="lnum"&gt;  13:  &lt;/span&gt;    &lt;span class="rem"&gt;/// &amp;lt;summary&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;&lt;span class="lnum"&gt;  14:  &lt;/span&gt;    &lt;span class="rem"&gt;/// A &amp;lt;see cref=&amp;quot;WebHttpBehavior&amp;quot;/&amp;gt; that does not attempt to display friendly error messages when an exception occurs&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;&lt;span class="lnum"&gt;  15:  &lt;/span&gt;    &lt;span class="rem"&gt;/// locating or invoking a service.&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;&lt;span class="lnum"&gt;  16:  &lt;/span&gt;    &lt;span class="rem"&gt;/// &amp;lt;/summary&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;&lt;span class="lnum"&gt;  17:  &lt;/span&gt;    &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;class&lt;/span&gt; FaultingWebHttpBehavior : WebHttpBehavior&lt;/pre&gt;&lt;pre&gt;&lt;span class="lnum"&gt;  18:  &lt;/span&gt;    {&lt;/pre&gt;&lt;pre&gt;&lt;span class="lnum"&gt;  19:  &lt;/span&gt;        &lt;span class="kwrd"&gt;protected&lt;/span&gt; &lt;span class="kwrd"&gt;override&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; AddServerErrorHandlers(ServiceEndpoint endpoint, EndpointDispatcher endpointDispatcher)&lt;/pre&gt;&lt;pre&gt;&lt;span class="lnum"&gt;  20:  &lt;/span&gt;        {&lt;/pre&gt;&lt;pre&gt;&lt;span class="lnum"&gt;  21:  &lt;/span&gt;            endpointDispatcher.ChannelDispatcher.ErrorHandlers.Clear();&lt;/pre&gt;&lt;pre&gt;&lt;span class="lnum"&gt;  22:  &lt;/span&gt;            endpointDispatcher.ChannelDispatcher.ErrorHandlers.Add(&lt;span class="kwrd"&gt;new&lt;/span&gt; ErrorHandler());&lt;/pre&gt;&lt;pre&gt;&lt;span class="lnum"&gt;  23:  &lt;/span&gt;        }&lt;/pre&gt;&lt;pre&gt;&lt;span class="lnum"&gt;  24:  &lt;/span&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre&gt;&lt;span class="lnum"&gt;  25:  &lt;/span&gt;        &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;class&lt;/span&gt; ErrorHandler : IErrorHandler&lt;/pre&gt;&lt;pre&gt;&lt;span class="lnum"&gt;  26:  &lt;/span&gt;        {&lt;/pre&gt;&lt;pre&gt;&lt;span class="lnum"&gt;  27:  &lt;/span&gt;            &lt;span class="preproc"&gt;#region&lt;/span&gt; IErrorHandler Members&lt;/pre&gt;&lt;pre&gt;&lt;span class="lnum"&gt;  28:  &lt;/span&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre&gt;&lt;span class="lnum"&gt;  29:  &lt;/span&gt;            &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;bool&lt;/span&gt; HandleError(Exception error)&lt;/pre&gt;&lt;pre&gt;&lt;span class="lnum"&gt;  30:  &lt;/span&gt;            {&lt;/pre&gt;&lt;pre&gt;&lt;span class="lnum"&gt;  31:  &lt;/span&gt;                &lt;span class="kwrd"&gt;return&lt;/span&gt; &lt;span class="kwrd"&gt;true&lt;/span&gt;;&lt;/pre&gt;&lt;pre&gt;&lt;span class="lnum"&gt;  32:  &lt;/span&gt;            }&lt;/pre&gt;&lt;pre&gt;&lt;span class="lnum"&gt;  33:  &lt;/span&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre&gt;&lt;span class="lnum"&gt;  34:  &lt;/span&gt;            &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; ProvideFault(Exception error, MessageVersion version, &lt;span class="kwrd"&gt;ref&lt;/span&gt; Message fault)&lt;/pre&gt;&lt;pre&gt;&lt;span class="lnum"&gt;  35:  &lt;/span&gt;            {&lt;/pre&gt;&lt;pre&gt;&lt;span class="lnum"&gt;  36:  &lt;/span&gt;                FaultCode faultCode = FaultCode.CreateSenderFaultCode(error.GetType().Name, &lt;span class="str"&gt;&amp;quot;http://tempuri.org/net/exceptions&amp;quot;&lt;/span&gt;);&lt;/pre&gt;&lt;pre&gt;&lt;span class="lnum"&gt;  37:  &lt;/span&gt;                fault = Message.CreateMessage(version, faultCode, error.Message, &lt;span class="kwrd"&gt;null&lt;/span&gt;);&lt;/pre&gt;&lt;pre&gt;&lt;span class="lnum"&gt;  38:  &lt;/span&gt;            }&lt;/pre&gt;&lt;pre&gt;&lt;span class="lnum"&gt;  39:  &lt;/span&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre&gt;&lt;span class="lnum"&gt;  40:  &lt;/span&gt;            &lt;span class="preproc"&gt;#endregion&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;&lt;span class="lnum"&gt;  41:  &lt;/span&gt;        }&lt;/pre&gt;&lt;pre&gt;&lt;span class="lnum"&gt;  42:  &lt;/span&gt;    }&lt;/pre&gt;&lt;pre&gt;&lt;span class="lnum"&gt;  43:  &lt;/span&gt;}&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;&lt;strong&gt;FaultingWebHttpBehaviorElement (this is the configuration element used in the app.config:&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;
&lt;div class="csharpcode"&gt;&lt;pre&gt;&lt;span class="lnum"&gt;   1:  &lt;/span&gt;&lt;span class="kwrd"&gt;using&lt;/span&gt; System;&lt;/pre&gt;&lt;pre&gt;&lt;span class="lnum"&gt;   2:  &lt;/span&gt;&lt;span class="kwrd"&gt;using&lt;/span&gt; System.Collections.Generic;&lt;/pre&gt;&lt;pre&gt;&lt;span class="lnum"&gt;   3:  &lt;/span&gt;&lt;span class="kwrd"&gt;using&lt;/span&gt; System.Linq;&lt;/pre&gt;&lt;pre&gt;&lt;span class="lnum"&gt;   4:  &lt;/span&gt;&lt;span class="kwrd"&gt;using&lt;/span&gt; System.Text;&lt;/pre&gt;&lt;pre&gt;&lt;span class="lnum"&gt;   5:  &lt;/span&gt;&lt;span class="kwrd"&gt;using&lt;/span&gt; System.ServiceModel.Configuration;&lt;/pre&gt;&lt;pre&gt;&lt;span class="lnum"&gt;   6:  &lt;/span&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre&gt;&lt;span class="lnum"&gt;   7:  &lt;/span&gt;&lt;span class="kwrd"&gt;namespace&lt;/span&gt; Decav.FreeCode.ServiceModel&lt;/pre&gt;&lt;pre&gt;&lt;span class="lnum"&gt;   8:  &lt;/span&gt;{&lt;/pre&gt;&lt;pre&gt;&lt;span class="lnum"&gt;   9:  &lt;/span&gt;    &lt;span class="rem"&gt;/// &amp;lt;summary&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;&lt;span class="lnum"&gt;  10:  &lt;/span&gt;    &lt;span class="rem"&gt;/// The configuration element for a &amp;lt;see cref=&amp;quot;FaultingWebHttpBehavior&amp;quot;/&amp;gt;.&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;&lt;span class="lnum"&gt;  11:  &lt;/span&gt;    &lt;span class="rem"&gt;/// &amp;lt;/summary&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;&lt;span class="lnum"&gt;  12:  &lt;/span&gt;    &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;class&lt;/span&gt; FaultingWebHttpBehaviorElement : BehaviorExtensionElement&lt;/pre&gt;&lt;pre&gt;&lt;span class="lnum"&gt;  13:  &lt;/span&gt;    {&lt;/pre&gt;&lt;pre&gt;&lt;span class="lnum"&gt;  14:  &lt;/span&gt;        &lt;span class="rem"&gt;/// &amp;lt;summary&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;&lt;span class="lnum"&gt;  15:  &lt;/span&gt;        &lt;span class="rem"&gt;/// Gets the type of behavior.&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;&lt;span class="lnum"&gt;  16:  &lt;/span&gt;        &lt;span class="rem"&gt;/// &amp;lt;/summary&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;&lt;span class="lnum"&gt;  17:  &lt;/span&gt;        &lt;span class="rem"&gt;/// &amp;lt;value&amp;gt;&amp;lt;/value&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;&lt;span class="lnum"&gt;  18:  &lt;/span&gt;        &lt;span class="rem"&gt;/// &amp;lt;returns&amp;gt;A &amp;lt;see cref=&amp;quot;T:System.Type&amp;quot;/&amp;gt;.&amp;lt;/returns&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;&lt;span class="lnum"&gt;  19:  &lt;/span&gt;        &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;override&lt;/span&gt; Type BehaviorType&lt;/pre&gt;&lt;pre&gt;&lt;span class="lnum"&gt;  20:  &lt;/span&gt;        {&lt;/pre&gt;&lt;pre&gt;&lt;span class="lnum"&gt;  21:  &lt;/span&gt;            get { &lt;span class="kwrd"&gt;return&lt;/span&gt; &lt;span class="kwrd"&gt;typeof&lt;/span&gt;(FaultingWebHttpBehavior); }&lt;/pre&gt;&lt;pre&gt;&lt;span class="lnum"&gt;  22:  &lt;/span&gt;        }&lt;/pre&gt;&lt;pre&gt;&lt;span class="lnum"&gt;  23:  &lt;/span&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre&gt;&lt;span class="lnum"&gt;  24:  &lt;/span&gt;        &lt;span class="rem"&gt;/// &amp;lt;summary&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;&lt;span class="lnum"&gt;  25:  &lt;/span&gt;        &lt;span class="rem"&gt;/// Creates a behavior extension based on the current configuration settings.&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;&lt;span class="lnum"&gt;  26:  &lt;/span&gt;        &lt;span class="rem"&gt;/// &amp;lt;/summary&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;&lt;span class="lnum"&gt;  27:  &lt;/span&gt;        &lt;span class="rem"&gt;/// &amp;lt;returns&amp;gt;The behavior extension.&amp;lt;/returns&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;&lt;span class="lnum"&gt;  28:  &lt;/span&gt;        &lt;span class="kwrd"&gt;protected&lt;/span&gt; &lt;span class="kwrd"&gt;override&lt;/span&gt; &lt;span class="kwrd"&gt;object&lt;/span&gt; CreateBehavior()&lt;/pre&gt;&lt;pre&gt;&lt;span class="lnum"&gt;  29:  &lt;/span&gt;        {&lt;/pre&gt;&lt;pre&gt;&lt;span class="lnum"&gt;  30:  &lt;/span&gt;            &lt;span class="kwrd"&gt;return&lt;/span&gt; &lt;span class="kwrd"&gt;new&lt;/span&gt; FaultingWebHttpBehavior();&lt;/pre&gt;&lt;pre&gt;&lt;span class="lnum"&gt;  31:  &lt;/span&gt;        }&lt;/pre&gt;&lt;pre&gt;&lt;span class="lnum"&gt;  32:  &lt;/span&gt;    }&lt;/pre&gt;&lt;pre&gt;&lt;span class="lnum"&gt;  33:  &lt;/span&gt;}&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;&lt;strong&gt;App.config:&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;
&lt;div class="csharpcode"&gt;&lt;pre&gt;&lt;span class="lnum"&gt;   1:  &lt;/span&gt;&lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;configuration&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;&lt;span class="lnum"&gt;   2:  &lt;/span&gt;  &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;system.serviceModel&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;&lt;span class="lnum"&gt;   3:  &lt;/span&gt;    &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;services&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;&lt;span class="lnum"&gt;   4:  &lt;/span&gt;      &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;service&lt;/span&gt; &lt;span class="attr"&gt;name&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;Decav.FreeCode.SomeService&amp;quot;&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;&lt;span class="lnum"&gt;   5:  &lt;/span&gt;        &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;endpoint&lt;/span&gt; &lt;span class="attr"&gt;address&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;&amp;quot;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;&lt;span class="lnum"&gt;   6:  &lt;/span&gt;                  &lt;span class="attr"&gt;behaviorConfiguration&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;WebBehavior&amp;quot;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;&lt;span class="lnum"&gt;   7:  &lt;/span&gt;                  &lt;span class="attr"&gt;binding&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;webHttpBinding&amp;quot;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;&lt;span class="lnum"&gt;   8:  &lt;/span&gt;                  &lt;span class="attr"&gt;contract&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;Decav.FreeCode.SomeService&amp;quot;&lt;/span&gt;&lt;span class="kwrd"&gt;/&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;&lt;span class="lnum"&gt;   9:  &lt;/span&gt;        &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;host&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;&lt;span class="lnum"&gt;  10:  &lt;/span&gt;          &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;baseAddresses&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;&lt;span class="lnum"&gt;  11:  &lt;/span&gt;            &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;add&lt;/span&gt; &lt;span class="attr"&gt;baseAddress&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;http://localhost/Services/SomeService&amp;quot;&lt;/span&gt;&lt;span class="kwrd"&gt;/&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;&lt;span class="lnum"&gt;  12:  &lt;/span&gt;          &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;baseAddresses&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;&lt;span class="lnum"&gt;  13:  &lt;/span&gt;        &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;host&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;&lt;span class="lnum"&gt;  14:  &lt;/span&gt;      &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;service&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;&lt;span class="lnum"&gt;  15:  &lt;/span&gt;    &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;services&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;&lt;span class="lnum"&gt;  16:  &lt;/span&gt;    &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;behaviors&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;&lt;span class="lnum"&gt;  17:  &lt;/span&gt;      &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;endpointBehaviors&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;&lt;span class="lnum"&gt;  18:  &lt;/span&gt;        &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;behavior&lt;/span&gt; &lt;span class="attr"&gt;name&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;WebBehavior&amp;quot;&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;&lt;span class="lnum"&gt;  19:  &lt;/span&gt;          &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;faultingWebHttp&lt;/span&gt;&lt;span class="kwrd"&gt;/&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;&lt;span class="lnum"&gt;  20:  &lt;/span&gt;        &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;behavior&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;&lt;span class="lnum"&gt;  21:  &lt;/span&gt;      &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;endpointBehaviors&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;&lt;span class="lnum"&gt;  22:  &lt;/span&gt;    &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;behaviors&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;&lt;span class="lnum"&gt;  23:  &lt;/span&gt;    &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;extensions&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;&lt;span class="lnum"&gt;  24:  &lt;/span&gt;      &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;behaviorExtensions&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;&lt;span class="lnum"&gt;  25:  &lt;/span&gt;        &lt;span class="rem"&gt;&amp;lt;!-- NOTE:  Fully qualified name required, see: https://connect.microsoft.com/wcf/feedback/ViewFeedback.aspx?FeedbackID=216431 --&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;&lt;span class="lnum"&gt;  26:  &lt;/span&gt;        &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;add&lt;/span&gt; &lt;span class="attr"&gt;name&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;faultingWebHttp&amp;quot;&lt;/span&gt; &lt;span class="attr"&gt;type&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;Decav.FreeCode.ServiceModel.FaultingWebHttpBehaviorElement, Decav.FreeCode, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null&amp;quot;&lt;/span&gt;&lt;span class="kwrd"&gt;/&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;&lt;span class="lnum"&gt;  27:  &lt;/span&gt;      &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;behaviorExtensions&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;&lt;span class="lnum"&gt;  28:  &lt;/span&gt;    &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;extensions&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;&lt;span class="lnum"&gt;  29:  &lt;/span&gt;  &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;system.serviceModel&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;&lt;span class="lnum"&gt;  30:  &lt;/span&gt;&lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;configuration&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;img src="http://decav.com/aggbug.aspx?PostID=13057" width="1" height="1"&gt;</description><category domain="http://decav.com/blogs/andre/archive/tags/.NET_2F00_C_2300_+Development/default.aspx">.NET/C# Development</category><category domain="http://decav.com/blogs/andre/archive/tags/On+Software/default.aspx">On Software</category></item><item><title>Strong Typed Functional Programming In C#</title><link>http://decav.com/blogs/andre/archive/2007/09/17/strong-typed-functional-programming-in-c.aspx</link><pubDate>Mon, 17 Sep 2007 03:34:00 GMT</pubDate><guid isPermaLink="false">1a6c50a2-1cc5-440d-a734-51a167eba982:9231</guid><dc:creator>mrdecav</dc:creator><slash:comments>1</slash:comments><description>&lt;p&gt;&lt;a class="" href="http://decav.com/files/folders/public/entry9232.aspx"&gt;&lt;strong&gt;Functional Programming in C# Sample&amp;nbsp;Solution (.NET 3.5)&lt;/strong&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;I had an interesting discussion the other day with a collegue at Lab49 about the uses for &lt;strong&gt;functional programming&lt;/strong&gt; over &lt;strong&gt;object-oriented programming&lt;/strong&gt;.&amp;nbsp; Although I traditionally have been very OO-focused, some of the points he made are very relevant and things I have found myself doing in the past.&amp;nbsp; Although I have dabbled in some functional languages (PowerShell being the most prominent recently), I do not consider myself a functional programmer.&lt;/p&gt;
&lt;p&gt;Typically, functional programming is loosely typed and uses dynamic languages, however functional programmers using an OO language (such as C#) will use hashtables or data sets to store loosely typed data.&amp;nbsp; The benefit of the loosely typed, &amp;quot;flat&amp;quot; object model (single object for all your data properties) is that you don&amp;#39;t wind up creating excess code (such as properties that will never be filled in) for doing something very simple (like binding to a grid).&amp;nbsp; Furthemore, in an environment where new types are created daily, some of which will wreak havoc on your structured object model (which ultimately may never be used when you&amp;#39;re just displaying data), the OO concepts can fall apart.&amp;nbsp; Take into account distributed computing and thread safety, and you have a very comelling reason to have a set of small flimsy objects that don&amp;#39;t care what data they hold.&lt;/p&gt;
&lt;p&gt;Running with this concept (which I still have yet to actually accept), I started to realize this is largely the direction of the C# language.&amp;nbsp; &lt;strong&gt;Extension methods&lt;/strong&gt;, the &lt;strong&gt;var keyword&lt;/strong&gt;, &lt;strong&gt;LINQ&lt;/strong&gt;, and other recent developments in &lt;strong&gt;.NET 3.5&lt;/strong&gt; are all attempts to make a ridged OO language more dynamic.&lt;/p&gt;
&lt;p&gt;Not wanting to lose my type-safety, I tried to go off an build a functional-style app using C#, and found an interesting way of using &lt;strong&gt;extension methods&lt;/strong&gt; to apply &lt;strong&gt;&amp;quot;schemas&amp;quot;&lt;/strong&gt; to loose typed hashtable data objects.&amp;nbsp; While this is not perfect, and &lt;strong&gt;I certainly would never use this in production code&lt;/strong&gt;, it provides an interesting way to apply composite interfaces on top of an object without ever modifying the object itself.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;The use of &lt;strong&gt;extension methods&lt;/strong&gt; is simple.&amp;nbsp; By creating &lt;strong&gt;Get&lt;em&gt;Property&lt;/em&gt;() &lt;/strong&gt;and &lt;strong&gt;Set&lt;em&gt;Property&lt;/em&gt;()&lt;/strong&gt; methods (where&amp;nbsp;&lt;em&gt;Property&lt;strong&gt;&amp;nbsp;&lt;/strong&gt;&lt;/em&gt;is the name of the property you wish to get set)&lt;strong&gt;&amp;nbsp;&lt;/strong&gt;as extension methods in a seperate namespace, you can easily use the namespace as an interface that you place &amp;quot;over&amp;quot; the data object.&amp;nbsp; You can write your functional method, import a few namespaces, and all of a sudden have a strong-typed interface for your functional method to access, cool stuff.&lt;/p&gt;
&lt;p&gt;While I don&amp;#39;t particularly condone this method of development (for if no other reason, other developers will have to wrestle with the code becuase its &amp;quot;not standard&amp;quot;), its worth looking at.&amp;nbsp; &lt;/p&gt;
&lt;p&gt;&lt;a class="" href="http://decav.com/files/folders/public/entry9232.aspx"&gt;&lt;strong&gt;Functional Programming in C# Sample&amp;nbsp;Solution (.NET 3.5)&lt;/strong&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://decav.com/aggbug.aspx?PostID=9231" width="1" height="1"&gt;</description><category domain="http://decav.com/blogs/andre/archive/tags/.NET_2F00_C_2300_+Development/default.aspx">.NET/C# Development</category><category domain="http://decav.com/blogs/andre/archive/tags/On+Software/default.aspx">On Software</category></item><item><title>Live Updating Line Graph in WPF</title><link>http://decav.com/blogs/andre/archive/2007/08/25/live-updating-line-graph-in-wpf.aspx</link><pubDate>Sat, 25 Aug 2007 18:14:00 GMT</pubDate><guid isPermaLink="false">1a6c50a2-1cc5-440d-a734-51a167eba982:7806</guid><dc:creator>mrdecav</dc:creator><slash:comments>11</slash:comments><description>&lt;img style="FLOAT:right;" alt="WPF Live Line Graph" src="http://filedrop.decav.com/Samples/LineGraph/WPFGraphScreenshot.jpg" /&gt; 
&lt;p&gt;&lt;a class="" href="http://filedrop.decav.com/Samples/LineGraph/ClickOnce/Run.application"&gt;See a ClickOnce (.NET 3.5) Sample Here&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;a class="" href="http://filedrop.decav.com/Samples/LineGraph/Decav_WPF_LineGraphSample.zip"&gt;Download the Source Code (VS 2008 Beta 2) Here&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;A&amp;nbsp;live, updating graph in &lt;strong&gt;Windows Presentation Foundation&lt;/strong&gt; and .NET 3.5&amp;nbsp;is a natural use of the new framework, and is something that &lt;strong&gt;WPF&lt;/strong&gt; is well suited to do.&amp;nbsp; You can make great visually appealing animated components, and a graph is just one example.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;In this example, I have built an attractive, glassy (Vista style)&amp;nbsp; control that presents an array of points ticking accross a graph in real time.&amp;nbsp; The goal was to use this with a &lt;strong&gt;market simulator&lt;/strong&gt; so that you could see the data that the simulation was spitting out.&amp;nbsp; The graph uses the ticks as its concept of &amp;quot;time&amp;quot; in the market, and can readjust its speed based on the speed of the simulator.&amp;nbsp; Cool stuff.&lt;/p&gt;
&lt;p&gt;The graph always ticks from the right-most side to the left-most side, with the right-most side being &amp;quot;now&amp;quot; in the market.&amp;nbsp; This is not a simple task, because with the market speed consistently changing, you need to constantly re-adjust your animation speed to ensure that the right most side is always where the next point appears.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Key Points&lt;/strong&gt;&amp;nbsp;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;div&gt;The graph &amp;quot;glows&amp;quot; in intensity based on how far off the &lt;strong&gt;median value you are&amp;nbsp;(not zero)&lt;/strong&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;A moving average is used to determine how fast the graph is currently moving, and this is a good example of readjusting animation speed to outside variables&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;The control &lt;strong&gt;resizes dynamically&lt;/strong&gt;, the &lt;strong&gt;Grid&lt;/strong&gt; was used to allow most of the resizing, with some code to &lt;strong&gt;remove UI elements that are &amp;quot;in the way&amp;quot;&lt;/strong&gt; when the graph gets really small&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;&lt;strong&gt;ControlTemplate&lt;/strong&gt; were used to style buttons and other elements used in making the graph appealing&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;&lt;strong&gt;Extension properties&lt;/strong&gt; were used to extend Button with additional properties that could be used to find graph glow intensities.&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;The graph duration (time from start to end of the view area) can be changed by &lt;strong&gt;using the slider at the bottom of the application&lt;/strong&gt;&lt;/div&gt;&lt;/li&gt;&lt;/ul&gt;
&lt;p&gt;&lt;strong&gt;&lt;/strong&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Creating Your Own Data Source&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Care to use this in your project?&amp;nbsp; Making the graph use your own data source is simple.&amp;nbsp; Derrive from &lt;strong&gt;TickerAdapter&lt;/strong&gt; class (if you want to see an example look at the &lt;strong&gt;RandomTickerAdapter&lt;/strong&gt; that is supplied in the demo).&amp;nbsp; Add new securities to the collection by calling &lt;strong&gt;TickerAdapter.AddSecurity&lt;/strong&gt;, and add new ticks by calling &lt;strong&gt;TickerAdapter.NotifyNewTick&lt;/strong&gt;.&lt;/p&gt;
&lt;p&gt;That&amp;#39;s it!&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Known Issues&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;This control was originally made for a demo, not production use.&amp;nbsp; Although it is near production ready, some issues exist.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;div&gt;The &lt;strong&gt;MiniTicker.Ticks&lt;/strong&gt; collection is never cleared&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;The &lt;strong&gt;Security.Ticks&lt;/strong&gt; collection is never populated (and not used)&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;There is no way to remove a ticker from the collection of tickers managed by a &lt;strong&gt;TickerAdapter&lt;/strong&gt;.&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;Some performance issues exist when adjusting the time scale.&amp;nbsp; There is no &amp;quot;resolution&amp;quot; of the graph, so if you push the graph to a high duration, all the ticks show, rather than dropping some of the ticks for the scale selected.&amp;nbsp; This is both easy to fix, and not an issue if you&amp;#39;re only showing a time window&lt;/div&gt;&lt;/li&gt;&lt;/ul&gt;
&lt;p&gt;&lt;a class="" href="http://filedrop.decav.com/Samples/LineGraph/ClickOnce/Run.application"&gt;See a ClickOnce (.NET 3.5) Sample Here&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;a class="" href="http://filedrop.decav.com/Samples/LineGraph/Decav_WPF_LineGraphSample.zip"&gt;Download the Source Code (VS 2008 Beta 2) Here&lt;/a&gt;&lt;/p&gt;&lt;img src="http://decav.com/aggbug.aspx?PostID=7806" width="1" height="1"&gt;</description><category domain="http://decav.com/blogs/andre/archive/tags/.NET_2F00_C_2300_+Development/default.aspx">.NET/C# Development</category><category domain="http://decav.com/blogs/andre/archive/tags/On+Software/default.aspx">On Software</category><category domain="http://decav.com/blogs/andre/archive/tags/Windows+Presentation+Foundation/default.aspx">Windows Presentation Foundation</category></item><item><title>Fixing and Disabling UrgeMS.exe (MTV Urge Music Service) (100% CPU or HD on Vista)</title><link>http://decav.com/blogs/andre/archive/2007/08/14/fixing-and-disabling-urgems-exe-mtv-urge-music-service-100-cpu-or-hd-on-vista.aspx</link><pubDate>Tue, 14 Aug 2007 16:53:00 GMT</pubDate><guid isPermaLink="false">1a6c50a2-1cc5-440d-a734-51a167eba982:7245</guid><dc:creator>mrdecav</dc:creator><slash:comments>3</slash:comments><description>&lt;p&gt;This thing is really frustrating me so I finally killed it for good and thought I&amp;#39;d let everyone else know how.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;If you &lt;strong&gt;have Windows Vista and use Windows Media Player&lt;/strong&gt;, and you&amp;#39;re &lt;strong&gt;seeing your hard drive or CPU usage spike and stay at 50% or 100%&lt;/strong&gt;, you may be cursed by UrgeMS.exe.&lt;/p&gt;
&lt;p&gt;This executable is for the Urge Music Store (which I highly reccomend) that runs inside of Windows Media Player.&amp;nbsp; UrgeMS.exe gathers information about songs on your hard drive&amp;nbsp;for the &amp;quot;Auto-mix&amp;quot; features.&amp;nbsp; Why they haven&amp;#39;t made this idle when you&amp;#39;re using the computer (especially when on battery power) is beyond me, but you can force it yourself.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;div&gt;Press &lt;strong&gt;ctrl+shift+esc&lt;/strong&gt; to bring up the &lt;strong&gt;task manager&lt;/strong&gt; if it is not already open.&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;Go to the &lt;strong&gt;Processes&lt;/strong&gt; tab and find &lt;strong&gt;UrgeMS.exe&lt;/strong&gt;, click &lt;strong&gt;End Process&lt;/strong&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;Open the start menu and type &lt;strong&gt;C:\Program Files\MTV Networks\urge&lt;/strong&gt; and hit enter, this will open the Urge folder.&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;Rename &lt;strong&gt;UrgeMS.exe&lt;/strong&gt; to something of your choice (such as &lt;strong&gt;UrgeMS_NoStart.exe&lt;/strong&gt;)&lt;/div&gt;&lt;/li&gt;&lt;/ul&gt;
&lt;p&gt;When Urge starts, it will attempt to start this executable, if it fails, it does so silently, so theres no issue with just renaming it.&lt;/p&gt;
&lt;p&gt;Enjoy!&lt;/p&gt;&lt;img src="http://decav.com/aggbug.aspx?PostID=7245" width="1" height="1"&gt;</description></item><item><title>Apple iPhone: The Keyboard and Browser</title><link>http://decav.com/blogs/andre/archive/2007/07/01/apple-iphone-the-keyboard-and-browser.aspx</link><pubDate>Sun, 01 Jul 2007 01:27:00 GMT</pubDate><guid isPermaLink="false">1a6c50a2-1cc5-440d-a734-51a167eba982:3573</guid><dc:creator>mrdecav</dc:creator><slash:comments>0</slash:comments><description>&lt;p&gt;So I stopped by the &lt;strong&gt;Apple Store&lt;/strong&gt; quickly to see tons of people packed around the huge set of iPhone&amp;#39;s they had laid out on the table.&amp;nbsp; I was really only curious about two things...&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;strong&gt;The Keyboard&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;The first thing I wanted to know about was the keyboard.&amp;nbsp; How well would it really work with its &amp;quot;predictive typing?&amp;quot;&amp;nbsp; Most people hate predictive input, so I was curious to see what Apple did with this &amp;quot;revolutionary&amp;quot; new technology (note Pocket PC started with the onscreen keyboard too).&lt;/p&gt;
&lt;p&gt;Simply put: it sucks.&amp;nbsp; Sure it grabs some misspellings and corrects them for you, but overall, the typing experience is damn near horrible.&amp;nbsp; &amp;quot;Trusting the keyboard&amp;quot; as Apple puts it gets you a 70% accuracy rate at best.&amp;nbsp; Enough to be frustrating.&amp;nbsp; The worst part is, you don&amp;#39;t know if its going to correct your spelling until you finish typing the word.&amp;nbsp; So you type extra letters &amp;quot;trusting&amp;quot; the keyboard, and then end up erasing all of them because the keyboard got confused.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Web Browser&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;I was originally expecting the web browsing experience to require a ton of panning to read an article on the phone.&amp;nbsp; After all, the &amp;quot;whole page&amp;quot; view just didn&amp;#39;t sound like it would work to me.&amp;nbsp; Luckily, Apple was very smart here and they find the &amp;quot;article&amp;quot; section of the page (I&amp;#39;m guessing any big block of text, but I&amp;#39;m not quite sure what the browser determines to be the article) and enlarge &lt;strong&gt;that&lt;/strong&gt; text, leaving the page around it at its original size (to be zoomed in on).&amp;nbsp; This makes for a very friendly browsing experience.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Exchange Support&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;There is a tab&amp;nbsp;for &lt;strong&gt;Microsoft Exchange Server&lt;/strong&gt; in the email setup.&amp;nbsp; I didn&amp;#39;t test this (didn&amp;#39;t want to load all my email onto a store device), and it said it required IMAP.&amp;nbsp; I&amp;#39;m not sure if this means that it uses the OMA HTTP trigger to &amp;quot;push&amp;quot; email or not, but I&amp;#39;m assuming it does.&amp;nbsp; If it indeed does, cool stuff!&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Conclusion&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Overall, I found the iPhone to be a great media device.&amp;nbsp; I love the touch gestures (why did Microsoft never get this right?&amp;nbsp; Oh yeah, they wanted to copy the feel of a PC), and the overall interface.&amp;nbsp; Very intuitive.&amp;nbsp; Its not &amp;quot;revolutionary,&amp;quot; this stuff has been around forever.&amp;nbsp; What it does do, however, is impressive and well put together.&lt;/p&gt;
&lt;p&gt;The biggest problem I see is its not really a business device.&amp;nbsp; It doesn&amp;#39;t store tasks (a big problem for me, I need to write todos down as soon as I get them), cannot accept rapid input, and only syncs email through the web (why is this???).&amp;nbsp; Maybe version 2 will be more promising.&lt;/p&gt;&lt;img src="http://decav.com/aggbug.aspx?PostID=3573" width="1" height="1"&gt;</description></item><item><title>Lenovo: "Chinese Quality" (Abhorrant) Customer Service</title><link>http://decav.com/blogs/andre/archive/2007/06/27/lenovo-quot-chinese-quality-quot-abhorrant-customer-service.aspx</link><pubDate>Wed, 27 Jun 2007 15:07:00 GMT</pubDate><guid isPermaLink="false">1a6c50a2-1cc5-440d-a734-51a167eba982:3364</guid><dc:creator>mrdecav</dc:creator><slash:comments>2</slash:comments><description>&lt;p&gt;A week ago,&amp;nbsp;I tried to purchase an &lt;strong&gt;X61 Tablet PC&lt;/strong&gt; from&amp;nbsp;&lt;strong&gt;Lenovo&lt;/strong&gt; and had &lt;strong&gt;significant issues handling the sales staff&lt;/strong&gt;, estimated ship dates and websites.&amp;nbsp; This is my first experience with Lenovo post-takeover of IBM and I am very disappointed by the level of service I have received.&amp;nbsp; It is clear that an IBM brand has been taken over by a Chinese company that understands little about client communication and support.&lt;/p&gt;
&lt;p&gt;I have cancelled my order and bought the tablet from a reseller that had a few in stock, and who shipped the same day (&lt;a href="http://www.shopblt.com/"&gt;http://www.shopblt.com&lt;/a&gt; which has been very courtious and responsive).&lt;/p&gt;
&lt;p&gt;I have run into the following issues that made for a miserable experience with Lenovo.&amp;nbsp; I hope that thetechnical support does not have the same issues, should I need to call them:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;div&gt;30 minute or more wait times on the phone to talk to a representitive&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;Sales people giving me very different answers (one claiming there are no production snags and it should ship in a week or two, another claiming 4 weeks&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;An estimated ship date of 4 weeks (4/20) after I purchased, without an explaination.&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;An &amp;quot;order status&amp;quot; stating &amp;quot;in process.&amp;quot;&amp;nbsp; When I called to cancel, I was told it was already sent to &amp;quot;configuration&amp;quot;.&amp;nbsp; Does this mean it was going to be shipped earlier rather than later?&amp;nbsp; That may have kept me from cancelling my order.&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;Numerous problems with the website, including:&lt;/div&gt;&lt;/li&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;div&gt;broken links (ex: &amp;quot;contact&amp;quot; on the bottom of the order status form)&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;Session timeouts that erase your shopping cart&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;Broken &amp;quot;chat with a sales representitive&amp;quot; on the sales page&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;TYPOS INCLUDING &amp;quot;SXGA&amp;quot; INSTEAD OF &amp;quot;SXGA+&amp;quot; that no one cares enough to resolve&lt;/div&gt;&lt;/li&gt;&lt;/ol&gt;
&lt;li&gt;
&lt;div&gt;Fake, on-going sales that keep changing names, pretending that the product is &amp;quot;on sale&amp;quot; to lure customers.&lt;/div&gt;&lt;/li&gt;&lt;/ol&gt;
&lt;p&gt;Better communication, reasonable hold times, and a bit more transparency would have gone a long way to improving my experience with Lenovo.&amp;nbsp; I am hoping the product and support are up to the same standards as IBM held it to, but given my experience thusfar, I will not be reccomending direct Lenovo sales to any of my clients or friends.&amp;nbsp; I was sad when IBM sold out to the Chinese, and now that I see what the Chinese have done to IBM customer service firsthand, I&amp;#39;m very disappointed in both IBM and Lenovo for the way this transition was handled.&lt;/p&gt;&lt;img src="http://decav.com/aggbug.aspx?PostID=3364" width="1" height="1"&gt;</description></item><item><title>PostSharp:  A .Net Post Compiler</title><link>http://decav.com/blogs/andre/archive/2007/06/15/postsharp-a-net-post-compiler.aspx</link><pubDate>Fri, 15 Jun 2007 19:38:00 GMT</pubDate><guid isPermaLink="false">1a6c50a2-1cc5-440d-a734-51a167eba982:2649</guid><dc:creator>mrdecav</dc:creator><slash:comments>0</slash:comments><description>&lt;p&gt;For several months now, I&amp;#39;ve been collaborating with &lt;a class="" title="Josh Einstein&amp;#39;s Blog" href="http://www.josheinstein.com/"&gt;Josh Einstein&lt;/a&gt; about writing a post compiler for &lt;strong&gt;.NET&lt;/strong&gt;.&amp;nbsp; Our goal was quite simple:&amp;nbsp; we wanted to supply the ability to generate code, such as:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;div&gt;thorough tracing&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;argument null checks&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;clone implementations&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;dependency properties&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;INotifyPropertyChanged event invocations&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;checking if disposed on each method invocation&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;etc&lt;/div&gt;&lt;/li&gt;&lt;/ul&gt;
&lt;p&gt;The job of creating a post compiler to properly handle all of this is not simple, and is quite time consuming, however we figured the benefit to the community would make it well worth it.&lt;/p&gt;
&lt;p&gt;At the time I did several searches looking for a solution but could not find any implementation that I found adequate.&lt;/p&gt;
&lt;p&gt;Enter &lt;a class="" title="PostSharp Post-Compiler for .NET" href="http://www.postsharp.org/"&gt;PostSharp&lt;/a&gt;, a solution conceived and written by a developer named &lt;a class="" title="Gael Fraiteur (.NET Software Engineer) Blog" href="http://gael.fraiteur.net/"&gt;Gael Fraiteur&lt;/a&gt;.&amp;nbsp; Gael has hit the nail on the head, and has implemented an incredibly well documented and functional .net post compiler.&amp;nbsp; In addition, he goes above and beyond my original expectations, adding attributes that allow for easily intercepting and adding or replacing different types of code.&amp;nbsp; PostSharp not only makes the aforementioned operations easier, it adds a sense of &lt;strong&gt;aspect oriented programming&lt;/strong&gt; to .NET (thats not as painful as &lt;strong&gt;ContextBoundObject&lt;/strong&gt;).&lt;/p&gt;
&lt;p&gt;PostSharp is simple, intuitive, and best of all, comes with a suite of very well commented code samples.&amp;nbsp; Kudos to Gael for beating me to it!&lt;/p&gt;&lt;img src="http://decav.com/aggbug.aspx?PostID=2649" width="1" height="1"&gt;</description><category domain="http://decav.com/blogs/andre/archive/tags/.NET_2F00_C_2300_+Development/default.aspx">.NET/C# Development</category><category domain="http://decav.com/blogs/andre/archive/tags/On+Software/default.aspx">On Software</category></item><item><title>.NET: Sending Email to Japanese Mobile Phones</title><link>http://decav.com/blogs/andre/archive/2007/06/12/net-sending-email-to-japanese-mobile-phones.aspx</link><pubDate>Tue, 12 Jun 2007 19:53:00 GMT</pubDate><guid isPermaLink="false">1a6c50a2-1cc5-440d-a734-51a167eba982:2443</guid><dc:creator>mrdecav</dc:creator><slash:comments>1</slash:comments><description>&lt;p&gt;Following up on my previous post about configuring ASP.NET for Japanese mobile phones, I thought I would write about another irritating aspect of developing for the Japanese mobile market:&amp;nbsp;sending email to the fairly ubiquitous Japanese phone email system.&lt;/p&gt;
&lt;p&gt;Oddly enough, the most advanced Japanese phones on the market are very picky about which &lt;strong&gt;content encoding&lt;/strong&gt; and &lt;strong&gt;content transfer encoding &lt;/strong&gt;they support.&amp;nbsp; Unicode does not seem to be an option (go figure), and it seems to me that the email gateway may be where the software bottleneck is, more than the phone itself.&lt;/p&gt;
&lt;p&gt;Anyway, I started by trying to use the &lt;strong&gt;System.Net.Mail.SmtpClient&lt;/strong&gt;.&amp;nbsp; In our tests, we found that the supported &lt;strong&gt;content-encoding&lt;/strong&gt; was &lt;strong&gt;iso-2022-jp&lt;/strong&gt;.&amp;nbsp; Nothing else.&amp;nbsp; Not &lt;strong&gt;unicode&lt;/strong&gt;, not &lt;strong&gt;shift_js&lt;/strong&gt;, just this somewhat awkward standard.&amp;nbsp; Fine.&amp;nbsp; So we set our &lt;strong&gt;MailMessage.BodyEncoding&lt;/strong&gt; to this format, and found that the Japanese phones still would show jibberish, rather than real Japanese.&amp;nbsp; Sure enough, &lt;strong&gt;SmtpClient&lt;/strong&gt; supports sets the &lt;strong&gt;content-transfer-encoding&lt;/strong&gt; to &lt;strong&gt;quoted-printable&lt;/strong&gt;, something the Japanese phones (or gateways) do not support.&amp;nbsp; After trying &lt;strong&gt;AlternateView&lt;/strong&gt; and other classes in &lt;strong&gt;System.Net.Mail&lt;/strong&gt;, we gave up trying to send using this class.&amp;nbsp; It simply was not possible.&lt;/p&gt;
&lt;p&gt;Unfortunately, we were forced to use &lt;strong&gt;System.Web.Mail.MailClient&lt;/strong&gt; to send our emails.&amp;nbsp; This is a crappy wrapper around CDO, and is deprecated in .NET 2.0.&amp;nbsp; The advantage, however, is that &lt;strong&gt;MailClient&lt;/strong&gt; will send a &lt;strong&gt;MailMessage.BodyEncoding&lt;/strong&gt; as &lt;strong&gt;7bit&lt;/strong&gt;, the required &lt;strong&gt;content-transfer-encoding&lt;/strong&gt; for the Japanese mobile market.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;In brief:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;div&gt;Japanese phones require:&lt;/div&gt;&lt;/li&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;div&gt;&lt;strong&gt;content-encoding&lt;/strong&gt; of &lt;strong&gt;iso-2022-jp&lt;/strong&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;&lt;strong&gt;content-transfer-encoding&lt;/strong&gt; of &lt;strong&gt;7bit&lt;/strong&gt;&lt;/div&gt;&lt;/li&gt;&lt;/ul&gt;
&lt;li&gt;
&lt;div&gt;&lt;strong&gt;System.Net.Mail&lt;/strong&gt; does not send in &lt;strong&gt;7bit&lt;/strong&gt; encoding, unless you use &lt;strong&gt;AlternateView&lt;/strong&gt;.&amp;nbsp; At this point, I could not get mail sent with &lt;strong&gt;AlternateView&lt;/strong&gt; to display properly on the mobile device.&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;&lt;strong&gt;System.Web.Mail&lt;/strong&gt; will send &lt;strong&gt;7bit&lt;/strong&gt;, but has the disadvantage of being depricated&lt;/div&gt;&lt;/li&gt;&lt;/ul&gt;
&lt;p&gt;Hope this helps someone! Best of luck!&lt;/p&gt;&lt;img src="http://decav.com/aggbug.aspx?PostID=2443" width="1" height="1"&gt;</description><category domain="http://decav.com/blogs/andre/archive/tags/Web+2.0/default.aspx">Web 2.0</category><category domain="http://decav.com/blogs/andre/archive/tags/.NET_2F00_C_2300_+Development/default.aspx">.NET/C# Development</category></item><item><title>ASP.NET Mobile for Japanese Phones (DoCoMo/i-mode, SoftBank, KDDI AU)</title><link>http://decav.com/blogs/andre/archive/2007/06/10/asp-net-mobile-for-japanese-phones-docomo-i-mode-softbank-kddi-au.aspx</link><pubDate>Sun, 10 Jun 2007 02:11:00 GMT</pubDate><guid isPermaLink="false">1a6c50a2-1cc5-440d-a734-51a167eba982:2309</guid><dc:creator>mrdecav</dc:creator><slash:comments>0</slash:comments><description>&lt;p&gt;In the Japanese market the mobile web is one of the most important web mediums for companies to target.&amp;nbsp; Nearly every site has a mobile version that works with&amp;nbsp;the major mobile carriers phone technologies.&amp;nbsp; When developing for the Japanese market, it is important to develop a mobile site in addition to a full site, as some users only have phones and not a computer.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;This article will cover how to properly configure ASP.NET Mobile 2.0 to work with the majority of Japanese mobile phones in the market.&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;&lt;a class="" href="http://decav.com/files/folders/2310/download.aspx"&gt;Download KDDI .Browser File Here&lt;/a&gt; &lt;/strong&gt;-- These browsercaps are imperfect (I haven&amp;#39;t reviewed each and every setting), but will ensure that Japanese text renders properly in the browser).&lt;/p&gt;
&lt;p&gt;ASP.NET Mobile provides the ability to change rendering of a web page based on the browser accessing the site.&amp;nbsp; Because of the wide varieties of HTML supported in the Japanese mobile market (&lt;strong&gt;DoCoMo/imode&lt;/strong&gt; perfers &lt;strong&gt;cHTML and XHTML&lt;/strong&gt;&amp;nbsp;whereas &lt;strong&gt;SoftBank&lt;/strong&gt; prefers &lt;strong&gt;HDML&lt;/strong&gt;).&amp;nbsp; In addition, different browsers support different encodings (some use &lt;strong&gt;UTF-8&lt;/strong&gt;, others use &lt;strong&gt;shift_js&lt;/strong&gt;).&lt;/p&gt;
&lt;p&gt;To support all of these, ASP.NET uses &lt;strong&gt;browser caps&lt;/strong&gt;.&amp;nbsp; Most of the browser caps you need to the Japanese market are included in .NET 2.0.&amp;nbsp; Unfortunately, KDDI browsers seem to lack a browser caps file in ASP.NET.&amp;nbsp; To resolve this issue, read on to find how to install a browser caps file into ASP.NET.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Installing a .browser file&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;div&gt;If you have not already, download the &lt;strong&gt;&lt;a class="" href="http://decav.com/files/folders/2310/download.aspx"&gt;KDDI .browser file&lt;/a&gt;&lt;/strong&gt;.&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;Copy the browser file into the &lt;strong&gt;C:\Windows\Microsoft.NET\Framework\v2.0.50727\CONFIG\Browsers&lt;/strong&gt; folder.&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;Open a command prompt and change path to &lt;strong&gt;C:\Windows\Microsoft.NET\Framework\v2.0.50727&lt;/strong&gt;.&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;Run&amp;nbsp;&lt;strong&gt;aspnet_regbrowsers.exe /i&lt;/strong&gt; to recompile the browser files into an assembly and add it to the GAC.&lt;/div&gt;&lt;/li&gt;&lt;/ul&gt;
&lt;p&gt;At this point your ASP.NET sites should be compatible with the majority of Japanese phones on the market.&lt;/p&gt;&lt;img src="http://decav.com/aggbug.aspx?PostID=2309" width="1" height="1"&gt;</description><category domain="http://decav.com/blogs/andre/archive/tags/.NET_2F00_C_2300_+Development/default.aspx">.NET/C# Development</category><category domain="http://decav.com/blogs/andre/archive/tags/On+Software/default.aspx">On Software</category></item><item><title>Security: Writing Password Protected Applications</title><link>http://decav.com/blogs/andre/archive/2007/06/07/security-writing-password-protected-applications.aspx</link><pubDate>Thu, 07 Jun 2007 22:23:00 GMT</pubDate><guid isPermaLink="false">1a6c50a2-1cc5-440d-a734-51a167eba982:2221</guid><dc:creator>mrdecav</dc:creator><slash:comments>1</slash:comments><description>&lt;p&gt;Okay, here is something that is very frustrating to me.&amp;nbsp; So many people do this incorrectly and it makes me feel insecure about giving my password to a website. The thing they don&amp;#39;t do properly is &lt;strong&gt;password management&lt;/strong&gt;.&lt;/p&gt;
&lt;p&gt;In this day of web and hobbiests calling themselves developers, we&amp;#39;ve found ourselves with tons of accounts at every web property ever, each with a username and password.&amp;nbsp; Users however seldom know &lt;strong&gt;how&lt;/strong&gt; their password will be stored when they supply it.&amp;nbsp; This leads to various simple but dangerous security holes.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Ways not to handle passwords&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;div&gt;&lt;strong&gt;Never store passwords in plain text.&lt;/strong&gt;&amp;nbsp; Passwords should be stored &lt;strong&gt;with one-way hashes&lt;/strong&gt; (such as an &lt;strong&gt;MD5&lt;/strong&gt;) so that the hashes can be compared when a user enters a password to login.&amp;nbsp; Storing passwords raw in a database not only makes you responsible for everyones lost passwords if someone hacks your system, but also is bad practice because DBA&amp;#39;s have full access to password lists.&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;&lt;strong&gt;Never send a user their password for &amp;quot;forgot password&amp;quot; workflows.&lt;/strong&gt;&amp;nbsp; If you do the first, this should be obvious enough.&amp;nbsp; &lt;strong&gt;Sending passwords via email is dangerous&lt;/strong&gt; because anyone can sit down at users machine and open up a web browser history and Outlook; try &amp;quot;forgot password&amp;quot; on a few sites and get the users password to anything.&amp;nbsp; Not very secure.&lt;/div&gt;&lt;/li&gt;&lt;/ul&gt;
&lt;p&gt;&lt;strong&gt;Proper ways to handle passwords&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;div&gt;&lt;strong&gt;Store passwords with a one-way hash&lt;/strong&gt;.&amp;nbsp; Storing passwords with a one-way hash allows you to compare the hash against a hash you make when a user attempts to login, but secures the users password from the sight of both a potential hacker or a DBA.&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;&lt;strong&gt;Send links or new passwords to email accounts.&lt;/strong&gt;&amp;nbsp; When a user requests a forgotten password, send the user a single-use link to create a new password, or a temporary password they must change on next login.&amp;nbsp; This will ensure the user can change their password, but the password cannot be compromised by someone with access to their email.&lt;/div&gt;&lt;/li&gt;&lt;/ul&gt;&lt;img src="http://decav.com/aggbug.aspx?PostID=2221" width="1" height="1"&gt;</description><category domain="http://decav.com/blogs/andre/archive/tags/Web+2.0/default.aspx">Web 2.0</category><category domain="http://decav.com/blogs/andre/archive/tags/.NET_2F00_C_2300_+Development/default.aspx">.NET/C# Development</category><category domain="http://decav.com/blogs/andre/archive/tags/On+Software/default.aspx">On Software</category></item></channel></rss>