Rants, rambles, news and notes from another geek

Road to Wisdom

Just saw this go by on the Extreme Programming mailing list:

The road to wisdom? Well it’s plain and simple to express: Err and err and err again, but less and less and less.

-Piet Hein,
poet and scientist (1905-1996)

I'm Published!

I am finally a published author. The August 2003 issue of Hardcore Web Services just hit my desk and my article, “Test-Driven Development and Web Services” is on the cover. Cool!

NOTE: The website is currently down… I think due to the east-coast blackout.

More on Generics

In case you read my blog and not Don Box’s blog I wanted post a link to his answer to my post about C# generics. It looks like my answer wasn’t necessarily wrong, but also wasn’t the real answer.

Here is Don’t first post which explains the answer. Here is a follow up post which explains delegate compatibility. I think understanding this last bit is going to be very important when we all start actually using generics, so this is a very useful bit&nbsp_place_holder;of information. Thanks Don.

Credit Card Prank

This is hilarious. I knew that most sales clerks don’t actually compare the signature on a credit card receipt with the back of the card, but who would’ve thought you could draw a little comic strip and they would take it? [via Bruce Schneier’s Crypto-Gram Newsletter]

Camping

Well, we tried to take my 17 month old daughter, Hadley, camping this weekend. After driving 9 miles up F.R. 119 in Pike National Forest, we found a nice spot that would fit two gigantic tents (one for my family and one for my brother-in-law’s family).

Just about the time we got the tents up it started to sprinkle. That wasn’t all that unexpected, but it out haste to get out of Denver, we forgot to bring rain gear. I figured that it would be a typical Colorado summer rain shower… no more than an hour or two long. No such luck.

Three hours later all of the kids were wet and cranky and the rain was getting stronger. Everyone except brother-in-law and I was hiding in a tent. Andrew and I had a pretty good fire going and were warm if not dry. When my wife yelled out, “The tent is leaking,” though, we knew we were in trouble.

After another 15 minutes waiting and discussing, we decided to bail. The rain was really coming down now and the temp was down to about 48 degrees. The kids were cold and wet. So we grabbed the coolers, the kids and the dog and loaded up the cars. We left everything else behind. I sure didn’t feel like taking down my 3 room tent in the middle of a freezing rain storm.

We drove back down the mountain in the splendor of a heated car and went to Andrew’s house. It wasn’t raining in Highlands Ranch, so we fired up the barbecue and made smores. The kids had fun and got to sleep in warm beds.

In the morning Andrew and I went back up to Pike National Forest and struck camp. It was still cool and damp, but at least it wasn’t raining anymore.

So our first attempt at camping with a toddler didn’t work out. We hope to try one more time before Fall/Winter and hopefully that one will go better. We will at least remember to bring panchos next time. :)

Specifying Requirements W/ C# Generics

In my post&nbsp_place_holder;More Tricks w/ C# Generics, I re-posted Don Box’s sample that demonstrated the use of the where clause in a generic definition.

Don’s code was:

public delegate void EventHander<S, T>(S sender, T args) where T : EventArgs;

Brett&nbsp_place_holder;Knights asked in the comments of my post what the difference is between Don’s code and this:

public delegate void EventHander<S>(S sender, EventArgs args);&nbsp_place_holder;&nbsp_place_holder;

I’m not 100% sure of this, but based on my experience with C++ templates I would suggest that there is&nbsp_place_holder;a significant difference between Brett’s example and Don’s. In the former example, you are saying that T should be derived from EventArgs, but within your method T is still “untyped”. In other words you can access any public method on T, not just those defined in EventArgs.

In Brett’s example you would only be able to call the public methods defined in the EventArg class.

Am I right here? Anyone who actually has Whidbey care to comment?

Using Class Libraries Projects as Web Project in VS.NET

Richard Lawrence asks in the comments of my post Create the Solution Before Adding Projects

Where can I find more information about making web projects work as Class Libraries? I’ve looked around on your site and Brad’s, but no luck. Thanks.

Since as far as the compiler and the runtime are concerned there&nbsp_place_holder;is no difference between&nbsp_place_holder;web projects and assemblies, all you really have to do it convince VS.NET to behave.

Here are the steps I follow. This process is far from ideal, but it works for me.

First you need to setup VS.NET to allow you to add web files to class library projects:

  1. Open the file WebProjectItems.vsdir in a text editor. (This file is typically installed in C:\Program Files\Microsoft Visual Studio .NET 2003\VC#\CSharpProjectItems\WebProjectItems)

  2. Open the file LocalProjectItems.vsdir in a text editor. (This file is typically installed in C:\Program Files\Microsoft Visual Studio .NET 2003\VC#\CSharpProjectItems\WebProjectItems)

  3. Copy the following lines from WebProjectItems.vsdir to LocalProjectItems.vsdir. (Note: I don’t know if the GUIDs and IDs are different on different installs. If not you can just copy these.) (UPDATE: I broke the following lines so they would display better on my blog. Each entry is ONE line and begins with ‘..’)

    &nbsp_place_holder;..\CSharpAddWebFormWiz.vsz {FAE04EC1-301F-11d3-BF4B-00C04F79EFBC} #2236 10 #2263
    {FAE04EC1-301F-11d3-BF4B-00C04F79EFBC} 4534 0 WebForm.aspx  
    &nbsp_place_holder;..\CSharpAddWebServiceWiz.vsz {FAE04EC1-301F-11d3-BF4B-00C04F79EFBC} #2243 20 #2266
    {FAE04EC1-301F-11d3-BF4B-00C04F79EFBC} 4521 0 Service.asmx  
    &nbsp_place_holder; ..\CSharpAddMobileWebFormWiz.vsz {FAE04EC1-301F-11d3-BF4B-00C04F79EFBC} #2398 25 #2399
    {FAE04EC1-301F-11d3-BF4B-00C04F79EFBC} 4571 0 MobileWebForm.aspx  
    &nbsp_place_holder; ..\CSharpAddWebDataForm.vsz {FAE04EC1-301F-11d3-BF4B-00C04F79EFBC} #2380 45 #2381
    {FAE04EC1-301F-11d3-BF4B-00C04F79EFBC} 4559 0 DataForm.aspx  
    &nbsp_place_holder; ..\CSharpAddWebUserControl.vsz {FAE04EC1-301F-11d3-BF4B-00C04F79EFBC} #2378 55 #2379
    {FAE04EC1-301F-11d3-BF4B-00C04F79EFBC} 4558 0 WebUserControl.ascx  
    &nbsp_place_holder; ..\CSharpAddMobileWebUserControl.vsz {FAE04EC1-301F-11d3-BF4B-00C04F79EFBC} #2400 56 #2401
    {FAE04EC1-301F-11d3-BF4B-00C04F79EFBC} 4572 0 MobileWebUserControl.ascx  
    &nbsp_place_holder; ..\CSharpAddWebControlWiz.vsz {FAE04EC1-301F-11d3-BF4B-00C04F79EFBC} #2297 120 #2298
    {FAE04EC1-301F-11d3-BF4B-00C04F79EFBC} 4533 0 WebCustomControl.cs  
    &nbsp_place_holder; ..\StaticDisco.disco {FAE04EC1-301F-11d3-BF4B-00C04F79EFBC} #2393 155 #2394
    {FAE04EC1-301F-11d3-BF4B-00C04F79EFBC} 4525 0 Disco.disco  
    &nbsp_place_holder; ..\CSharpAddGlobalASAX.vsz {FAE04EC1-301F-11d3-BF4B-00C04F79EFBC} #2304 160 #2305
    {FAE04EC1-301F-11d3-BF4B-00C04F79EFBC} 4542 8192 Global.asax  
    &nbsp_place_holder; ..\CSharpAddWebConfig.vsz {FAE04EC1-301F-11d3-BF4B-00C04F79EFBC} #2312 170 #2313
    {FAE04EC1-301F-11d3-BF4B-00C04F79EFBC} 4545 8192 Web.config  

Once you have done that, you can create a project.

  1. Open Visual Studio and create a Class Library project.

  2. Add a reference to System.Web

  3. Open IIS Manager

  4. Add a New Virtual Directory to your Default Web. I like to name mine the same thing as my Web (Class Library) Project.

  5. Browse to your project folder and click OK.

  6. From File Explorer, give the IUSR_MACHINENAME and ASP.NET accounts read and execute right on the files and folders in the project.

  7. In the project settings for your project, set the Configuration drop-down list to All Configurations. Set the following settings:

&nbsp_place_holder;   Build:  
&nbsp_place_holder;&nbsp_place_holder;    Output Path: bin\  
   &nbsp_place_holder;Debugging:  
&nbsp_place_holder;&nbsp_place_holder;    Enable ASP.NET Debugging: True  
&nbsp_place_holder;&nbsp_place_holder;    Debug Mode: URL  
&nbsp_place_holder;&nbsp_place_holder;    Start URL: The url you setup for the virtual directory
  1. Build your project.

Debugging your project is done by attaching to the IE and ASP.NET_WP processes.

  1. Start your project by pressing F5. This will launch IE and attach to the running IE instance.
  2. Once the web browser is up, choose “Processes…” from the Debug Menu.
  3. Check the “Show System Processes” checkbox.
  4. Select aspnet_wp.exe from the list and click Attach.
  5. In the “Attach to Process” dialog, check “Common Language Runtime” and click OK.
  6. Close the “Processes” dialog.
  7. Set breakpoints and start debugging.

That’s it. A few things to note:

  1. I’m pretty sure you could dig through the project config files in VS.NET and create a new project template that does all of the project setup steps. This exercise is left for the reader.
  2. Your project will not have a Global.asax or a web.config file. Add them if you need them.
  3. I don’t know how to add “Web Form” to the “Add…” context menu in Solution Explorer. Anyone?
  4. I would love to have better way of debugging.

Please leave comments if you know how to deal with these issues or if you know of a better way of doing this.