Current AppDomain’s Base Directory issue while running Unit Tests in VS2008

As I mentioned earlier, we are currently converting all the solutions of our application from Visual Studio 2005 to Visual Studio 2008. While converting solutions to VS2008 we faced some minor issues. One of them were related to Unit Test in VS2008 which I blogged earlier. The current issue also is related to Unit Test in Visual Studio 2008. Here’s the details –


Background & Issue:

 After converting a VS2005 solution to VS2008 solution all the unit test cases that reference current AppDomain’s Base Directory property (AppDomain.CurrentDomain.BaseDirectory) fails.



Cause of Issue:

 This happens as in Visual Studio 2008, while running under the context of Unit Test current AppDomain’s Base Directory property (AppDomain.CurrentDomain.BaseDirectory) points to Visual Studio 9.0 IDE directory (typically – C:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE\)



This behavior is different and incorrect in Visual Studio 2008 from Visual Studio 2005 and previous versions where current AppDomain’s Base Directory property would correctly points to Applications Base directory (if not set otherwise explicitly).



To fix to issue do the following steps –


  1. In the class of the test method where current AppDomain’s Base Directory property (AppDomain.CurrentDomain.BaseDirectory) is used, add a ClassInitialize method for the unit test.
  2. Add the following code in the ClassInitialize method to initialize the AppBase to Application’s Current Directory –


        public static void ClassInitialize(TestContext testContext)


            AppDomain.CurrentDomain.SetData("APPBASE", Environment.CurrentDirectory);



Now current AppDomain’s Base Directory property (AppDomain.CurrentDomain.BaseDirectory) even while running within the Unit Test context of VS2008 would refer to Application’s Current Directory –





Microsoft has recognized this as a bug in Visual Studio 2008. It’s possible that this behavior may change back to original behavior as in 2005, however if this was to happen it would not be done until SP1 for Orcas 2008 and no time frame on SP1.

Live Mesh – /

Those who has heard Ray Ozzie’s ( keynote in MIX 2008 ( Mesh is a familiar word. In fact there are blogs in net counting how many times he pronounced mesh – social mesh, device mesh, seamless mess J.


Hearing his keynote gave me a brief, sketchy idea of what he meant and what is Microsoft’s plan on a longer term. Now Microsoft has announced that it’s going to release the Community Preview of LiveMesh ( or soon. The LiveMesh team’s blog ( provides links to lot of resources like Videos and docs.

Here’re some of them –


Ray Ozzie: Introducing Live Mesh

Meet the Live Mesh Team


Abolade Gbadegesin: Live Mesh Architecture

Ori Amiga: Programming the Mesh

Hands on with Live Mesh
Mesh WhitePaper –

Architecture Journal – Role of an Architect

This month’s Architecture Journal discusses the role of Architect. The articles are an excellent thought provider for any architect.

Journal 15 –

Download in PDF –


Journal 15: The Role of an Architect

·         Foreword

·         We Don’t Need No Architects

·         Becoming an Architect in a System Integrator

·         Architecture Journal Profile: Paul Preiss

·         The Open Group’s Architect Certification Programs

·         The Need for an Architectural Body of Knowledge

·         A Study of Architect Roles by IASA Sweden

·         The Softer Side of the Architect

·         An A-Z Guide to Being an Architect

Haskell – A Pure Functional Programming Language

As I mentioned earlier I got interested in Functional Programming recently. Lately there has been lot of interest among developers and programmers on functional programming. Imperative Languages like C# and VB.NET have started introducing concepts from functional programming world like Generics, Lambda Expression, Anonymous Method, Variable Type Inference etc.

My interest behind Functional programming is not because I want to leave Imperative Programming Languages completely and start working with only Functional and Dynamic Languages. My approach is taking best of the both worlds as I believe old concepts like Object Oriented Design and Component Based Design are also very helpful.

I got interested in Functional Programming by watching lot of videos in Channel9 on Functional and dynamic languages. In these videos Microsoft Programming gurus like Erik Meijer and Brian Beckman explains functional programming very well and these videos helped me grasp some of the concepts like Side Effect and Monad effectively. Here’re links to some of the videos –

Erick Meijer was one of the designers of Haskell programming language. Currently he is working on Volta project in Microsoft –

Haskell is a pure functional programming language. Functional Programming is all about functions. In Imperative Programming also we use functions. But as Functional programming is based on Lambda Calculus everything can be represented with functions. In Pure Function Programming Languages there would be no side effect, no mutable identifiers.

Haskell, like most other languages, comes in two flavors: batch oriented (compiler) and interactive (interpreter). An interactive system gives you a command line where you can experiment and evaluate expressions directly, and is probably a good choice to start with.


Compiler and interpreter (GHCi)

Probably the most feature-complete system


Interpreter only

Very portable, and more lightweight than GHC.

While both GHC and Hugs work on Windows, Hugs has perhaps the best integration on that platform. Nonetheless, GHC is more actively developed and maintained, and the consensus seems to be that it is the generally-recommended environment of choice for newcomers to Haskell as well as old hands.

GHC stands for Glasgow Haskell Compiler. GHC is a state-of-the-art, open source, compiler and interactive environment for the functional language Haskell. To know more about GHC please go to –








Installs the following items in menu –



GHCi stands for Haskell interactive or Glasgow Haskell Compiler Interactive.  Selecting it opens the Haskell interactive similar to Ruby or Python Interactive …



Here’s the first “Hello World” app in Haskell –



Notice that Haskell is more intelligent and dynamic than Ruby & Python from the perspective that 3/2 in Haskell returns 1.5 not 1 as in Ruby and Python. PowerShell also is smart enough so 3/2 in PoweShell also returns 1.5 not 1 like Python and Ruby.

Code Analysis Error in VS2008 (related to FxCop)

Currently we are converting all the solutions of our application from Visual Studio 2005 to Visual Studio 2008. While converting solutions to VS2008 we faced a minor issue. We use VSTS Static Code Analysis for all our projects. After converting the solutions, some of the solutions throws an error if Code Analysis is turned on. Apparently it tries to use FxCop instead of VSTS for Static Code Analysis. Here’ re the details –

Background & Issue:
After converting a VS2005 solution to VS2008 solution sometime while compiling the solution we receive the following Code Analysis error –

MSBUILD : error : Invalid settings passed to CodeAnalysis task. See output window for details.

Code Analysis Complete — 1 error(s), 0 warning(s)
Done building project "Contact.csproj" — FAILED.

========== Rebuild All: 0 succeeded, 1 failed, 0 skipped ==========

The output windows shows the following details –

Compile complete — 0 errors, 0 warnings

Contact -> C:\Test\Dev\RRDevelopment\Development\GE\Contact\bin\Debug\tgtpharm.Modules.Contact.dll

Running Code Analysis…

c:\Program Files\Microsoft Visual Studio 9.0\Team Tools\Static Analysis Tools\FxCop\FxCopCmd.exe  /outputCulture:1033 /out:"bin\Debug\tgtpharm.Modules.Contact.dll.
CodeAnalysisLog.xml" /file:"bin\Debug\tgtpharm.Modules.Contact.dll" /directory:"..\..\Shared Assemblies\Pharmacy Shared Assemblies\Common.Validation" /directory:"..\..\Shared Assemblies\Pharmacy Shared Assemblies\Common.DataAccess" /directory:"..\..\Shared Assemblies\Pharmacy Shared Assemblies\Common.ReferenceData" /directory:"..\..\Shared Assemblies\Pharmacy Shared Assemblies\DomainModel" /directory:"..\..\Shared Assemblies\Third Party\Enterprise Libraries 2.0" /directory:"C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727" /directory:"C:\Program Files\Reference Assemblies\Microsoft\Framework\v3.0" /directory:"C:\Program Files\Reference Assemblies\Microsoft\Framework\v3.5" /directory:"..\..\Shared Assemblies\Third Party\AzMan" /directory:"..\..\Shared Assemblies\Pharmacy Shared Assemblies\Common" /rule:"c:\Program Files\Microsoft Visual Studio 9.0\Team Tools\Static Analysis Tools\FxCop\Rules" /ruleid:-Microsoft.Design#CA2210 /ruleid:-Microsoft.Design#CA1005 /ruleid:-Microsoft.Design#CA1032 /ruleid:-Microsoft.Design#CA1014 /ruleid:-Microsoft.Maintainability#CA1502 /ruleid:-Microsoft.Mobility#CA1600 /ruleid:-Microsoft.Mobility#CA1601 /ruleid:-Design Rules#RR1001 /ruleid:-Microsoft.Usage#CA2209 /searchgac /ignoreinvalidtargets /forceoutput /successfile
/ignoregeneratedcode /saveMessagesToReport:Active /timeout:120

Cause of Issue:
The issue happened as Visual Studio was calling FxCop from the "Visual Studio 8" directory instead of "Visual Studio 9.0". Visual Studio should use "Visual Studio 9.0" for performing the Static code analysis tasks instead of using FxCop external tool (this would be evident from the error as the error shows that Visual Studio us calling FxCopCmd.exe tool instead of Visual Studio 9.0)

To fix to issue create an environment variable called "FXCOPDIR" to point to the 2008 instance of Visual Studio.

  1. In Control Panel, open System. The System Properties dialog box appears.
  2. Click the Advanced tab, and then click Environment Variables. The Environment Variables dialog box appears.
  3. Under System variables, click New. The New System Variable dialog box appears.
  4. In the Variable name box, type FxCopDir.
  5. In the Variable value box, enter the location where the Visual Studio 9.0 IDE or devenv is located (typically it’s located at – C:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE\devenv.exe), and then click OK.
  6. Restart the Visual Studio 9.0 IDE and compile the project once again. This time the project should compile successfully.



F# – a test of functional programming

Recently I have started learning about dynamic programming languages and functional programming. I chose two languages to learn dynamic programming – Ruby and Python. While dynamic programming is not completely new to me, as I have developed apps on JavaScript and VB, but I was not aware of the fundamentals of dynamic programming at that point of time. But I would admit that learning and playing with Ruby and Python have been a fun.

On the other hand functional programming is a complete new thing for me. I have always coded and developed solutions and applications using static languages like C#, C++, Java and VB.NET. Though lately C#, specially in C# 3.0 there have been lot of inclusion of functional programming. Recently I planned to learn F# which is a pure functional programming language developed by MS Research. I downloaded F# from the MS Research site ( and the installation experience was all smooth.

Before sharing the installation experience here’re couple of links for functional programming and F# –

I installed the Jan 23, 2008 release of F# (Version from the following URL –  

Clicking the Run button displays the welcome screen of the install wizard

Clicking the next button as usual displays the EULA page of the wizard.

After accepting the EULA, the select destination folder page of the wizard is shown. I kept the default which is C:\Program Files\FSharp-\. The installation requires Admin Rights, so the UAC dialog is shown in Vista.
(Notes: This is not required for installing Python & Ruby).
Once the installation is complete the finish page of the wizard is shown.

Once the installation is done, it adds new menus is Start menu

Here’s the first program that i wrote in F# Interactive (FSI) console –

Windows Server 2008 – Server Role (Component Based Architecture)

Windows Server 2008 manages its features by role – Server Role. While discussing Windows Server 2008, you would find that the term “Server Role” is used frequently.

A server role (or simply role) is a specific function that your server performs on your network. Examples of roles you can deploy on Windows Server 2008 include File Server, Print Services, Terminal Services, and so on. Many of these roles will be familiar to administrators who work with Windows Server 2003 R2, but a few are new—such as Windows Deployment Services (WDS) and Network Policy and Access Services (NAP/NPS).

Server Roles brings the component based architecture to Windows Server 2008. It does not mean that it previous versions of Windows was not following component based architecture, but in Windows Server 2008 it’s prevalent throughout.

Most server roles are supported by one or more role services, which provide different kinds of functionality to that role. A good example here is the File Server role, which is supported by the following role services:

  • Distributed File System (DFS)
  • File Server Resource Manager (FSRM)
  • Services for Network File System (NFS)
  • Single Instance Store (SIS)
  • Windows Search Service
  • Windows Server 2003 File Services

Once you login to the Windows Server 2008 machine, the most important utility for an administrator or IT Pro is Server Manager is the Server Manager. It’s similar to “Computer Management” utility of XP/Vista. Infact lots of people describe Server Manager as Computer Management on steroids,” as it can do everything compmgmt.msc can do plus a whole lot more. It is the central admin utility and can perform almost all the tasks. Because it’s so powerful and one-stop location to do everything it’s available in the main menu in Windows Server 2008.


Following is the screenshot of Server Manager when you first open it.

Note that Server Manager uses the MMC or Microsoft Management Console tool. The default home page shows a summary/overview of the server.


Clicking on the Roles node on the left side hierarchy/tree view displays the Roles available or installed on the server. As you can see this particular server in the example only has the Web Server (IIS) installed. So it’s displaying – 1 if 16 (roles) installed. We can add or remove roles by clicking on the Add Roles or Remove Roles link.


Note that the services related to the Roles are also displayed. So in this case the services related to Web Server or IIS is shown –


Note that this is the same set of components that is installed while installing IIS7. I have discussed it in my previous blog on IIS7.

Now to add a new Server Role, let’s click on the Add Roles link, which displays the “Add Roles” wizard.


Select the Roles you want to add. In this example I have selected the File Services, Print Services and Application Server.


Note that the wizard provides basic validation. For example if DHCP Server or DNS Server option is selected for a server without Static IP address, it displays a warning dialog box –


Selecting next creates more pages in the wizards depending on the roles you have chosen. Since I have chosen File Service, Print Service and Application Server Service those pages are added to wizard.





Once the install button in the confirmation page of the wizard is clicked it’s start installation –

The progress is displayed to the user –


Once the installation is successful the results are displayed to the user –


Now the Roles Summary part of the Roles page in Server Manager applet displays – 4 of 16 installed (as we added 3 new roles). The navigation/tree view windows on the left side also show 4 roles.


Clicking on the Services on the tree view on the left shows the Service home page –


To install more roles, click on the Add Role Services link. This brings up the Add Role Services wizard. I selected the LPD Service which allows Unix machines use the printer or print services. Selecting Next displays the similar Confirmation, Progress and Results page of the wizard that we have shown before.