Monday, September 22, 2008

The Legend

The race this weekend went great. I finished in 1:46.21. As far as I can remember, that's my fastest half marathon, though I suppose that's not too difficult, as the next fastest that I know of was the halfway split in my first marathon (1:49:40). I haven't run a lot of on-road halves.

Anyway, the day was fantastic, sunny and pleasant. The course was hilly, but nowhere near as tough as the website made it sound. Our weekend long run course on Whangaparoa road is quite a lot tougher. That said, there were a lot of rolling hills and nice smooth downhills.

Here are the splits (markers were every 2km)
2k - 10:07 (5:03s)
4k - 19:47 (4:50s)
6k - 30:30 (5:21s)
8k - 40:27 (4:59s)
10k - 51:55 (5:44s)
12k - 1:04:04 (6:04s) - big uphills.
14k - 1:14:20 (5:08s)
16k - (4:34s)
18k - (4:34s)
20k - (4:34s) 8:27? (4:13s)
21k - 1:46:21

My watch data is a little bit muddled from 16-20km. I think I got some of the full marathon distance markers mixed up with the half markers. But whatever happened, I was definitely averaging 4:34s from 15km to the finish! I would love to have the splits from the last 2km. 18-20 is 8:27 in my watch, but I'm not certain that's right.

Thursday, September 18, 2008

Marathons Past

This last weekend I did a 34k training run. That may be the furthest I've ever run outside of an actual marathon. It was definitely almost as tough as running a marathon itself.

It got me thinking about past races and times. It occurred to me that I'd lost track of how many marathon's I've run. I had the feeling it was somewhere around 10, but I couldn't be sure.

After a bit of searching around the websites of the races I've run, it turns out that this upcoming Auckland marathon will be my 9th. For future reference, here are the races and times:

Grandma's Marathon 20023:48:11First Marathon with Craig, Pete, and Scott
Twin Cities Marathon 20033:59:54Ran by myself, beautiful weather. Breaking 4:00 in this race is what made me think I could just keep running without training.
Grandma's Marathon 20044:00:20Ran with Peter Akimoto. Stayed in the Clown House. I probably would have wimped out on this one if Peter hadn't been keen on driving up to Duluth on Friday night.
Twin Cities Marathon 20055:18:06Ran this one with some first timers from work. For the record, running slower is more painful that just running as fast as you can (To a point at least, the very first marathon, I was at the best fitness level, but in the worst shape at the starting line, and in the most pain afterwards.)
Auckland Marathon 20064:28:16First New Zealand Marathon. This one made me decide that I'd better get training again after all.
Rotorua Marathon 20074:51:10This one was brutal. Pouring rain at the start line, cold wind later. This is the only marathon where I thought for a while that I might not finish.
Auckland Marathon 20074:08:20I was in overall good shape for this one, but not the greatest running shape. I held the end together quite well, but just didn't have the leg muscles to finish under 4:00
Rotorua Marathon 20084:07:03Much better than the last Rotorua, in fact the day was nearly perfect. Same story as Auckland 2007, good run, just couldn't pull in under 4:00

The last few months I've put in more running than any year since 2002. We'll see how that works out.

This weekend I'm running a half Marathon. "The Legend" named for Arthur Lydiard's training route in the Waitakere's. Looking at Arthur's training methods, they're nearly identical to what my old high school cross country coach used to use. I may have to study up on that again, I wouldn't mind seeing how close I can get to my 5k PR (18:03) one of these days in between marathons.

Anyway, here's The Legend, I'll post a race report afterwards:

Wednesday, September 10, 2008

Compile Error in ASP.Net (error CS0103: The name 'X' does not exist in the current context)

Note: I would have liked to title this post "Microsoft Voodoo make Hulk MAD!!" but for reasons outlined in the rant below, I went with the title above.

The Problem

In an ASP.Net web project you may see one of these two compile error messages referring to a control in a page:

In the Visual Studio 2005 Output window:

"error CS0103: The name 'X' does not exist in the current context"
"error CS0117: 'XPage' does not contain a definition for 'X'"

In the VS.Net 2005 Compile Error List

"The name 'X' does not exist in the current context."

Where 'X' is your control variable name (like TextBox1). If you're seeing these, then you may have the same problem I did.

My problem more specifically was that I was copying files from one (working) VS.Net solution which contained one sort of web project, to another stand-alone project. I needed the new project to have a .CSProj file so our build guys could compile the site with whatever they're using. As soon as I copied the first non-static content into the new Project, the errors above started.

My Solution

The technical root cause of the problem was that there was no variable referring to the control(s) in the page object model.

More details

When I added a new page from scratch, a WebForm1.aspx.designer.CS file appeared, with the following code in it:

protected global::System.Web.UI.WebControls.TextBox TextBox1;

Hmmm . . . why did the other page not have a designer.cs file? In fact the original project I was copying from has no Designer.cs files at all.

I went back to the other (working) project and right clicked on the object referece to my control. In response to "Go to Definition" I got a message box stating:

"The definition of the object is hidden."


Hidden where exactly? Visual Studio's little "Show All Files" option is greyed out. A look at the file system revealed no mystery files. This was starting to sound familiar from my long ago reading about new partial class features.
After Googling "The definition of the object is hidden" I had my answer (see references for details, specifically [1]).

It turns out that I'd stumbled into a gap between "Web Site Project" and "Web Application Project"[2]. I was attempting to manually copy files from a "Web Site" into a "Web Application". In a "Web Site Project", the compiler does some code generation for you, and hides it away in a temporary assembly stored in the location specified by HTTPRuntime.CodeGenDir.

"Web Application Projects" were rolled into VS.Net 2005 with Service Pack 1.

So anyway, throwing the textBox variable declaration into the code-behind file allowed a successful compile with a cut down version of the page. That was definitely it.

Now that I knew what I was looking for, I searched on "Converting a Web Site Project to a Web Application Project". Sure enough, that turned up [4] Walkthrough: Converting a Web Site Project to a Web Application Project in Visual Studio 2005

Great . . . not only does this guide contain an exact description of the specifics of the problem, but it's a detailed guide to the solution. I still need to read a bit more of this tomorrow, but this has certainly cleared the biggest roadblock. To rub salt in the wounds, if you do the file copy from IDE window to IDE window it all happens magically, I never would have seen this problem at all:

"Visual Studio includes an option to convert pages and classes within Web application projects to use partial class declarations. Partial classes are used to separate designer-generated code from code-behind code. These designer-generated classes are stored in a separate file from the code-behind file. This conversion process causes Visual Studio 2005 to recursively examine every page, user-control, and master-page in the project, and to automatically generate a .designer.cs file for each. Visual Studio also changes the .aspx or .ascx files to use the codeBehind attribute instead of the codeFile attribute."

<BonusRant read="optional">
I get incredibly annoyed with some of these 'easy' problems. I want to be able to just look up the error message in a search engine, but it seems I always run across the same pattern of search results:

1. Often the top couple of hits are totally irrelevant sites that happened to be experiencing the same error at the time that the crawler bot visited.

2. The next hit or two are even more annoying. Typically, it's somebody who has innocently(naively) cut and pasted their error message into some forum site or support board. Their post is at the top, then there follow the useless trolls and know-it-alls who bitch about posting off topic or demand more irrelevant data. Then the whole thing either trails off, or the person solves their own problem, but doesn't post the solution. Better forums at least they put a little mark on the solution (if one has emerged).
3. After the first page or so of search results, you just get forum sites that scrape other forum sites, or tons of cross posts of the original problem to ghost-town forums.

So anyway, the moral of this story is: here's my contribution back to the internet: The error message and a solution in one troll-free page. ;-) I've seen quite a number of search hits for other technical posts here, so hopefully this helps somebody.



[1]The Definition of the Object is Hidden

[2]Visual Studio.Net 2005 Web Application Projects

[3]ASP.Net 2.0 Hidden Files and Assemblies

[4]Walkthrough: Converting a Web Site Project to a Web Application Project in Visual Studio 2005

Monday, September 01, 2008

Tech Ed NZ 2008

Tech Ed New Zealand is on at the moment. It's day two.

I was excited about it over the weekend and yesterday morning, but I've had enough now.

This is one of those in between years when everything is pretty much where it was last year. Visual Studio 2008 and .Net Framework 3.5. I didn't even see anything shiny or fun in the Silverlight or WPF department. Most annoying of all, in between sessions when I went down to play in the hands on labs, all the lab virtual machines had expired beta versions of Expression Blend, rendering them unusable for WPF and Silverlight labs.

Ah well, maybe it will be more fun next year. I really only learn from what I work with every day anyway. At the moment, that's WCF via VS.Net 2005, most of my work doesn't even have GUIs other than my own test harnesses.

Speaking of testing, one of my co-workers: Rob Fonesca-Ensor gave a presentation on Dependency Injection, Inversion of Control and Unit Testing during the New Zealand .Net Users Group Code Camp on Sunday. Very good presentation. There's some stuff I'll actually use soon, I need to do some follow-up on the Ninject framework.

Two other good things out of Tech Ed: Scott Hanselman is coming over here to talk to our developers in our lunchroom for a couple hours. Scott's ASP.Net MVC presentation was the high point of day one. Then OpShop is playing at TechFest tonight.