# Saturday, August 20, 2005

The GAC -- Global Assembly Cache -- is a popular topic among managed code developers. It serves two main purposes: (A) as a catalogue of the globally publicly available assemblies available on the system, indexed by strong name, and (B) the location of those same files. It is not my intent to describe the GAC, however; look here for more info. My intent is to describe some interesting changes that have been made to the GAC for Whidbey and to promote some good practices. This is part I and is dedicated to processor architecture; we'll see how far we get with the series ;)

Whidbey is the first CLR release in which we support 64-bit execution. The CLR team has been working on porting the CLR to 64-bit for several years now and is now releasing it to the world with Whidbey. Woohoo! Not surprisingly, 64-bit has required a lot of changes all over the CLR, as it imports a bunch of new concepts onto us. My favourite is the general concept of processor architecture, of which there are four that we now support: X86, X64, IA64 and MSIL. We always supported the first and the last, but there was never a strong reason to differentiate them considerably as we only ran on a 32-bit system.

With respect to the v1.x GAC (v1.0 and Everett share the same GAC), you can see pretty clearly that processor architecture was not a design point.

V1.x GAC location
C:\Windows\assembly\GAC

V1.x System.dll location
C:\WINDOWS\assembly\GAC\System\1.0.5000.0__b77a5c561934e089\System.dll

Where would you have tagged the processor architecture? Nowhere that I can see. As a result, we changed the GAC structure in Whidbey to accommodate processor architecture, which is now an incredible important aspect of the GAC.

V2.0 GAC locations on an x86 machine
C:\Windows\assembly\GAC_MSIL
C:\Windows\assembly\GAC_32

V2.0 System.dll and mscorlib.dll locations on an x86 machine
C:\WINDOWS\assembly\GAC_MSIL\System\2.0.0.0__b77a5c561934e089\System.dll
C:\WINDOWS\assembly\GAC_32\mscorlib\2.0.0.0__b77a5c561934e089\mscorlib.dll

V2.0 GAC locations on an x64 or IA64 machine
C:\Windows\assembly\GAC_MSIL
C:\Windows\assembly\GAC_32
C:\Windows\assembly\GAC_64

V2.0 System.dll and mscorlib.dll locations on an x64 machine
C:\WINDOWS\assembly\GAC_MSIL\System\2.0.0.0__b77a5c561934e089\System.dll
C:\WINDOWS\assembly\GAC_32\mscorlib\2.0.0.0__b77a5c561934e089\mscorlib.dll
C:\WINDOWS\assembly\GAC_64\mscorlib\2.0.0.0__b77a5c561934e089\mscorlib.dll

You can now see that it is easy to tag assemblies with processor architecture. We’ve created three GACs to do just that! As you can see, the GAC_64 directory only shows up on 64-bit machines, which is hopefully quite intuitive.

I’ve run out of time to get any further in this post, but hopefully it gives you a good idea of how and why the GAC changed, at least with respect to processor architecture in Whidbey. I also hope I left you with the opinion that these changes were a good idea ;)

A question to ponder: If you call System.Reflection.Assembly.Load(“System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089”) and there is both a copy in the bit-specific GAC and another in the bit-agnostic (MSIL) GAC, which do you get?

Saturday, August 20, 2005 6:02:47 AM (GMT Daylight Time, UTC+01:00)  #    Disclaimer  |  Comments [5]  | 
# Tuesday, August 16, 2005

I was recently reading the "remarks" section for the AppDomain.Unload() method @ http://msdn.microsoft.com/library/en-us/cpref/html/frlrfSystemAppDomainClassUnloadTopic.asp. I was doing a review of the documenation available to determine if we needed more around the CannotUnloadAppDomainException exception. I decided that we were in an OK spot for the most part, but that I would post a little more information on this exception for the small percentage of .NET programmers out there who need it. At least, I certainly hope that most .NET programmers don't need this information ;)

Note: Please mail me if this information proves particularly useful for you -- I'd like to better understand your scenario.

Upon calling the AppDomain.Unload() method, the CLR will request that all threads in the unloading domain abort. Threads do not abort instantly, so getting n threads to abort will take some time. As a result, the CLR checks after 10ms* to determine if there are any threads still running. If there are not any threads still running, then the CLR will proceed with domain shutdown. If there are threads still running, then the CLR repeats this process -- wait 10ms and check -- up to 1000* times. In the general case, it is very unlikely to need to repeat this process 1000 times (or anything close to it); eventually, all threads will be aborted and domain shutdown will occur. The purpose of this repeating "wait and see" behaviour is to avoid a deadlock due to a thread that will not abort for some reason.

If the 1000th check fails, meaning that threads are still running (not yet aborted), the CLR will throw a "CannotUnloadAppDomainException" exception. If the application, after the exception has been thrown, can do something to prevent this situation from occuring again (i.e. cleanup or manually aborting threads) then the application should perform that cleanup and call AppDomain.Unload() again. It is not expected, however, that the app should attempt to try repeat this process -- catching the "CannotUnloadAppdomainException" exception and calling AppDomain.Unload() -- an indeterminant number of times until it "works". The best approach is to remove the case where the exception is thrown at all, which means ensuring that all threads in a domain can be aborted in a timely manner. If the application, after the exception has been thrown, cannot do anything to prevent this situation from occuring again, it should not call AppDomain.Unload() again, but terminate the application or leak the domain.

* please consider these numbers (10ms and 1000 times) as implementation details. You absolutely should not take a dependency on them, for two reasons: (A) they are subject to change in a later release w/o notice, and (B) the number of running threads, processes and CPUs (+ multi-core) can very significantly change the time it takes to hit the 1000th iteration of the check due to the amount of CPU time that the unload check is given.

Tuesday, August 16, 2005 3:03:38 PM (GMT Daylight Time, UTC+01:00)  #    Disclaimer  |  Comments [1]  | 
# Wednesday, July 20, 2005

After logging in, be sure to visit all the options under Configuration in the Admin Menu Bar above. There are 26 themes to choose from, and you can also create your own.

 

Wednesday, July 20, 2005 8:00:00 AM (GMT Daylight Time, UTC+01:00)  #    Disclaimer  |  Comments [0]  | 
# Friday, May 27, 2005

Our Product Unit Manager is hiring! Jason's post is about interns, but he has a link to regular jobs too at the end of the post. The CLR team is the best team that I've worked for at Microsoft. If you want proof, read this blog entry.

We are currently closing up Whidbey and doing some initial planning for Orcas. By the time you get here, we'll likely be prototyping ideas for Orcas. In fact, I have an executive review in just over a week with Jim Allchin on the managed code versioning work we are planning for Orcas. We'll see what he thinks. If you join the team, you'll find out ;)

Friday, May 27, 2005 4:23:16 AM (GMT Daylight Time, UTC+01:00)  #    Disclaimer  |  Comments [0]  | 
# Wednesday, May 25, 2005

Yes. Please send mail to netfxcmp@microsoft.com to get signed up for this free program.

We're trying to do the right thing and get as many apps/controls/add-ins as possible to ensure that Whidbey is a compatible release. We have a bunch of apps already in our lab and have tested them extensively looking for any compatibility issues. We use these applications to establish a baseline of behavior and we’d like to add your app to the mix to ensure we haven’t missed anything. If we add your application to our appcompat tests, we are not just going to use them for testing compatibility with .NetFX 2.0, but we’ll add them to our regression suites and test them against the SP’s and future FX releases as well.

Take a read at this eWeek article, just published today. The article is a little dire in spots (including the title), but the basic idea is that we have a compatibility program and are ramping it up before we ship, now that the product is stabalizing in preparation for shipping. Most apps do "just work".

This blog, a dasBlog blog, is an example of "just works" on Whidbey. The dasBlog blog engine is an Everett ASP.Net web app, written for the 32-bit Everett (v1.1) CLR. My instance of dasBlog is running on top of the 64-bit Whidbey (v2.0) Beta 2 CLR. It "just works", as you can see.

Please do send in your app to add it to our mix of apps tested in our compat lab. You can also do compatibility testing yourself. See the Compatibility Testing Scenarios doc on MSDN for detailed instructions on how to do your own compatibility testing.

Here is a blog entry from JasonZ, our Product Unit Manager, on your compat and project upgrade experience. And an MSDN article on Whidbey compatibility. I encourage you to read these articles.

Caveat: This "free program" isn't long-term. We need a bunch more apps in the short term to beef up the sample size of apps in our compat lab. At the point we believe we have enough apps in our lab, we'll no longer need this program.

Wednesday, May 25, 2005 8:06:39 PM (GMT Daylight Time, UTC+01:00)  #    Disclaimer  |  Comments [2]  | 
# Tuesday, May 24, 2005

I need to post on the assembly version number for Whidbey again, for two reasons: (A) I never posted what it actually was, and (B) I posted some inaccurate data that I'd like to correct.

(A) is easy. The assembly version number for Beta 2 and RTM is: 2.0.0.0. This may seem to make sense for a version number, however for Everett it was 1.0.5000.0 -- not sure why that was chosen. 

(B) is slightly more complicated. I said in an earlier post that apps built on top of Whidbey Beta 1 (or earlier) would need to be recompiled. That is not true. They will work fine on Whidbey RTM without re-compilation. What will not work is Whidbey RTM apps running on the Whidbey beta 1 runtime -- which is presumably not a scenario for anyone.

(B) is true due to framework unification, which only applies to .NET Framework assemblies (i.e. System.Web.dll). The assembly binder basically does a quick test to determine if the version of a framework assembly is higher or lower than the one that ships with a given runtime -- meaning the runtime currently being run in the process. If it is higher, the load is rejected; if it is lower or equal, the referenced version number is ignored and the version that shipped with that runtime is loaded instead. We go through this algorithm to prevent Everett System.Web.dll running on Whidbey with Whidbey System.dll. Those configurations are not supported, so we prevent them from occuring.

Tuesday, May 24, 2005 12:05:18 AM (GMT Daylight Time, UTC+01:00)  #    Disclaimer  |  Comments [0]  | 
# Saturday, May 21, 2005

I watch the traffic that goes through my blog. Dasblog, the blogging software, lists the search terms and the search engine of the hits that come through a search engine. As an aside, 100% (at least lately) of the searches come from google.

One of the searches from today was exactly the title of this post -- can you use a library compiled against v1.1 in v2.0 of .net. The answer is absolutely "yes" and migrating to Whidbey (either v1.x source or binaries) is a completely supported and encouraged activity. If you have any (I mean "any") problems with your migration process, please drop me a line @ rlander@microsoft.com. I know all the right people to talk to and can get you an answer back quickly.

Here is the search URL for that query (yes, it came from google UK):

http://www.google.co.uk/search?hl=en&q=can+you+use+a+library+compiled+against+v1.1+in+v2.0+of+.net&btnG=Google+Search&meta=

I'm a little short on time at the moment. In a later post, hopefully tomorrow, I'll explain how to move your app to Whidbey from a CLR binding standpoint. This is an easy process and takes only a couple minutes. You may want to do this for testing or to port your app to Whidbey now that we have a "go live" license for Beta 2. See this earlier post for more info.

I will state up front that there are known issues with asp.net source migration. The goal for Whidbey (v2.0) RTM is that the use of the migration wizard plus manual tweaking for a significant site should be on the order of hours (as opposed to days or weeks). We're thinking around a morning or an afternoon.  Binary migration (for all v1.x code -- not just asp.net) should "just work". As I said earlier, please mail me if your mileage varies.

I have heard this question before. Hopefully this post helps get the answer out there in a more broad manner.

Saturday, May 21, 2005 8:33:24 PM (GMT Daylight Time, UTC+01:00)  #    Disclaimer  |  Comments [0]  | 
# Friday, May 20, 2005

Claudio, Mike and I had a great week in Phoenix. We definitely noticed the change in temperature from what we're used to in Redmond. The hottest day was about 40C/104F. And this is referred to as "cool" by the weather man here! Hate to experience "hot", which apparently starts at around 115F and heads up to 125F. Ouch! If I was here then, I'd end up in the hospital. Although, now that we're heading back to Redmond, we'll miss the warmth of the Arizona climate since we're likely headed to much cooler temperatures and a bit of a tropical storm. From talking to Annie, my wife, during our trip, I've been hearing about all of the rain that we've been missing.

I'd like to thank Tim Heuer, the Developer Evangelist for the SouthWest region, for organizing our trip. He worked for a number of weeks before we arrived with a number of customers to develop a jam-packed schedule for us. We met with 2-3 customers per day and then had dinners at night with Microsoft partners and the local .NET user group. This resulted in 13 hour days on average. Must sleep now.

We took the time out to travel to Phoenix with three goals: (a) get feedback from our customers on their use (i.e. challenges and wins) of the .NET Framework, (b) provide customers with access to CLR experts to address their questions, and (c) ask customers for their apps and/or unit tests for use in our compatibility lab (more on this later).

We left Phoenix feeling quite happy with achieving our goals. We took a lot of notes and are going to use those in our planning for the next version of the .NET Framework (v3.0). We are almost done working on Whidbey (v2.0) and are starting to move the Program Management team (i.e. Claudio, Mike and me) to writing high-level specs on v3 features. For example, I'm doing a lot of work on managed code versioning. In terms of providing customers with access to CLR experts, I was very stoked about getting Scott Guthrie to meet with one lucky customer. This only worked out due to Scott being in town for just over 24 hours to speak at the Beta Days conference (where I am now) on Thursday. Scott didn't even break a sweat explaining how to best use certain aspects of ASP.Net. The customer quesions varried quite a bit but were more focussed on the use of viewstate. He also spent some time describing the new features in ASP.Net v2. One of the developers had this look in his eyes like he wasn't planning to go to bed that night, but migrating his company's website to v2 in order to get access to the new features!

Many customers were very excited about Visual Studio 2005 Team System. Claudio did an awesome demo of the CLR profiler built into the team system. I hadn't seen that before either and was quite impressed too. I can see using the profiler on the ASP.Net site that I'm currently building. I'm sure that I'm using much more memory than I need to be. There are many other new features in VSTS that customers are dying to start using, including load testing, code defect tracking, source control (not VSS), and FXCop. If you are in the South-West area, please contact Tim Heuer if you'd like a demo of VS 2005 (or any other developer technology).

I'd like to take a moment to address compatability. You've probably seen that as a recurring theme in my blog entries -- and this blog is supposed to be about the CLR loader ;). We made an offer to all of the customers that we met that I'd like to offer more generally. I haven't asked if this is OK to offer to the whole Web, but I'll do it anyway ;). We are very serious about backwards compatibility. We have a compatibility lab on the CLR team, in which we test v1.x apps on the v2.0 .NET Framework. Just to be super clear, we are testing the binary backwards compatibility of Whidbey. If an app fails to work/behave as expected, we determine why and then fix the problem in the v2.0 .NET Framework before it ships. We need more applications in the compatibility lab in order to have a better sample size of apps relative to the universe of managed apps out there in the wild. Ideally, we would have more apps that we can test and that they were very varried in terms of: internal business apps versus boxed apps, data components versus visual controls, ASP.Net versus Windows Forms, Windows Services versus Web Services, simple apps versus complex apps, database-oriented versus XML-oriented, natural language-specific (i.e. English) versus localized (i.e. Chinese, Hebrew, French), VB.Net versus Cobol, data-heavy (megs and megs of data in memory) versus CPU-bound. Hopefully you get the idea since I cannot think of any other axis of programs. Anyway, if you'd like to submit your apps or some part thereof, we'd love to talk. Unit tests are also great. We'll test the app until we ship Whidbey and then continue to ship it in the future to ensure that we don't break v1.x compatibility. In future, we'll look for v2.0 apps in addition to v1.x, ensuring that we don't break v2 compatibility on the v3 CLR.

Anyway, we had a great time in Phoenix. Turned out that our flight is delayed by 1 hour, but that's OK. This way we get to watch the sun go down in Phoenix. Quite fitting for the end of a great trip.

Just got home. It is is 1AM now. It is raining and 11C/51F. Just a minor change from Phoenix ;)   Definitely found out that flying -- landing in particular -- with a head-cold is not recommended. I still cannot hear anything, but fortunately my ears have stopped hurting. 

Friday, May 20, 2005 9:01:40 AM (GMT Daylight Time, UTC+01:00)  #    Disclaimer  |  Comments [0]  | 
# Thursday, May 19, 2005

Some time ago, I moved my blog to a 64-bit X64 server. This server was running Windows Server 2003 SP1 Beta 1 and an early version of Whidbey Beta 2. I thought that this was an excellent opportunity to dogfood (MS term for early adoption) the 64-bit version of the framework, not to mention Server 2003 SP1. Another side aspect of this exercise was that I was testing out the backwards compatibility of the .NET Framework, since DasBlog is built with the v1.1 version of the Framework.

I'm happy to report that I've had zero problems with this new configuration, even with beta software. The OS has now shipped, so there is no issue there, but the version of Whidbey is still only Beta 2 and it is chugging day after day without issue. Doesn't get better than that! It also shows the incredible value of MSIL -- what C#, VB.Net, Eiffel, IronPython, Cobol and any other managed code compiler compiles down to -- given that the Everett DasBlog code "just works" on 64-bit Whidbey, even though 64-bit was not a supported (or possible) configuration of Everett.

One of the major features of Whidbey ASP.Net is XHTML compliance. DasBlog was not designed to be 100% XHTML compliant, so would not work on the first try on Whidbey. We had to use a special config switch to turn off XHTML compliance in Whidbey. After that, everything worked perfectly, in terms of performance, backwards compatibility and general behaviour of the app. I'm very happy and can say that Whidbey Beta 2 is ready for prime-time development. To that end, the .NET Framework is allowing companies to "go live" with our "go live" license. This means that you can build/migrate a public-facing application with Whidbey Beta 2.

Back to 64-bit ... I must say that the 64-bit support in Whidbey is very cool. I have two high-end X64 boxes in my office, one from Intel and the other from AMD. I use them for various purposes and am quite happy with them. In particular, I really like building and debugging apps on my 64-bit machines, having them run in native 64-bit, but then being able to deploy them to both 32- and 64-bit machines. The portability of managed code assemblies across different CPU architectures (IA64, X64, X86) is a huge win.

I've also been running early 64-bit versions of Longhorn on these two X64 machines. I haven't done any tests using >2GB of virtual address space, but I would like to see a managed app that does that, taking full advantage of the 64-bit address space. I can imagine that companies running SQL Server will immediately see the benefit of that removed barrier.

Thursday, May 19, 2005 8:35:01 PM (GMT Daylight Time, UTC+01:00)  #    Disclaimer  |  Comments [0]  |