|
Monday
7/6/2009 11:06:23 AM
(CST)
-
Michael Wells
I like sleek-looking applications as much as the next guy, and good iconography is a solid part of that effort. Unfortunately, a lot of the icons I find can't be used in a .NET app--when I try to apply an icon as, e.g. the application icon, I get an "out of memory" error.
Some Googling yielded a newsgroup comment, which suggested that .NET cannot read some icon formats, so I did a bit of experimentation and came up with this explanation and solution;
As you probably know, ICO files are compound-image files. There can be any number of iconic images in there, of different sizes and bit depths. It happens that 24-bit formats, in particular, seem to cause problems. If you have any 24-bit images in your ICO file, .NET will not be able to load it.
The easy solution to this is to use a good icon editor (I like IcoFX, which is freeware). Open the ICO file, and create new 32-bit versions of the desired icons at the appropriate sizes. Most icon editors, including IcoFX, allow you to create icons from existing icons. You simply create a new 16x16x32-bit icon from the existing 16x16x24-bit icon, and so on, for all the sizes you need.
It is crucial to delete the 24-bit versions as well, to prevent .NET from choking when it tries to load the file.
Save your changed file, and voila! The ICO file will now work fine with .NET apps.
|
|
|
|
Thursday
8/3/2006 8:05:24 AM
(CST)
-
Michael Wells
I have way too many projects. Hundreds of little websites, and a few giant behemoths dancing around me. Managing these puppies is like herding cats, and so a lot of my attention turns to things like processes and tools for keeping them out of the fireplace.
HttpHandlers and HttpModules are a wonderful thing here, because with no application code, and a few lines of Web.config, you can plug in a big chunk of capability, like health monitors, exception loggers, even database handling tools.
The annoying thing is that this approach doesn't lend itself well to plugging in stuff that has UI's. In the .NET world, any page will have, somewhere, an .aspx file to support it.
What I'd really like to be able to do is to create a tool that is, say, a simple web-based database administration tool. Build it normally, with .aspx, .resx, and .cs files. But on compilation, have it embed all of the static files like the .aspx, .resx, and graphics, into the resources of the finished assembly. One big self-contained thingamabob.
I think this could be done with the addition of one feature to .NET... a version of GetCompiledPageInstance that can read from resources, rather than from the local hard drive.
I bet that would open up a whole new market for component venders; pre-built, easily-integrated website additions. Of course, done improperly, it would open up a whole new door for hackers, too...
|
|
|
|
Tuesday
5/9/2006 5:17:05 PM
(CST)
-
Michael Wells
Once in awhile, it's nice to mix things up on your website. If you have a set of images (or html snipplets, or other content) that you'd like to randomly choose from on each page refresh, and those items are all of the same file format, here's a quick technique.
|
|
|
|
Monday
4/24/2006 11:42:01 PM
(CST)
-
Michael Wells
|
|
|
|
Monday
4/24/2006 10:57:59 PM
(CST)
-
Michael Wells
When developing large applications, you look for any methods you can to establish consistency in the interactions between all the little moving pieces. To do otherwise is mental suicide; you just can't possibly remember or document those inconsistencies well enough to find your way around.
|
|
|
|
Friday
4/7/2006 4:49:14 PM
(CST)
-
Michael Wells
Wha..?! It turns out that C# has a built-in mechanism for multi-line constant strings, without the need for a line-continuation character. What I've always been coding as...
szSql = "select * from blah " + "blah blah blah blah " + "blah blah blah blah " + "blah blah blah blah";
Has always been possible through the much simpler;
szSql = @"select * from blah blah blah blah blah blah blah blah blah blah blah blah blah";
Can you believe it? Why didn't one of you tell me! Arrgh!
[Director's note: In utter frustration, Mike throttles the mouse for several minutes, then bashes it to a pulp of circutry and made-in-Taiwan laser parts. Then goes and has a good, stiff yoghurt-flavored drink, which quickly restores him to peace & sanity.]
Of course, using @"" for multiline strings may not be all that perfect a solution. For one, you can't embed escaped characters like \x203. For another, the carriage returns separating your lines are included in the string. Sometimes that's good, and sometimes it doesn't really matter. But sometimes, it's Bad. Nevertheless, I'd much rather write string reformatting functions than deal with pages of line continuation characters.
Of course resource files and database CLOBs work great too, but it's sure nice to have code features like this. Much appreciated, MS.
Moral: RTFM. It will save you gobs of time and frustration.
|
|
|
|
Monday
4/3/2006 11:45:38 PM
(CST)
-
Michael Wells
|
|
|
|
Thursday
3/16/2006 12:04:02 AM
(CST)
-
Michael Wells
A great solution for vertical alignment in CSS, that actually works in Internet Explorer.
|
|
|
|
Wednesday
2/22/2006 12:55:14 PM
(CST)
-
Michael Wells
I've been thinking lately that there's a big case for custom pre-compiler tags in C#. This kind of capability would offer a very easy, reusable way to extend the C# compiler without having to write VS.NET plug-ins or perform your own pre-compilation step outside of the system.
For example, when you have a long string such as a SQL statement, using string-concatenation is a messy approach.
string szSql = "select " + "t.* " + "from " + "MyTable t ";
And copying and pasting and reformatting the text between VS.NET and your SQL editor of choice is just... no fun at all.
Using the @ for multiline strings tends to be better, but it is also non-optimal because it prevents escaping (afaik), and introduces CRLFs into your content...
string szSql = @"select t.* from MyTable t ";
|
|
|
|
Monday
10/31/2005 4:59:41 PM
(CST)
-
Michael Wells
I often find myself wishing SQL would just disappear. From an application development standpoint, trying to write code that efficiently manipulates a chunk of raw instruction text is... dumb. And the fact that SQL uses an ostensibly English-like grammar often adds a dash of nightmare.
SQL was never designed to be written my another program, and it is therefore missing some very basic behaviors that you might expect.
Take, for example, the IN clause...
|
|
|
|
Wednesday
8/10/2005 2:01:26 PM
(CST)
-
Michael Wells
Andy and Marcie inspired me to dig a little deeper into custom DataGrid columns and this morning, I discovered just how easy it is to cook up a wee bit o' magic.

With surprisingly little effort, BarChartColumn was born and both binaries and source are available for download.
|
|
|
|
Thursday
8/4/2005 8:05:51 PM
(CST)
-
Michael Wells
The ASP.NET DataGrid is an excellent control, but requires a little slight-of-hand to achieve some of the capabilities you'd like. One common need is the ability to have a column of checkboxes, which allow you to select multiple rows and perform some task on them -- such as deleting selected emails from your inbox.
There are a number of ways to do this, but like any architect I wanted the best, cleanest, most flexible approach for my project. This morning I hopped over to my favorite starting point for all things DataGrid -- Marcie Robillard's DataGridGirl.com. It's an excellent reference and as luck would have it, one of the top articles hit the nail on the head. It happens that Andy Smith of MetaBuilders (already one of my favorite component developers) has extended the DataGrid directly with a new column type named RowSelectorColumn,
Quite literally, I dropped it in, wired it up, and it was working flawlessly in minutes. You have to love that kind of smoothness.
However, there was one limitation that was significant in my project. I'm using the RowSelectorColumn to allow the user to choose rows for deletion -- but project requirements demand that some of the rows be pre-checked based on internal business logic. In my case, I have a boolean column in my DataSource that contains the state I need the checkbox initialized to -- but the current version of the RowSelectorColumn doesn't support data binding.
|
|
|
|
Wednesday
6/8/2005 11:22:06 AM
(CST)
-
Michael Wells
Ok, I confess, I'm officially now an RSS addict. This is way too much fun. And useful! Well, mostly anyway.
One of my newer discoveries is the MSDN RSS feedset, which does a good job of covering most of the interesting developer news at Microsoft.
Then of course, there are also the developer personal blogs... which are friendly and also chock full of useful information about what to expect and how to future-proof your systems.
Good stuff! Keep it going, MS.
|
|
|
|
Friday
4/1/2005 1:32:03 PM
(CST)
-
Michael Wells
Hmmm, a few important things I didn't know about how .NET uses the assemblyinfo version numbers.
|
|
|
|
Monday
3/28/2005 8:22:09 AM
(CST)
-
Michael Wells
Much to my dismay, .NET 1.1 does not offer any significant support for DateTime conversion across timezones. Unforgivable, yes. But then, that's only because solution architects like me are so spoiled by the great coverage .NET has essentially everywhere else.
So now I'm left to design my own time zone converter, and as it turns out, this problem isn't as simple as it sounds. For example, we Americanos are used to timezones being neat and orderly, e.g. GMT-7, GMT+3, and so on. Did you know that much of the world doesn't use even-hour increments from GMT. Egads! Several major Indian cities are at GMT+05:30. Central Australia is at GMT+09:30, and Kathmandu is GMT+05:45! Even on our own continent; Newfoundland is GMT-03:30.
Interestingly, I've heard it said that Eastern thought seeks a more accurate representation of ideas, thus the use of hieroglyphic languages. Western thought seeks a simplification and orderly classification of ideas, thus alphabetic languages. This seems to bear out in our use of time zones as well.
Some interesting discussions of datetime formats and timezone representations;
Also of the relationship between UTC and GMT;
Jon Box has written an excellent summary of his experiences with the same problem, and his solution.
|
|
|
|
Thursday
3/24/2005 11:33:24 AM
(CST)
-
Michael Wells
The DataGrid is a great control, once you figure out how to overcome some of it's subtle inconsistencies.
One of the things that most annoyed me about the DataGrid was that when you specify a CssClass to apply at the row level, the tag is actually applied to the <TR> element instead of the <TD>. This makes it useless for formatting.
The second, related annoyance was that there is no means to apply cell-padding at the <TD> level, which means the default DataGrid view has text slammed against the cell borders, making it... urgh... difficult to read.
Fortunately both can be overcome quite easily.
|
|
|
|
Tuesday
3/22/2005 10:38:41 PM
(CST)
-
Michael Wells
There's a nifty little copy-and-paste trick in VS.NET that's a carryover from Microsoft Word. When selecting data, you can select rectangular regions of code by holding the Alt key while you click and drag.
This is actually very useful in those special situations. You can delete the content, but more interestingly, you can copy and paste the content into another location, and the rectangular nature of the selection will be preserved.
|
|
|
|
Monday
3/14/2005 9:15:04 AM
(CST)
-
Michael Wells
Though not strictly a .NET discussion, I've been experimenting [very successfully] with the use of application hotkeys in a web brower application. Based on the terrific javascript work of Michael Foster, I've been able to implement a very robust hotkey capability in my .NET apps.
Now to wrap it all up as a control...
|
|
|
|
Tuesday
3/8/2005 1:27:00 PM
(CST)
-
Michael Wells
Under the category of "things I'd like to see improved", .NET handles HTML comments oddly. Specifically, .NET controls that are defined in the HTML, but are placed in an HTML <-- comment --> tag are still recognized and handled normally by .NET.
This is quite annoying, because it means that you can't quickly code/debug by manipulating large chunks of UI code. You have to backup the UI, dismember it, and run your tests that way.
The specific case I was bitten in today was that there were some old RequiredFieldValidator controls in my HTML that had been commented out. Even though they weren't rendered by the browser (hey, they were commented out...), they were processed by .NET. In essence, the field validators were failing, but weren't able to show their error. So the page couldn't process and also couldn't tell me why...
It's a little thing, but as they say, it's the little things that count...
|
|
|
|
Monday
1/31/2005 10:19:25 AM
(CST)
-
Michael Wells
ASP.NET gives developers the ability to generate traditional HTTP errors (like the commonly known 404 - document not found error) from within an application. In its simplest form this is done using the HttpException class, e.g.;
throw new HttpException (404);
|
|
|
|
Saturday
1/15/2005 10:56:17 PM
(CST)
-
Michael Wells
I've encountered an unexpected anomaly in the behavior of HttpModules relating to the decoding of Urls.
If you have an HttpModule installed in your application, portions of the Url appear to be decoded between the user request (i.e. what is entered into the browser Url bar) and the execution of the HttpModule.
The specific problem I'm encountering is the decoding of + (the MIME encoding for a space character) and %2B (the MIME encoding for a + character).
|