Is Debug Mode Evil?

"On April 29, 1974 when the US Congress refused to authorize emergency funding to support our ally the South Vietnamese, that's when I stopped being a Liberal."
--Mort Kondracke

One of the difficulties in working with .NET, especially ASP.NET, is being able to determine whether an assembly has been compiled in Debug Mode or Release Mode, and especially whether an application is running in Debug Mode (e.g. debug="true" in the compilation element of web.config). This also applies to the Page level attribute, debug="true", in the @Page directive.

It is definitely evil if a production app is being run in debug mode - it will use a lot more memory, stuff that should be cached will not be cached, and a half dozen other generally "evil" things.

Recently I chimed in on a post by MVP Rick Strahl where he posts some code to determine "runtime" debug status via the HttpContext:

if (!HttpContext.Current.IsDebuggingEnabled)
Script = OptimizeScript(Script);

Wilco Bauwer states that this doesn't take the Page - level debug=true attribute into effect, since it basically encapsulates the web.config setting, and he suggests:

bool isDebuggingEnabled = Assembly.GetExecutingAssembly().IsDefined(typeof(DebuggableAttribute));

My suggestion offers another solution using the Global.asax.cs file and a static global application flag being set in the Application_Start event:

public static bool IsDebugMode = false;
protected void Application_Start(object sender, EventArgs e)
if (System.Diagnostics.Debugger.IsAttached) IsDebugMode = true;

Rick replied that in his case he's not after knowing whether the user is actually running a debugger or not but rather whether the application is in Debug Mode. Like MS Ajax he is trying to send back Client script code and depending on the debug flag he either wants to mangle the script or not and add the appropriate browser caching flags (public vs. private) so that the content can refresh.

There are slight nuances in all of the above; it's probably a good idea to test your stuff with any or all of these and see what effect each has.

There is one other little item I've started to use. If you look in my assemblyinfo.cs files, you'll see this:

[assembly: AssemblyTitle("WhateverTheTitleIs")]
[assembly: AssemblyDescription("[DEBUG]")]
[assembly: AssemblyDescription("[RELEASE]")]

I've started to do this with all my builds. Now, you can just right click on the assembly in Windows Explorer and look at the summary, and you'll see either "RELEASE" or "DEBUG". This really helps in making sure that you have not accidentally deployed an assembly built in debug mode into a production app, something that you really really want to be sure "NOT TO DO"! Bear in mind that it is possible to build a release build of an assembly and have the compiler still emit a PDB (program debug database) file so that your logging framework can report more information on exceptions.

You can also retrieve these properties programmatically through reflection, and have your app be able to "self report" on itself and all the assemblies it uses. If you want to get really creative, you could even add this information to the assemblyinfo VisualStudio project template file, and have it be there automatically for all your new assemblies.


Microsoft Expression Web Designer - Dreamweaver Killer?

I looked at the beta of this but now its for sale (you can download a fully functional trial here) and all I can say is, "this thing totally rocks!".

You get advanced WYSIWYG design support for any kind of ASP.NET or HTML page, CSS taglets that actually show you what the rendering looks like (you can just highlight an element in Design view and right-click on a CSS style and choose "Apply Style"), and (Damn - I don't know how the HELL they do it but...) the ability to import a complete ASP.NET web site -- over HTTP -- and start working on it! It's got features up the GAZOO and it's also very easy to learn to use.

I gotta tell ya, this is the engine that will be built into Visual Studio.NET "v.Next" (Orcas) as the built-in ASP.NET HTML editor designer, and if it's gonna be anything like what you get with Expression Web, you can just take your Dreamweaver 8 and uninstall it, because there isn't much of anything I can think of that you would want to keep it for!

It takes a lot to get me excited about a new piece of software lately, because I've become so jaded from all the hype, but in this case I am happy to make an exception!


When is it time to "Move On"?

Recently I made the decision to "Move On" from a position I had been at for two years. I went about it very methodically, and the results were highly successful. I'll be starting as a Senior Developer / Architect at a much more stable company, for a lot more money, and with a vastly improved work environment at the end of January. I'd have left sooner, but the boss asked me to hang around for the obligatory two-week notice, so that's OK with me.

Developers have to realize that sometimes your skill set exceeds the capabilities of the work environment you were originally hired into. What I mean by that is, if you find that your work environment is no longer sufficiently remunerative in terms of the challenges you are presented with as a professional "problem solver", that you aren't getting the raises, perqs or bonuses that you feel you should be getting for the innovative, quality work you do, or that you just plain feel that your work environment is less than what a professional developer should expect, then it's probably time to "Move On".

Opportunity Cost of Retaining Good Employees

Many employers don't understand a basic fact in the marketplace: It costs less money to keep good employees happy than it does to have to keep replacing them when they leave. It takes a developers 3 to six months on a new job before they are really starting to make a contribution. If your developers are constantly leaving you because you haven't provided the kind of environment to keep them happy, you are going to be in a constant state of retraining new hires and bringing in new people to replace those that left. You are going to be constantly paying headhunter fees, have your staff all tied up with the extra effort it takes to bring new employees up to speed, and the extra administrivia and paperwork it takes to keep the revolving door you've set up for yourself running.

In sum it would have been a lot cheaper to pay people more, give them more benefits and a better work environment, and have them be happy and stay.

"Moving On" is generally a difficult thing to do for a lot of software developers beacause of inertia - this is human nature. A body at rest tends not to suddenly start moving on it's own without some sort of external influence. Sometimes you may have a Significant Other who adores and respects you, and supplies the encouragement to overcome the inertia; other times you yourself must supply the determination to do better for yourself.

And, sometimes you need to consider your situation carefully, pull your pants up by the bootstraps and FORCE YOURSELF to get to a better place. In other words, YOU need to supply the influence on YOURSELF if you want to move ahead and upwards in your short happy life as a software developer! If you do not, inertia will keep you in the same place, and you and your career may stagnate.

You deserve it. If you are stuck somewhere that is less than par, the only person you can blame is - YOURSELF.

Think about it. We are in a great economy and the developer market is very tight in a lot of areas of the country. If you aren't happy where you are, then you need to get your ass in gear and LEAVE!

How NOT to make a code example!

"I have no idea where I'm going. But the real question is, what was I doing here in the first place?" -- Art Buchwald

This is a bit of a pet peeve of mine, and ordinarily I wouldn't even bother to write about it except for the fact that I saw this article on MSDN and just had to shake my head in quasi-disbelief.

An otherwise excellent article on how to do BHO's (Browser Helper Objects) in managed code, and what does their example do? You guessed it: a "Hello World" MessageBox in your Browser! Good God, folks! Is that the most innovative code illustration you can come up with? It's completely USELESS! How about getting an RSS feed, doing a search, or creating a link?

You see something similar in many code examples, both in books, and in print and online articles. All you get is a Console application that "illustrates" a technique that should have been put into a self-contained class library. Instead, all the "guts" is totally tied up into the Console app -- often making it extremely difficult, especially for n00bs, to do something useful with it.

Naturally, its almost never that a real - world developer would ever want this code in a console app, but that's what you get.

Oh, I understand the rationalization that many users don't have Visual Studio and maybe they are doing their development in Notepad and using the command line compilers. Total B.S.! Visual Express products are all free now, and SharpDevelop, an open source IDE that rocks, is also free. So, that "explanation" doesn't cut it with me.

I really think writers should give serious thought about the usefulness of the code examples they publish. I almost always try to illustrate a technique by providing a full example with a class library, and where appropriate, an ASP.NET Web Solution or a Windows Application to go with it that uses same. It only takes a little bit more time, but I am sure that the end-users appreciate it. And ain't that what it's all about - the end user?


Whoops! Got Tagged!

From the It Really Happened Department

Developer: "Why is Visual Studio.Net so SLOW!"
Developer 2: "Try closing a few of the other nine copies you've got running."

<Got Tagged?>

I don't know who came up with this, but I've seen it around and now I've been tagged by my buddy, MVP Rick Strahl.

That means I've got to tell you five things about myself that you don't know about me. Let's see...

1) I'm the kid who set Hi Tor on fire! Yep, when I was 14, I and Tommy Lockhart decided to hike up to Hi Tor, a mountain that overlooks the Hudson River in northern Rockland County, New York. Tommy and I had started a fire to cook our hot dogs and we scrambled up the metal radio tower at the top of the mountain to enjoy the panoramic view. The winds were high, and before we could clamber back down, the whole top of the mountain was on fire. We hi-tailed it back home as fast as we could. They sent a helicopter up there to douse it with water. Nobody got hurt, I don't think. Here's the whole story, if you want a good giggle...

2) I started out programming in BASIC! That's right, you would never know it because you couldn't pay me any amount of money to write in BASIC now, but that's how I learned programming. Echh!

3) My cousin Victoria, who is now married with kids and lives in Boulder, CO, was a dancer with the New York City Ballet under the legendary George Balanchine. No, I am not related to David Bromberg or Brian Bromberg, but I did play contrabass and flute in jazz clubs in and around New York City years ago, with the Robert Hunt Trio. I also gigged with Noel Jewkes and Jules Broussard in San Francisco, and played Zen flute music with Schawkie Roth.

4) My goal in life is to be a philanthropist. Right now, I'm still only a malingerer, but I'm working on it!

5) I believe in the Zen of programming. If you aren't sure what that means, don't worry. I just had to find something for number 5! BTW, one of my favorite Web 3.0 sites is zombo.com - where you can do anything!

But mostly, I've always been a geek. When other kids were cruising around in their cars, I was in my room, soldering in an illegal 40-Watt power tube into my CB radio!

So, to keep this going, "Who's on First?" You guys have been TAGGED:

1) David Silverlight, of XmlPitstop.com

2)Kevin Spencer (MVP)

3) Jon Skeet, (MVP)

4) Robbe Morris (MVP)(RobDogSnoopCat)

5) Bill Jones (MVP)


New Features at IttyUrl.Net

My latest creation, Ittyurl.net, which takes the "short url" concept quite a bit farther, now features my "Multi-Search", which searches currently 18 different providers simultaneously (live.com, google blog search, msn search, msdn search, digg, asp.net forums, technorati, blogmarks, reddit, Yahoo news, blogdigger,
waypath, blogpulse, fybersearch, feed24.com, icerocket.com, furl.net, and google news), removes duplicate links, and presents your results in a nice page-able Gridview display.

If you are interested in some pointers on how I do this, check out this recent article on eggheadcafe.com.

The concept of IttyUrl.net is that if you create a short url there, you should not only be able to get a free RSS feed of all your links, but your short url should be shared with others so it is searchable and thus people who use the site can use it to find "similar" content that others have saved.

There is also a very easy-to-use SOAP 1.2 compliant webservice API. Take a look. Suggestion are, of course, always welcome.


World's First Silent Ringtone - a la John Cage

Conceptual artist Jonathon Keats has created the world's first silent ringtone, a bootleg of John Cage's famous piano piece that contains four minutes and 33 seconds of silence. Cage performed 4'33" live before an audience in 1952. Keats wrote "My Cage," a 4:33 minute ringtone of pure, unadulterated silence. You can get it for free from Start Mobile, a ringtone distributor, and Keats urges people to remix and mashup his ringtone as much as they wish.

From the ringtone ad:

A remastering, "My Cage" is also a remix, introducing serendipity into the equation, delivering performances unpredictably, whenever calls come unexpectedly. The silence may take place without the listener being aware of it. Or the listener may hear a call - phantom silence - when there's no one on the line. "My Cage" all-encompassing: Even those who don't use it as a ringtone have the potential to experience it, in the silence of an unanswered call. Note: To fully enjoy this work, and to give callers the opportunity to enjoy the complete silence as well, it is recommended that you turn off your voicemail.

I grew up in Rockland County, NY where Cage had a house in Stony Point. When I was young, we used to drive by and look at it - it was a circular house, like a dark tin can. John Cage pushed the envelope of modern music, and he did it with grace and style. I will never forget his influence on me as both a musician and now, as a programmer. John Cage (and followers like Terry Riley, Steve Reich, and Philip Glass) understood the Zen of music and helped me to understand the Zen of programming.

Do you remember your Mantra?


More Web 2.0 Goo for You?

I just have to shake my head and laugh at how silly buzzwords have become. Buzzwords, particularly on the Internet, have gotten to the point where they've replaced the human ability to actually observe and think -- with patterns of "brainwave gibberish" that evoke images of the classic Pavlovian doggie-style "knee jerk on demand" reaction.

Case in point: "Web 2.0" What IS this God-awful Horseshit? Yes, I know all about the O'Reilly conference and them laying out all the groundwork and guidelines about what is and what is not "Web 2.0" and I really couldn't care less!

Look, A web site is a web site.

It might be good, it might be bad. It might have a lot of snazzy features, and it might not. It might be useful, and it might not be, notwithstanding the previous items. You wanna put a snazzy label on it to make you "feel all good"? -- knock yerself out!

Did you know that if you search Digg on "Web 2.0" (all time) you come up with 393 pages worth of this utter CRAP? That's 5,895 entries, mostly about nothing at all.

It really doesn't mean a damned thing to me. It could be Web 2.0, it could be AJAX, it could be Web 3.11. It's just a fyookin' WEB SITE, man! I'll figure out whether I like it or not, and I'll decide whether it's useful to me. Its the CONTENT and its usability that's important, not the curvy corners and funky logos and the AJAX - SCHMAJAX! And especially not that fact that some moronic "self proclaimed Web 2.0 Guru" put his label of approval on it!

All your stupid acronyms and buzzword labels SUBTRACT value, IMHO -- they only serve to elicit this Pavlovian "no need to reason" response rather that leading the user to really think and use their brain for a change.

This pretty much sums it up for me:

I can't help it. I am a programmer, and as a programmer I understand the first inalienable right of programmers is - we get PAID TO THINK!

Cripes! Oscar the Grouch knows more about Web content than you Web 2.0 morons!


More Patent Parking Extortion - only now it's Universities!

A research foundation backed by the state of Washington has sued three of the world's biggest consumer electronics makers over claims that they have infringed a series of patents surrounding the Bluetooth short-range wireless technology.

The suit was filed in Federal court in Seattle and claims that Matsushita, Samsung and Nokia should have sought a license before using the technology in cellphones, headsets and other electronic equipment.

The Washington Research Foundation, which said it was acting on behalf of the University of Washington, owner of the patents in dispute, said it had already secured a license over the technology from Broadcom, one of the biggest makers of communications chips, that would cover any consumer electronics that employ Bluetooth chipsets made by Broadcom.

However, it said that the three companies had all sold devices based on chipsets made by British-based CSR, which had not been licensed. CSR slammed the legal suit as "without merit in relation to CSR's Bluetooth chips". By focusing on the US, WRF's action could potentially affect a fifth of the world's cell phones.

Meanwhile, the beleaguered IEEE 802.15.3a task group failed once again at its latest meeting to select one of two competing proposals for the ultrawideband physical layer for high-rate, short-range wireless connectivity ("UWB").

Amid accusations of deliberate stalling by one side and overstated time-to-market advantages by the other, the group is now considering extreme options ranging from splitting the task group into two to outright dissolution if some progress is not made by March.

What's really happening is that it's all about the patents. Nobody wants to give up on the version of the standard that might include some bit of their own patented technology, no matter how broad and obvious, because it's just so lucrative.

The end result is that it slows down or kills various useful standards that would help move industries forward. Once again, this flies in the face of the purpose of the patent system - a system that has gone terribly wrong.

In other news, they've found evidence of liquid methane on Saturn. But don't get too excited. Some outfit probably already has a patent on it, and they are ready to sue at the drop of a hat.


Extract Files from an MSI Installer without a full install

Have you ever wanted to get at some assemblies in an .NET MSI installer, but you either didn't want to do a full install, or there is some condition in the MSI Installer that doesn't let you install it (such as, you need such and such program, version X, and you do not have it on your machine)?

You can do an Administrative installation using MSIEXEC.EXE and the /a command - line switch:

The administrative installation runs only basic actions like InstallFiles in the AdminExecuteSequence table.

You cam also run this, passing the command to start /wait which will block until msiexec.exe completes and returns:

start /wait msiexec /a product.msi TARGETDIR="%TMP%\Product" /qn

Ah! Now I can fire up Reflector and look inside those little boogers!

N.B. A commenter mentions "LessMSIrables" a tool to extract files from MSI's. Here is the actual link: