November 2003 - Posts
I'm trying to do some profiling on a command line app that uses a number of assemblies that spit out a bunch of debug information via Console.WriteLine (this isn't the intent and the calls have since been removed; I just don't have the latest bits yet). This is no problem on the command line, as I can redirect output to null via “> nul”. Unfortunately, this doesn't work when started from a profiler.
The simple solution was to add an optional “-null” argument to the application. When that argument is given, I replace the standard out with a NullTextWriter, then re-add the standard out at program end in case any exceptions were thrown, etc. Here's the magic:
public class NullTextWriter : TextWriter {
public override System.Text.Encoding Encoding {
get { return ASCIIEncoding.Default; }
}
}
You can set the output stream by calling Console.SetOut(TextWriter). Works for me.
I've been acquiring new hard drives over the years as I rip more CDs, take more photos, etc. As you'd imagine, it gets harder to keep track of what is where, what's worth keeping, what's not, etc. I finally lost it yesterday and took a few hours to write something to create a single virtual drive. It's nothing fancy like a file system driver, but simply a Windows Explorer-like app that shows all of the drives you want (including networked drives) as a single drive. I have no idea if anyone else would find this useful. If so, let me know and I'll clean it up and post the source on my site (and get a better icon).
“Features”
- User picks which drives to use in the virtual drive, including network drives. (This is good for me because my “server“ machine has two internal and two external.)
- Folder tree view is an aggregate view of all of the folders on all the drives. For example, although I have two or three “\Documents and Settings\Jeff“ folders on different drives, it shows up only once. Every file is shown.
- Send files/folders to the recycle bin.
- View file/folder properties.
- Open files.
- That is all.
Download

What year is this? 1983?
I'm installing Borland's Optimizeit profiler and things aren't looking good so far. I get to the second page of the installer, which is all done with bitmapped fonts that I can hardly read, and get the above message. I'll continue on and hope that the people that wrote the installer had nothing to do with the actual product development, and are shot.
Microsoft® has posted a Word® document titled “A Sneak Preview of Visual C#® Whidbey”. It's a great, short overview of the language improvements as well as VS.NET, WinForms and ASP.NET info. Check it out, you might learn something.
Microsoft, Word and Visual C# are either registered trademarks or trademarks of Microsoft Corp. in the United States and/or other countries.
Brad Abrams has started some really interesting API discussions over the past couple months. It's great to see what the .NET teams are thinking about and it's nice to know they're listening to “the people“. I've always found API issues to be particularly interesting, and Brad's blog doesn't disappoint.
One of the more recent discussions is Properties vs. Methods. Sure, they're both really methods, but what does the consuming developer expect? Most treat them like fields and expect that the cost is minimal. What if that's the case 95% of the time, but the remaining 5% are (very) expensive? Do you use methods instead? Do you consider a different design altogether? Read about this and more at Brad's Pad of API Happiness.
I've read in the past that default parameters in VB.NET are “bad”, but never saw an explanation. Being a C# guy, I didn't really care to find out why since we don't have them. BradA explains why.
Simply, the default value is compiled into the caller. Yes, that's right, this is your worst versioning nightmare.
I had to figure this out a couple days ago and the answer isn't what you'd expect: It's not FileVersionInfo.IsDebug or IsRelease, as neither compiler flips the required bit. As far as I can tell, the only way is to look for a DebuggableAttribute on the assembly.
static void Main(string[] args)
{
Assembly assm = Assembly.LoadFrom(args[0]);
bool found = assm.GetCustomAttributes(typeof(DebuggableAttribute), false).Length > 0;
Console.WriteLine("Assembly is {0}.", found ? "debug" : "release");
}
Quiz
How do you determine if a table exists in SQL Server?
a) sysobjects
b) information_schema.tables
c) other
If my crack research team is to be trusted, the answer is “B”. They claim the reason is that the sysobjects table's schema may change over time but the information_schema.tables view will not.
If you've been keeping up with the blog world the past week (I haven't) you've probably read or seen references to the multi-blog debate about sprocs vs. generated SQL. The best post (and comments) I've seen so far is on Frans' site (85 comments as this went to press).
My thoughts: Every problem is different. Pick the most appropriate solution. Easy!
So now there's a weblogging site for TabletPC users[1] to upload posts in Ink.
This is progress?
I can't read my own handwriting, much less a good chunk of others'. I think the TabletPC presents a great mode of input for a PC. Very cool and handy. But please, please, don't subject me to other people's bad handwriting. I've noticed some other apps are treading in these waters and I hope it doesn't catch on. The day I start receiving emails in Ink is the day I start my career in home construction and renovation.
[1] Link from fun guy Provost.
More Posts
Next page »