June 2005 Entries

One More On ASP.NET 2.0 Compilation

I’m trying to move past the subject of ASP.NET 2.0 compilation to something new, really I am, but between some insightful questions I’ve seen, and work on my own code, I’m starting to have … issues. Switching Pre-compilation Models Can Expose Broken Code Let’s say you have a web form and need to dynamically load a user control. The code inside a web form might look like: {     Products products;     products = LoadControl("Products.ascx") as Products;     products.CategoryName = "Blunt Instruments";     Controls.Add(products);        } We can build the code from the IDE with no errors. We can do a simple precompilation from the command line with no errors....

My Worst Job

I’m throwing my story into the worst job meme. When I was 17-ish, my friend Andy started driving a maroon 1969 Camaro SS – a true muscle car. I’ve never been a big gear head, but the sound and fury of 400 horsepower was enthralling. We used to cruise the streets downtown. Andy had a theory that the smell of burning rubber would attract females, but we soon realized the only interested females wore badges and wrote traffic tickets. Live and learn, I always say. We also came to terms with another, more serious problem. Andy’s parents refused to pay...

When Deployment Gets Ugly

Rick Strahl presents a GUI utility to drive the aspnet_compiler command line tool, and voices valid criticisms of ASP.NET 2.0 deployment options with “ASP.NET 2.0 Application Deployment in the real world”. Precompile || !Precompile Is pre-compilation for deployment worth the trouble? The performance advantages to pre-compilation are almost insignificant. Pre-compilation is not NGEN. There remains a hefty amount of JIT compiling at startup, not to mention warming up the cache, establishing connections … the to-do list for the runtime at startup goes on and on. There are, however, at least two good reasons to pre-compile. First, pre-compilation will find any syntactical errors...

Special Directories in ASP.NET 2.0

ASP.NET 2.0 introduces a number of special directories for application resources. These directories live as subfolders in the application root, have special names, and offer various shortcuts and conveniences to web developers. One such folder is the App_Code folder. You can drop a .cs file into the App_Code folder, even while an application is running, and the runtime will automatically compile all the code inside the folder into an assembly. The App_Code folder is one of those features experienced developers will shun in favor of class libraries. Other folders have definite advantages. For example, the App_Browsers folder will allow you...

Tracing Threads In Async Pages

Let’s look at the impact of the Async=”true” attribute in an @ Page directive for a web form using RegisterAsyncTask. Refer to the 2nd chunk of source code from last week’s “Async pages” post. The new tracepoint feature in VS 2005 makes analyzing thread behavior in this scenario quite easy. Tracepoints are set like breakpoints, but instead of halting execution you can ask a tracepoint to log a message to the debug output window. It’s like having calls to Trace.WriteLine in your code. I set tracepoints at the beginning of Page_Load, Page_Unload, and in each of the begin and end...

Precompilation in ASP.NET 2.0

New article on OdeToCode: Precompilation in ASP.NET 2.0. Here is an excerpt: Although pre-compilation will give our site a performance boost, the difference in speed will only be noticeable during the first request to each folder. Perhaps a more important benefit is the new deployment option made available by pre-compilation - the option to deploy a site without copying any of the original source code to the server. This includes the code and markup in aspx, ascx, and master files. Other notes: It seems the precompile.axd 'magic page' touted as a feature in the early days has slipped quietly into the...

Service Broker

I spent my recreation time this weekend on the softball field and doing the Service Broker challenge. I left the softball field for the second time in as many weeks on the losing side, and with scraped up legs. It’s time to buy long pants – I’m becoming old and fragile, I am. The Service Broker experience involved a lot less pain, although Geoff is now taunting me. May your blog be filled with an overabundance of spam, Geoff! The amazing part about Service Broker is not how I dropped an XML document into a local queue, nor how the...

Win A Book!

The fine people at Packt Publishing are letting me giveaway their books in a contest. They have books by yours truly, on DotNetNuke, BPEL, and a variety of other topics outside of .NET. My first thought was to have contestants answer 3 .NET trivia questions, but this runs the risk of having some clever know-at-all from Microsoft point out a subtle flaw in the question and invalidating the entire contest. Instead, I decided to play it safe and ask three questions about content on this blog (don’t worry – I’ve provided hints to make it point-and-click easy). Here are the...

Async Pages In ASP.NET 2.0

Fritz Onion asks an interesting question in his “Value of asynch tasks” post. Do asynch tasks add any benefit for parallelizing asynchronous web service invocations? I’ve been experimenting with the feature too, and wanted to offer an answer. Let’s say we need to call a HelloWorld web service that returns a string, but the service takes 5 seconds to complete – and we need to call it twice. In the simplest case we are looking at a 10 second response time. We might try to improve response time by kicking off simultaneous calls the service like so:     1     protected void Page_Load(object...

Partially Amazing

Did you know in 2.0 both C# and VB use the partial keyword to indicate a class definition will be spread across multiple declarations? Don’t they always use different keywords? How did this happen? To: Team From: Team Leader Date: T – 3 days Subject: Partial Dear Team, Yesterday, that ‘other’ language team decided to use partial as a keyword in their language. We need the same feature, but you know we try to avoid sharing keywords with that ‘other’ language. We have about 3 days to think something up. Email me your suggestions. To: Team From: Team Leader Date: T – 2 days Subject: Re: Partial Dear...

Blogs & Censorship

There is a kerfuffle in Blogsville over censorship in the MSN Spaces available to residents of China. Let’s make the assumption that without censorship, there would be no MSN Spaces available in China. The assumption seems safe to make, in which case Microsoft is taking the right approach. I’d like to think that if I was Chinese, and I wrote a blog entry containing the word ‘freedom’, and the site rejected my post for containing ‘forbidden speech’, that my thought process would be the following: 1. The government sucks …2. … but I’m sure this is easy to work around …3....

nCover

I didn’t realize until recently that there are two different projects going by the name of nCover – the one on ncover.org and the one on SourceForge. Both projects are code coverage analyzers. Code coverage tools measure the fraction of code exercised during execution. If an assembly has 100 lines of code, and the execution flow covers 30 of those 100 lines, you have 30% code coverage. I think code coverage tools are a natural sidekick to unit testing tools, because you can see and verify what code is being tested. For pros (and cons), see: “How to Misuse Code...

Linking Is Back

In case you didn’t know there was an OdeToCode link blog, or you were wondering if the link blog died, well, it’s back.

More String Comparisons

Just out of college, I used to spend half my time writing Windows UI code in C++, and half my time writing firmware for 8 bit Intel and Hitachi CPUs using C and assembly language. The firmware drove some infrared LEDs and took readings from an ADC to determine the percentage of protein in a wheat sample. “How exciting”, I can hear you say. The C compiler for the 8 bit Hitachi chip was terrible, but fortunately the compiler generated files of assembly language instructions instead of binaries.. The assembly files would then pass through an assembler to produce the...

TechEd Day 1

No, I’m not at TechEd either, but I did keep the keynote webcast open in the background. If you are interested, I’m sure a Google news search will turn up piles of mind-numbing analysis by industry experts who do nothing all day but write white papers filled with pie charts, so I’m not rehashing any content here. Something did stick out, though. Rather – something was missing in this keynote entitled “The New World Of Work”* I’m pretty sure there was not one mention of a web application during the keynote. There was talk of smart clients, web services, mobile...

Code-behind for Me

In ASP.NET 2.0, I still prefer using code-behind over the single-file code model for web forms – but it is a tough choice. In ASP.NET 1.x the choice was easy. Using a code-behind file was the only way to have intellisense when writing code, was the only way to catch syntax errors at build time, and was the only way to ‘pre-compile’ your code into an assembly before deployment. All these reasons above go away in 2.0. In the single-file model your C# / VB.NET code exists inside a <script runat=”server”> tag, and within the same file as the ASPX / HTML...

Code-Behind or Single File?

The latest OdeToCode article: The Code Models Of ASP.NET 2.0. The obvious question is which model should you be using for your ASP.NET projects? The answer will largely depend on the type of person you are. Working from a single file containing both the code and ASPX markup will appeal to many people, while others will insist on a strict separation and favor the code-behind model. The single-file model has an advantage in configuration management and deployment, since there is only a single file to version and deploy. Intellisense and refactoring tools appear to work equally well with both models, so...

Test-Driven Development with NUnitAsp

There is a good-looking webcast coming up on MSDN tomorrow (Wednesday, June 1): Test-Driven Development with NUnitAsp. I saw some of Jonathon Cogley’s TDD presentation at the MAD Code Camp, and it was obvious that he lives this stuff everyday. Turn on and tune in.

Things You Can't Trust

Recent discussion has focused on the trustworthiness of blogs. I was quite dismayed to think I may not be able to take everything I read in my aggregator at face value. The problem is that I keep a list of only 10 things I can’t trust. Currently this list looks like the following: Rental car agents Object references returned from a web service  Naked mannequins The television The newspaper The guy reading a magazine in a non-descript van across the street Financial planners Mayonnaise The Sith Tinky-Winky the Teletubby My question is, do blogs break into the top 10 list of things I can’t trust? If...