Rants, rambles, news and notes from another geek

ASP.NET Without Web Projects

I’ve written about this before, but it seems to have gotten a lot of attention on WinTechOffTopic last week. I prefer to NOT use ASP.NET Web Projects. I prefer to use Class Library projects instead.

Not always, of course, but on larger projects with many developers and a centralized build system? Absolutely. My big thing is that I hate that the Web Project always goes under wwwroot and that it requires IIS to build. Very annoying since it really is just a class library.

Apparently, I’m not the only one who feels this way. Brad Wilson, Fritz Onion, Craig Andera and many others chimed in with a similar preference.

In fact, Fritz has written a little reference on the steps you need to take to enable .ASPX pages in a Class Library project. Thanks Fritz.

OpenPGP.NET - Part 4 - Streams and Compression Issues

This is a short note about some thoughts I’ve been having all weekend.

I’ve been reading about how you can chain a series of CryptoStream objects together to get sequential encryption or transformations. Very cool.

I’ve also been reading the code for the Cryptix OpenPGP implementation. This implementation seems to be heavily centered around the Java Cryptographic Extensions (JCE) architecture so it doesn’t fully apply here, but it does seem to use an approach that involves chaining streams and algorithms together.

So before I go much further I’m probably going to write a couple of spike solutions to play around with this idea.

Also, I’m researching my options for ZIP (RFC1951) and ZLIB (RFC1950) compression libraries. I’ve found the ICSharpCode ZIP implementation but I have two potential problems with it:

  1. I think it is a ZIP (RFC1951) implementation and not a ZLIB (RFC1950) implementation. AFAIK these two RFC’s are almost identical… but I’m not sure. Anyone know if ICSharpCode’s implementation will do both?
  2. ICSharpCode’s library is GPL with some extensions. I’ve emailed the author to see if he will give me permission to reference his compiled DLL from my BSD (or whatever) licensed code. We’ll see…

That’s about all for now. I probably won’t touch this until mid-week as I need to finish getting everything together for my talk on UIP.

UIP Talk @ MS Denver

I’m giving the following presentation at the MS offices in Denver this week…

Utilizing the User Interface Process Application Block  Â

9/23/2003 1:00 PM - 9/23/2003 4:00 PM

MicrosoftÂ
Denver Microsoft Office
4643 South Ulster Street Suite 700
Denver Colorado 80237
United StatesÂ

Recommended Audience: Developer.

Developers recognize the need to separate business processing logic from the presentation logic. However, a similar partitioning scheme can be applied to the presentation tier itself to create reusable, scalable user interfaces. This session will introduce the User Interface Process Application Block, a simple yet extensible framework for creating user interface processes that abstract the control flow and state management away from the views and into a processing layer.

Register here.

Data Access Application Blocks 3.0 Released

It looks like MS has finally acknowledged the core flaw in ADO.NET. Here’s the deal…

In System.Data there are the following interfaces:

The nice thing about this is that you should be able to program against the database transparently, right?

WRONG!

Here is the core problem:

IDbConnection doesn’t have a CreateDataAdapter method. So there is no way to “know” which kind of Data Adapter to use given only an IDbConnection. This sucks. You can call IDbConnection.CreateCommand to get a command object. From the command object you can get a data reader. But to fill a DataSet you are hosed.

Well, if you haven’t already written your own factory code, the new Data Access Application Block is out and they have done it for you. It looks pretty good at first glance but I haven’t banged on it hard.

I can’t believe we have to go through all of that just because the ADO.NET team forgot one method…

(Found the DAAB 3.0 via Fabrice’s Weblog.)

PS. This is the first bit of code I’ve seen come out of MS that has and NUnit test harness with it. Very cool. Keep it up.

OpenPGP.NET - Part 3 - Refactoring

Next up on my list was to implement Literal Data Packet (I know I said Literal Message but I can’t do messages until I have packets done).

So as not to bore you all I’ll just say that I did exactly what I did last time, but this time I followed the RFC spec for Literal Data Packet instead of User ID Packet.

Everything worked out just fine. But, as I’m sure you expect, I ended up with a lot of duplication in my code for the ParsePacket methods.

In fact the only significant difference between the two implementations was where and how the content from the packet body gets stored. This only makes sense, of course, because there is a common packet header structure here. But since I’m following TDD here, and since I also am a strong believer in the DRY principle (Don’t Repeat Yourself), I waited until I had working tested code before refactoring out the duplication.

Now I also am an experienced developer who has been around the block before. I also happen to have a spec in front of me that I know isn’t changing. So I can take a wee look into the future to see what I will need.

I decided that it would be useful to have a class called PacketReader that knows about the structure of a generic packet and how to read it from a Stream. So I dropped back into TDD mode and wrote a test class called PacketReaderTests. By working my way through the TDD green light, yellow light, red light routine I was able to get a simple class working that understood how to read the header of a stream and how to translate the body using UTF-8 encoding.

Next I removed all of that code from my UserIdPacket and LiteralDataPacket classes and ran all of the tests again. Green bar! Woo hoo… refactoring complete.

PS. I know I went fast through this but I figured another detailed discussion of TDD was unneccessary.

OpenPGP.NET - Part 2.5 - CVS Problems

Shortly after writing my last OpenPGP.NET post I decided that I should probably go ahead and push the code base into my CVS repository.

An interesting thing happened that I had heard about├é but not actually seen…

I had created an empty solition called OpenPGP. Within that I created two class library projects, one called “Core” and one called “UnitTests”.

All was well with this until I tried to add it to CVS. Because of CVS’ UNIX heritage, it doesn’t like files (or folders) named Core. (For those of you who haven’t done much UNIX development, core files are dumped to the file system when an app crashes – also known as a core dump.)

I remember reading somewhere that there is a way around this but it made me think about whether Core was really a good name for this project.

I decided “Framework” was better so I renamed the folder, changed the name of the namespace (for consistency sake) and updated all the references.

Now CVS likes it just fine. Whew.

CDROM ISO Mounting Tool

I don’t remember who, but someone recently asked me for a Windows util for mounting an ISO image as a drive. I didn’t know of one until today…

Brenton House (aka Dot Net Boy) posted his list of free utilities and in there I found Daemon Tools which does exactly that! Cool, thanks Brenton.

OpenPGP.NET - Part 2 - FxCop

As I stated yesterday, one of the requirements that I’ve set for myself is that the library should pass the default FxCop rules. (Okay, I didn’t actuall day which rules, but this is what I meant.)

I’ve been aware of FxCop for a while but haven’t actually used it much. So I downloaded it from GotDotNet├é and fired it up.

I created an FxCop project that referenced my Debug assembly and clicked “Analyze”.

I got the following report:

  1. Error - 99% - Assemblies are marked CLSCompliant
  2. Error - 99% - Assemblies should have the ComVisible attribute
  3. Error - 95% - Assemblies have strong names
  4. Error - 75% - Namespace acronyms of three or more characters are Pascal-cased
  5. Warning - 50% - Avoid having a namespace with a small number of types

I then went through these one at a time and tried to make the error/warning go away.

The first error is “Assemblies are marked CLSCompliant”

When you read the rule details on this rule it says:

Assemblies should explicitly state their CLS compliance using the CLSCompliant attribute. An assembly without this attribute is not CLS-compliant.

This one was relatively easy to fix and since I actually wanted to be CLS compliant, I added the attribute and rebuilt. Got it. One to├é the next one…

The second error is “Assemblies should have the ComVisible attribute”. The rule details on this say:

_The ComVisible attribute indicates whether COM clients can use the library. Good design dictates that assemblies explicitly indicate COM visibility. _

Again, this sounds like a pretty good idea, so I fixed that one too. Next…

The third error was “Assemblies have strong names”. This is one that I am familiar with. Here is the gist of strong names from the SDK:

A├é strong name consists of the assembly’s identity – its simple text name, version number, and culture information (if provided) – plus a public key and a digital signature. It is generated from an assembly file (the file that contains the assembly manifest, which in turn contains the names and hashes of all the files that make up the assembly), using the corresponding private key. Microsoft┬« Visual Studio┬« .NET and other development tools provided in the .NET Framework SDK can assign strong names to an assembly. Assemblies with the same strong name are expected to be identical.

Basically the idea is to create a guaranteed way of referencing exactly this assembly and not another. This is the solution to DLL hell that we experienced in Win32 and COM. Because it is my intention to ship this DLL to people for their use someday, I will certainly be strong naming it. I don’t know of any particularly bad reason to strong name it now, so I went ahead and created a strong name key by running

C:\Projects\OpenPGP\Core> sn -k OpenPGP.snk

This created the file but I also need to attach it to the assembly. I opened up AssemblyInfo.cs and scrolled to the bottom of the file and updated it to look like this:

[assembly: AssemblyDelaySign(false)]
  
[assembly: AssemblyKeyFile("..\\..\\OpenPGP.snk")]
  
[assembly: AssemblyKeyName("")]

Compiled and re-ran FxCop. Bang. Another one bites the dust. Two more to go.

The next one is “Namespace acronyms of three or more characters are Pascal-cased”. The rule details say:

Acronyms of three or more letters should be Pascal-cased. For example, use System.Xml rather than System.XML.

While I understand and agree with this rule in general, I just don’t like the look of “OpenPgp”. It bugs me. So I decided to use FxCop’s “Exlude Message” feature to basically say that I want this particular message exluded, but I want to leave the rule in place. A nice feature that is designed specifically for this reason.

The last one is “Avoid having a namespace with a small number of types.” This is a rule that I wholeheartedly agree with, but honestly I don’t care about it right now. My OpenPGP.Core.Packets namespace has only one class in it, UserIdPacket, but I know it will have more as time goes on so I will just leave this message unaddressed.

One additional thing that I did was have FxCop save a .fxcop file into my project folder. Then I added it into the VS.NET project and set the IDE to open FxCop when I double-click the file. This makes it very easy to run the FxCop checks periodically. I suppose I could add a Post-Build step too, but I’ll think about that some other day.

Tonight if I can find time, I’ll continue my TDD adventure by implementing a more complicated Packet type: LiteralMessage. (Still no crypto, but that is coming.)

.NET MCSD Here I Come

I’ve posted before about my complete lack of interest in certifications for software developers. (Except maybe the IEEE Certified Software Development Professional which I don’t yet have…)

But… my new employer will pay me to update my MCSD from VC++ 6.0 to .NET, so why not? Took my first test (70-300) on Friday and passed. Now my boss is challenging me to take the other 3 tests (70-315, 70-316, and 70-320) in ONE DAY.

I need to think about that for a couple of days before deciding. That might be an interesting way to get my bonus money but it could be a boring ass day. We’ll see…

PS. Has anyone else noticed that they don’t give you the scores anymore? Just pass/fail? Bummer.