December 2006 Entries

Blog Tag - Five Things You Don't Know About Me

The Moth tagged me, so now you'll find out more than you wanted to know about me. 1. I scream like a 7 year old girl when I see a cicada bug. In 2004, Brood X cicadas overran the eastern United States. Three days a week, I had to get in and out of an office building surrounded by swarms of cicadas. At first, I was curious about the bugs. Curiosity turned to terror. After one week, I lost all traces of rationality. I started to think the bugs were carnivorous space aliens who wanted to crawl inside my ear and eat...

WPF versus WPF/E

I sat down to look at WPF/E this evening. WPF/E is Microsoft's cross-platform XAML engine that runs in a web browser. The technology is currently in a community preview stage. I thought a good first step would be to port my "Game of Life" WPF application to WPF/E and see the game run in a browser. A quick look at the documentation revealed that WPF/E doesn't support data binding, resources, or layout controls (like the Grid).  A good contrast will be to compare the following snippet of WPF code to my hacked up WPF/E equivalent. This C# code dynamically creates...

Google's Big Move

Google has deprecated their SOAP Search API in favor of an AJAX Search API. This move provoked a great deal of discussion. Some say the move was purely technical - Google is leaving its angled bracket XML partner to move in with the younger, sexier JSON. Others say the move was a business decision - Google can't afford to let advertising opportunities slip by. I think Google did solve a technical problem. The problem was unregulated XML data. The solution was an AJAX control. Control is the essential word. The scripts that Google requires for the new search API keep...

JavaScript Targets and the this Reference

I've been catching up on JavaScript basics recently. Here is a simple example to demonstrate the difference between the event target (where an event takes place), and the this reference (where an event handler is defined). Consider the following hunk of HTML: <div id="List">     <ul>         <li> One </li>         <li> Two </li>         <li> Three </li>     </ul> </div> We could write an event handler like so: <script type="text/javascript">      window.onload = function()   {       List.onclick =  List_onclick;   }      function List_onclick(e)   {       var evt = e || window.event;       var evtTarget = evt.target || evt.srcElement;              alert(evtTarget.nodeName);       alert(this.nodeName);   }           </script> Clicking on one of the list items will reveal that evtTarget references an LI element, while this references the DIV element. I like this style, but for various...

The Case of the Miniature Reminders Window

It was a quiet December evening. In the distance, a chime rang. Suddenly, an Outlook Reminders window appeared on my desktop. This is an actual picture of the window as it appeared at the time. The window would not resize. The window would not maximize. I made torturing gestures with my mouse, but the window held my reminders as closely guarded secrets. I poked around with the registry editor and found a value named WindowPos under HKCU\Software\Microsoft\Office\11.0\Outlook\Options\Reminders. Deleting this value and restarting Outlook made the Reminders window appear with a normal, visible size. Problem solved ... ... except, I couldn't...

Sidebar Gadgets

I find the Sidebar gadgets in Windows Vista appealing. I never thought this would happen. I've looked at desktop widget technologies like Konfabulator before, but I've always felt like I'm looking at a traveling carnival. Traveling carnivals transform a grassy field of rural America into a noisy assortment of amusement rides, games, and food stalls. The bright colored lights attract people to the midway hawkers, who in turn entice the crowd with prizes at games of chance and skill. The magic of a carnival eventually wears off when you realize the food isn't that great, the games are rigged,...

Windows Workflow Foundation - The Book

I spent a fair amount of time this year with Windows Workflow Foundation. I wrote about WF and posted a handful of articles about WF here on OTC. However, not everything I wrote ended up online…. Packt Publishing took all my work and ran it through a top-notch editorial and technical review. The result is a new book: Order now and avoid the rush!

Words To Live By - From Google Code Search

I want to take some of the prose I find on Google's Code Search and print it onto T-shirts and coffee mugs. These would make great gifts during the holiday season. Locks are analogous to green traffic lights: If you have a green light, that does not prevent the idiot coming the other way from plowing into you sideways; it merely guarantees to you that the idiot does not also have a green light at the same time. (from File.pm)....

So, What Was Wrong with That Code Anyway?

WWWTC #9 ranks 10 out of 10 on the "difficult and subtle" scale. Let's say we write the following code to call the method Jill wrote: Sub ExploitIt(ByVal path As String, ByVal data As Byte())     Dim j As New JillsObject     Try         ' setup an environment that will force         ' an exception after impersonation starts,         ' than call into the method         j.WriteToSensitiveFile(path, data)     Catch When RunMaliciousCode() = True         ' ...     End Try End Sub Function RunMaliciousCode() As Boolean     ' here is your chance to execute code as an admin... End Function The problem is that the exception filter (RunMaliciousCode) has a chance to execute before Jill's method turns off impersonation in the finally clause....

What's Wrong With This Code? (#9)

Jill Developer has a new assignment. She needs code that will overwrite data in a sensitive file. Only the local machine administrator has access to the file, but Jill plans to impersonate the admin account to gain access to the file. Jill first builds a static class to PInvoke LogonUser and start the impersonation. This class (Utility), and it's method (ImpersonateAdministrator) work well. Jill's next step is to write the following code: public void WriteToSensitiveFile(string path, byte[] data) {     WindowsImpersonationContext impersonationContext = null;     impersonationContext = Utility.ImpersonateAdministrator();     try     {         using (FileStream fs = File.OpenWrite(path))         {             fs.Write(data, 0, data.Length);         }     }     finally     {         if (impersonationContext != null)         {             impersonationContext.Undo();         }     } } Of course, Jill still has some work ahead to...

Win a Visual Studio 2005 Team Suite with MSDN Premium Subscription

In celebration of my solitary post this month, I'm giving away two Visual Studio 2005 Team Suite with MSDN Premium subscriptions. Microsoft gave me these subscriptions to give to the community, and I'd like to find some deserving candidates. To win a subscription, send me an interesting application or some cool code you've written that uses a .NET 3.0 technology (WF, WPF, or WCF), or uses ASP.NET AJAX 1.0 Beta 2. I'll pick one winner from the .NET 3.0 category and one winner from the AJAX category. I'll be posting the code from 6 or more of the entries here...

Scott Allen
Posts - 869
Comments - 4493
Stories - 14