Sunday, April 19, 2009

Confused by the GAC

Forgive me coder for I have sinned. I put some code into a dll in the GAC, and now I am confused about how the GAC is really working with IIS.

In our intranet environment I have several related web applications (about 10). Each application runs from a separate url, and potentially runs in its own app pool. For now all of the apps are on the same server, but that is not required. This setup allows us to control, develop and migrate each app separately. However, there are several parts of each app that we wanted to be common across all of our applications (master pages, logon pages, menus ect.) The request from management was that changes to these files could be universal, and would take effect without having to re-compile and re-migrate each web app. There are lots of ways to accomplish this task, and despite warnings to avoid the GAC, this really seemed like a case where using a Virtual path provider and a dll stored in the GAC made sense.

I put together a Virtual path provider, and then embedded the files and resources I needed to be common into a dll. (I could have had the VPP pull the files from a database, but I was hoping that embedding the files into the dll itself would be more performant.

Complication #1

I didn’t want the developers of each app to have to mess with their own GAC to test and run their application, so in each solution I just included the Virtual Path Provider project, and made its result dll, copy local, (as well as strongly named), this means that the provider dll, along with its embedded files are copied to the bin directory of the application. As long as the developer doesn’t have a version of this dll in their GAC (which they shouldn’t) the local bin copy is used. This allows the developer to easily change and test both the app’s files and the files that are common to every application.This also means that unless it is deliberately prevented, the common dll will exist in the bin directory of every app in production as well. However, since IIS will always use the GAC version if it exists, even if the local version is out of date, the GAC version is always used.

I accepted this as reasonable for now since I couldn’t find an easy way to both have the VPP.dll copy local for development, and yet not copy to the bin directory, when the app was copied to the server.

Complication #2

Actually coding an app so that it always uses the latest version of the dll instead of the specific version that it was compiled with seems like a fairly complicated matter. ( I have yet to see a good example of how to do it, but I think I would need a chain of publisher policies) It seemed much easier to try the more obvious answer – leave the version number of the dll unchanged when migrating a new version of the VPP dll to the GAC. This seemed to work ok, until it didn’t.

Using the Windows /assembly snap-in on the server, I replaced an older version of v. of my dll in the GAC with an updated copy of v. . Even though I had updated the dll in the GAC, my apps continued to use the old version of the code. Restarting IIS, and even rebooting the server entirely did not seem to help. What really flipped me out was that eventually IIS would mysteriously and unexpectedly correct itself and start using the correct copy of the dll from the GAC.

I have seen many GAC related questions of this type that all seemed to end with “all of the sudden my website started working correctly again”. It took a while for me to see that this was an effect of how IIS was caching my strongly named dll, and that I was mis-using the way strongly named dll’s were supposed to work.

Next I tried removing the version of the dll from the GAC entirely. Because there was still a copy of my dll in the bin directory, I expected that the process would either fail, or revert/advance to the version that was in the bin directory. However because the version in the bin was also, IIS continued to use the cached copy of the dll, which now no longer existed on the machine.(That had me really baffled for a while, because I lost confidence that the GAC version was ever running at all)

Finally the only way I had to assuredly get the dll to update was to remove the copy of the dll from the GAC, remove the copy of the dll from the bin directory, run the site so that it would fail, and then put the new version of the dll into the GAC. Starting and stopping IIS during this had no effect. This consistently got my applications to use the new code but…
So much for simply sticking a new version of a dll into the GAC and having its new effects propagate seamlessly.

After reading some related issues, What I am trying now is:
1. Stopping IIS
2. Updating thesoftware of the dll in the GAC (but still leaving the version number of the new dll at )
3. deleting everything in the 'C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files' folder ( I think this forces a recompile, but it’s a sledgehammer of a fix)
4. restart IIS.

This appears to be working, but It still seems like there is something wrong with having to go to all this trouble. Is there an easier way to force IIS to use the current instance of the GAC’s dll? Is there a better way to accomplish the effect that I am after. (some common files .aspx and .xml files shared among various apps, that can be updated separately from the apps themselves.)


Thursday, March 12, 2009

Stupid Cold

I hate the miserable spring cold that just hangs on. I had to work from home today, while going to take a nap every couple hours. It also pretty much killed my exercise routine for the time being.

I’m not sure how people made it before modern medicine - maybe that’s why they just died younger.

On the other hand not actually eating anything substantial in the last two days made making my weight goal pretty easy. New Goal 28.99 in two weeks.


Thursday, February 26, 2009

One and Done?

I Hit BMI 29.48 this morning which means I met my two week goal in one day. I guess that not actually eating for a day can do that. All I think it did was made it that much harder to reach the next goal. I set an new goal of BMI 29.25 for two weeks from today.

Jim – not quite withering away yet


Wednesday, February 25, 2009


Up on time today. I have a feeling I'm going to be tired today, but hopefully that will wear off in a couple days. I got in 30 good min of aerobic exercise. Pre exercise BMI was 29.71 which is better that I thought it would be. I'm pretty sure I got an advantage because of the time of day difference, but at least she didn't call me obese. Set my goal to be under 29.5 in the next two weeks.

Jim - hasn't hit that "more focused in the morning" phase yet.


Tuesday, February 24, 2009


Inspiration can come from some pretty strange places. In this case it came from a Microsoft Developer Evangelist. The strange part of course was that it had nothing to do with software development.

Last Christmas Santa brought our family a Wii balance board. If you haven’t seen one, it is a pretty cool new input device. It is a flat board that sits on the floor, you stand on it and distribute your weight across four pads. Along with being able to weigh things, it allows you to use the balance of your body to play video games. The Balance board comes with a game called "Wii Fit" that is supposed to help you exercise.

I took it all casually at first, knowing that I needed more exercise, and willing to play games. The galvanizing moment came after an initial "weigh-in" when a sweet feminine computerized voice said to me…. "Ooooh that’s obese".

The next day I took the balance board back out of the trashcan and started in earnest to mend my ways. I didn’t really change my diet, beyond eating reasonably, and cutting out sweets and sodas. However over the next 6 weeks the moderate 30-40 min of workout was enabling consistent weight loss. More importantly I was feeling more fit and gaining noticeably more endurance and strength each day.

Then it happened:
A couple bad days at work…. My wife got sick….I cut the exercise out for lack of time.
The cycle was broken and all my old habits started creeping right back in. I was starting to put back on all the weight I had lost.

So how does the Microsoft Developer Evangelist fit in? A week ago today I was at a user group developer meeting. The topic was ASP.NET technologies. It was interesting, although I think it was the same slide deck that I saw the same guy present last fall at a roadshow.

What really caught my attention, was the side story that came up in the casual conversation. Here was someone that was that was going through the same issues that I was, and using the same methods to achieve his goals. It was actually a little spooky, right down to the core reason for taking care of myself. I don’t want to be dead before my kids grow up.

While I’m pretty sure that it is explicitly written somewhere in the Bible that it’s bad form to brag about what you are giving up for Lent, I will say this much, in the hope that it inspires someone else. Typically during lent, I have been cutting out caffeinated sodas. It can be a pretty painful withdraw if you are addicted. However, they aren’t really that good for you and you feel a lot better once the drug is out of your system. Unfortunately, I had already pretty much given soda up at the beginning of the year, and started drinking more plain water, and that habit stuck. Therefore, for lent I am going to pick back up my exercise routine among other things, and borrowing an idea from my new "evangelist" friend, starting tomorrow, and continuing at least until Easter, the alarm is going off at 5am. a.k.a …. 0 dark 30

Jim – was never scared of the dark


Monday, February 23, 2009

Put that tweet down on the TwitterDeck Captain!

It only takes a few minutes with the default twitter interface to realize that this beast can become completely and irrationally unmanageable pretty quick. I looked at several twitter clients and TweetDeck seems pretty good.

TweetDeck is an AIR based application. (That sounds impressive, but really it just means that there is another product, I have to go figure out a meaning for…)

The major difference between TweetDeck and other Twitter clients like Twhirl, Snitter, Twitteriffic, and AlertThingy, is that it displays more than one column of information at a time. In TweetDeck, you can define columns for your replies, numerous searches in Summize, as well as groups. You can define up to 10 different columns.


Sunday, February 22, 2009

I am not Spock! I am Spock.

Yes, I am Rachmeg. I think I created the online Avatar about 13 years ago when my second daughter was born. I don’t know why I thought putting two girls names together sounded like a tough medieval fighter, but at the time it worked. ( Rachmeg rhymes with Watch meg) Unfortunately as anyone knows, once you create an online persona, you can’t just go and change your name if you still want people to know who you are. From there, the name followed me across message boards and through online communities (some related to online gaming and others completely not.) I don’t expect that I will ever have the time to lead hundreds of people on dragon raids again, but I still feel the need to reach out to an online community. Hopefully, I can just change that focus to a different set of like-minded people. I now intend to use my blog space to start listing code examples and such that I may link to from outside, (as well as random personal commentary) Because of that, I’m going to switch to my more modern Avatar’s name. (Unless of course, I feel inspired to do otherwise) If anyone from the old days or from the “Nest” drops by – rest assured, I’m still around.

Jim – Because the trick is, realizing that there is no spoon.