Thursday, December 21, 2006

This is a postcard a coworker received from our freshly re-elected governor.

I like the attempt to include us yoopers. Unfortunately, well, I dunno. I've lived here a while, and something just doesn't seem right. Let's consult maps of Michigan at Google Images. (Go look.)

What really thrills my coworker is the shear number of hands this photo must have gone through before getting printed and *NOBODY* noticed it. Show anyone here in the U.P. this picture and they catch what's wrong instantly.

Now, I wasn't impressed with either candidate in this last election, but, well, who the heck is representing us?

Thursday, August 17, 2006

I'm in no way a music aficionado, and I have very specific likes and dislikes. Sometimes I like certain songs by a certain band, but really dislike the majority of other music in the same genre. It's weird.

One type of music I like almost 100% across the board is classical. I'm not a huge fan of overly-chamber-ish classical, and I don't really go outta my way to listen to classical. It's just decent background music. (No vocals == good background noise as far as I'm concerned.)

Now, remixed classical? I really like that. Check out this YouTube video for an example:

I'd really like to hear more remixes by this guy. Does anybody have any leads?

UPDATE: I found this YouTube vid because of digg.com, click here to digg-it. In the comments, someone has a link to JerryC's website. (I thought it was JerryL.). Anyway:

Wednesday, July 19, 2006

Ok folks, this is mostly a post for my own personal use. Basically, so the next time I run into the problem, I'll remember that I wrote this post. :)

While the title is misleading -- debugging in VS2005, especially debugging when debugging multithreaded apps. I've just ran into a problem though.

See, I'd set a breakpoint inside some code that's executing on another thread. When the breakpoint hits, VS2005 just sits there for about 10 seconds. It's like it's dead. Then, after it comes-to, if I try to step-through, or step-into any code after the breakpoint weird things happen. Like, it doesn't step-forward into the code. And while the IDE indicates the app is still in a 'paused' state, it certainly doesn't have any instruction pointer, nor does the "Threads" debugger panel indicate that your extra thread even exists anymore! Hitting "F5" and letting it go about it's business doesn't help either -- the app is now in some sort of voodoo-ized state.

The only solution is to stop the app and restart it.

This still doesn't help the fact that I can't debug any code running on a non-main/UI thread!

Basically, what's happening is the debugger is trying to peek at all the local variables in order to 'help you' debug. Unfortunately, access the GUI objects created on the main/UI thread from another thread is bad juju, and the debugger hangs when it hits a breakpoint while trying to probe values from objects owned by the UI thread. Why it screws everything else up, I don't know.

BUT, I've come up with a solution not listed in the above links -- disable/close/don't-look-at the "Locals" debugging panel. If that panel isn't visible, the debugger won't waste time poking-n-prodding all the objects found in the current scope, and you'll avoid the problem entirely. :)

Tuesday, June 27, 2006

Having worked with various versions of MS SQL Server for a number of years now, (6.5, 7.0, 2000, 2005,) and the verious MSDE and 'Express' editions of the product, I found this following link interesting:

Monday, April 03, 2006

There are a number of collection-like objects in the .NET Framework that allow you to 'key' the data you enter into them. Dictionary<TKey,TValue> comes to mind almost immediately. Dictionary<TKey,TValue> contains a Dictionary<TKey,TValue>.ContainsKey(T key) method that makes key-existance determination trivial.

But what about the SerializationInfo object?

When an object implements ISerializable the ISerializable.GetObjectData(SerializationInfo info, StreamingContext context) method adds the object's data to the serialization stream in a key/value style:

info.AddValue("MyObjectsValueKey", this._MyValue);

Then, during deserialization, the constructor that meets the ISerializable implied-constructor signature:

MyObject(SerializationInfo info, StreamingContext context)

is called, and the object is supposed to bootstrap itself from the data contained in the SerializationInfo instance.

How? By retrieving values based on the previously used string-keys, of course.

So, why isn't there a SerializationInfo.KeyExists(string key) method?

I hear some of you saying "Well, it's the serialization of an object, you had better know what's was serialized in the first place!" True, very true. But, consider a versioning issue that might arise:

Example (version 1):

Assume you have a business object that implements ISerializable. For this example, let's call that business object MyObject. In your first version of MyObject, you have some code that looks like this (large portions of code left out to save space):

As you can see, MyObject has an internal List<T> of OtherObject's. It exposes a property that returns whatever the 'current' OtherObject is, based upon a private index into the _MyOtherObjects List<T>.

The serialization code is fairly straight forward.

Now, let's say, somewhere in the development of the version 2, we find a bug related to _CurrentOtherObjectIndex not being updated properly when instances OtherObject are being inserted into the _OtherObjects List<T> at various locations, thereby possibly invalidating the OtherObject pointed to by _CurrentOtherObjectIndex.

Instead of updating the various code locations that would need to update _CurrentOtherObjectIndex we decide it would be better to just replace _CurrentOtherObjectIndex with an OtherObject instance. ie:

Ahhhh, but making this change would break the compatiblity between version 1 and version 2 of MyObject. Oh, but wait, we're handling the serialization ourselves, we should be able to code around it. [Let's ignore any possible versioning issues involved with strong-naming, let's just assume the version 2 code tries to deserialize a version 1 MyObject.]

So, ideally, we could change the ISerializable implementation to look like this:

We have to rely on an exception as part of our 'normal' code path. This feels 'icky' to me. ("Icky" being a highly technical term that means many things at different times. In this case, 'icky' means "goes against my 'best-practices' sense". Exceptions should be exactly that: an unexpected error condition. In the course of a normal deserialization, we have decided that being able to deserialize v1 MyObject instances into v2 MyObject instances is a completely normal operation. We should not have to rely on an Exception to perform normal work. And if we have a situation where v2 MyObject code may be deserializing a large amount of v1 MyObjects, we can expect it to be much slower as well because the Exception handling system carries a heavy tax.

One Possible Solution

One solution is to have any object that implements ISerializable also serialize some for of version information. Whether this version information is culled from the assembly versioning info, or is a private field of the class is completely up to your implementation. In the following modification to MyObject, MyObject will store it's own versioning information.

So, does anyone out there know why there isn't aSerializationInfo.ContainsKey(string key)method? As with many things that I've learned about the .NET Framework, what at first seems obtuse to me usually has a very good explanation behind it.

I gotta give thanks to Mr. DotNet who has helpd me through those mentally-obtuse times. He really knows his stuff. I was hoping to be able to use his SyntaxHighlighter (*nudge*-*nudge*) to make my code a bit more readable. Maybe in a future update!

Friday, March 31, 2006

I think #6 looks interesting, and I wouldn't mind trying it once, but for normal use? No thanks.

A couple coworkers have bad wrist problems and have keyboard #8.

What am I using right now? A Microsoft Ergonomic 4000.It's relatively similar to the original Microsoft Natural, but the key layout is slightly modified -- more relaxed I guess. I like the sexy-black color and the soft foamy wrist wrest. I'm not sure about all the extra buttons on the keyboard though. At least they're kept to a relative minimum, and are out of the way, on this keyboard.

Wednesday, March 29, 2006

I just finished figuring out a problem I was having with a ClickOnce deployment for a project I've been working on.

This project has a reference to ADODB.dll -- a Primary Interop Reference provided by Microsoft in the .NET Framework SDK. Unfortunately, that PIA isn't provided in the .NET Framework redistributable. Also, unfortunately, setting the adodb.dll to copy-local during the project-build process didn't help during ClickOnce deployment -- the ADODB.dll was specified as needing to be installed into the GAC before my app would install.

I did some searching around, and stumbled upon this post as the MSDN ClickOnce forums:

You can find my response there, but if you're averse to clicking, read-on.

Basically, the problem boils down to the default ClickOnce publishing behavior for the ADODB PIA. For whatever reason, it marks the ADODB PIA as a pre-requisite in the applications .manifest file. This means that ClickOnce requires the ADODB PIA to be installed into the GAC before it will allow my app to be installed. Unfortunately, none of the bootstrapper pre-reqs installed the PIA into the GAC, (making one of those pre-req bootstrapper installers is a possible solution, and I mention it in the reply, but it's not the easiest solution.)

What fixes is the problem is modifying the 'Publish Status' of the ADODB.dllin the project's ClickOnce publishing settings. You change ADODB.dll's publish-status from the default "Include (Auto)" to "Include".

Yes.

Change it from one setting to another setting that appears to be the exact same setting.

Re-publish. The applications .manifest now specifies ADODB.dll to 'install' -- which will cause ClickOnce to copy it to the install folder, instead of requiring it be installed into the GAC.