Browsing Tag »Source Code«

The Weekly Source Code 51 – Asynchronous Database Access and LINQ to SQL Fun

March 2, 2010

You can learn a lot by reading other people's source code. That's the idea behind this series, " The Weekly Source Code ." You can certainly become a better programmer by writing code but I think good writers become better by reading as much as they can. I was poking around in the WebFormsMVP project's code and noticed an interesting pattern . You've seen code to get data from a database and retrieve it as an object, like this: public Widget Find(int id) { Widget widget = null; widget = (from w in _db.Widgets where w.Id == id select w).SingleOrDefault(); return widget; } This code is synchronous, meaning basically that it'll happen on the same thread and we'll wait around until it's finished. Now, here's...(read more)

The Weekly Source Code 50 – A little on “A generic error occurred in GDI+” and trouble generating images on with ASP.NET

February 18, 2010

I got a nice little Yellow Screen of Death (YSOD) error on some code running under IIS that worked fine when running on the VS Developer Web Server. The error was "A generic error occurred in GDI+" and you know that if an error is generic, it's sure in the heck not specific. My little application takes an overhead map that's stored in a local file, does some calculations from user input and draws an X on the map, then returns the resulting dynamically generated image. There's basically three ways to do images on the server side. Use Native APIs and Interop, which only works in full trust, use System.Drawing, which " isn't supported " or use WPF on the server side, which also, ahem, isn't officially supported...(read more)

SmallestDotNet Update – Now with .NET 4 support and an includable JavaScript API

February 9, 2010

A few years back I wrote a post on the size of the .NET Framework . There's historically been a lot of confusion on the site of the .NET Framework. If you search around on the web for ".NET Framework" or ".NET Framework Redistributable" you'll often get a link to a 200 meg download. That download is the complete offline thing that developers redistribute when they want to install the .NET Framework on any kind of machine without an internet connection. The .NET 3.5 Client Profile is more like 28 megs and the .NET 4 Client Profile is a looking smaller that than, in fact. Back then I made this website, SmallestDotNet.com to help out. It'll sniff your browser's UserAgent and tell you want version of .NET you...(read more)

The Weekly Source Code 48 – DynamicQueryable makes custom LINQ expressions easier

January 27, 2010

NOTE: An alternative title to this post might be: " The Weekly Source Code 48: Making The Weekly Source Code 47 Suck Incrementally Less. " Last week I wrote a post about Dynamic Linq Query Generation in order to solve a kind of meta-programming problem. I had a site that used ASP.NET Dynamic Data and I wanted to do a LINQ query against some data. However, because I was creating a template that didn't know enough at compile time to write a proper LINQ query that could, well, compile, I needed to creating my LINQ dynamically. Be sure to hang in here with me, the awesome happens at the end. I was trying to generate effectively this at runtime Items.Select(row => row.Property).Distinct.OrderBy(colvalue => colvalue) And I succeeded...(read more)

The Weekly Source Code 47 – ASP.NET 3.5 Dynamic Data: FilterRepeaters and Dynamic Linq Query Generation

January 13, 2010

First, let me start this post by thanking Tatham Oddie . He helped my buddy John Batdorf and I debug our issue remotely from Australia. He's patient, kind, opinionated and Tatham's got a darn fine blog that you should subscribe to now . I also found great inspiration from Stephen Naughton's excellent blog . He's continually pushing ASP.NET and Dynamic Data to do fun things and I was able to use 95% of his auto-complete code as I found it. And finally Marcin Dobosz's blog is where I started, taking his Dynamic Data sample Filter Repeaters and ending up at the Dynamic Data Futures samples . Technical Disclaimer: This is me just messing about with the .NET 3.5 SP1 Dynamic Data samples as this non-profit wanted .NET 3.5. The...(read more)

2009 Blogged – Greatest Hits

January 1, 2010

While I (really) unplugged in December of 2009, you can access a nice calendar of all my 2009 posts (as well as other years) at this link . In 2008 I published a Greatest Hits post that I will keep updated, but here's a list of links to the posts I most enjoyed writing this last year. I hope you find some of them useful, and perhaps you missed one or two or you just started reading recently and this 2009 "Greatest Hits" Post will catch you up on the stuff I was thinking about this year. General Geekery Painful Reminder: Focus on Core Competencies (and Back Stuff Up) 10 Awesome Things I Remember About Computers FizzBin - The Technical Support Secret Handshake Paving my machine for a fresh 2009 - First-Pass Must-Haves Low Bandwidth...(read more)