Wednesday, October 3, 2012

TFS WebAccess Error: [HttpException (0x80004005): Unable to validate data

We were getting the following error while setting our TFS2010 Web access. Sharing the solution which worked for us, might be useful for you.

[HttpException (0x80004005): Unable to validate data

1. On App Tier server, goto C:\Program Files\Microsoft Team Foundation Server 2010\Application Tier\Web Access\Web.
    (Please make a copy of Web.config, just in case you need the original file later.)

2. Edit the Web.config file in notepad.
3. Search "machineKey" in Web.config file.
4. Replace the <machineKey> section with following.
<machineKey validationKey="AutoGenerate,IsolateApps" decryptionKey="AutoGenerate,IsolateApps" validation="3DES" decryption="3DES"/>
5. Save the Web.config file.
6. Restart the Microsoft Internet Information Services (IIS) service.

TFS Web Access Error: Microsoft.TeamFoundation.WebAccess.Common.dll was invalid

I was getting this error when setting up TFS 2010 web access. I searched a lot but didn't find any solution, finally after lot of R&D I was able to fix this issue.
I may be useful for others who face this error:

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.IO.FileLoadException: The given assembly name or codebase, 'C:\WINDOWS\assembly\GAC_MSIL\Microsoft.TeamFoundation.WebAccess.Common\\Microsoft.TeamFoundation.WebAccess.Common.dll', was invalid.

We get the following error due to IIS_IUSRS a/c is missing some group policies.
"'C:\Windows\assembly\GAC_MSIL\Microsoft.TeamFoundation.WebAccess.Common\\ Microsoft.TeamFoundation.WebAccess.Common.dll'
Here is what we need to do:
On App Tier->Start-Run- gpedit.msc -> Computer Configuration->Windows Setting->Security Setting->Local Policy->User Rights Assignment
Add the IIS_IUSRS a/c to the following policies:
    • Bypass Travers Checking
    • Impersonate a client after authentication
    • Log on as batch job
We were faced this issue two times in our differrent environment. And the above solution fixed it for both. So it's worth a try.

Thursday, October 13, 2011

How to get changeset information using TFS API?


using Microsoft.TeamFoundation.Client;
using Microsoft.TeamFoundation.Server;
using Microsoft.TeamFoundation.VersionControl.Client;

public void GetChangesetsInfo()
            TfsTeamProjectCollection proj_coll = new TfsTeamProjectCollection(new Uri("http://NvnTfsserver:8080/tfs/defaultcollection/"), new System.Net.NetworkCredential(username, password));

            VersionControlServer vcs = (VersionControlServer)proj_coll.GetService(typeof(VersionControlServer));

            //Following will get all changesets since 20 days. Note : "DateVersionSpec(DateTime.Now - TimeSpan.FromDays(20))"
            System.Collections.IEnumerable history = vcs.QueryHistory("$/Stakeholders Test Project", LatestVersionSpec.Instance, 0, RecursionType.Full, null, new DateVersionSpec(DateTime.Now - TimeSpan.FromDays(20)), LatestVersionSpec.Instance, Int32.MaxValue, false, false);

            foreach (Changeset changeset in history)
                Console.WriteLine("Changeset Id: " + changeset.ChangesetId);
                Console.WriteLine("Owner: " + changeset.Owner);
                Console.WriteLine("Date: " + changeset.CreationDate.ToString());
                Console.WriteLine("Comment: " + changeset.Comment);


Wednesday, October 12, 2011

How to get TFS Project groups and members information using TFS2010 APIs ?


using Microsoft.TeamFoundation.Client;
using Microsoft.TeamFoundation.Server;
using Microsoft.TeamFoundation.VersionControl.Client;

public void PrintTFSGroupMembersInfo()
            TfsTeamProjectCollection proj_coll = new TfsTeamProjectCollection(new Uri("http://NvnTFSServer:8080/tfs/defaultcollection/"), new System.Net.NetworkCredential(username, pass));

            VersionControlServer vcs = (VersionControlServer)proj_coll.GetService(typeof(VersionControlServer));
            TeamProject[] TPs = vcs.GetAllTeamProjects(false);

            IGroupSecurityService sec_groups = (IGroupSecurityService)proj_coll.GetService(typeof(IGroupSecurityService));

            foreach (TeamProject TP in TPs)
                Console.WriteLine("Team Project : " + TP.Name);
                Console.WriteLine("Group Members : ");

                Identity[] app_groups = sec_groups.ListApplicationGroups(TP.ArtifactUri.ToString());

                foreach (Identity app_grp in app_groups)
                    Identity grp = sec_groups.ReadIdentity(SearchFactor.Sid, app_grp.Sid, QueryMembership.Direct);

                    foreach (string members in grp.Members)
                        Identity member = sec_groups.ReadIdentity(SearchFactor.Sid, members, QueryMembership.Direct);

                        Console.WriteLine("     " + member.DisplayName);
                        foreach (string mm in member.Members)
                            Identity m = sec_groups.ReadIdentity(SearchFactor.Sid, mm, QueryMembership.Direct);

                            Console.WriteLine("         " + m.DisplayName);


Friday, September 9, 2011

TFS 2010 Training Kit Released

This is for all who are interested in learning TFS 2010. Microsoft has recently released the TFS 2010 Training Kit. You can download the TFS 2010 Training Kit by clicking on the link given below.  The training kit is very well designed, authored by Yuval Mazor and Asaf Stone. This training kit is really useful for all developers, testers, managers and all other in team.

This Training Kit contains several demos and hands-on labs that require some additional setup. For instructions, please see the Setup document.

Friday, August 19, 2011

How to get members list for a Team Project using TFS API?

Try the following code. Rember I have written it for TFS08, so there may be some functions don't work well for TFS2010.

public void printMemberList(string teamProject)
            TeamFoundationServer tfsServer = new TeamFoundationServer("TFS_Server_name");
            IGroupSecurityService sec = (IGroupSecurityService)tfsServer.GetService(typeof(IGroupSecurityService));

            VersionControlServer versionControl = (VersionControlServer)tfsServer.GetService(typeof(VersionControlServer));

            TeamProject tp = versionControl.GetTeamProject(teamProject);

            Identity[] appGroups = sec.ListApplicationGroups(tp.ArtifactUri.AbsoluteUri);

            foreach (Identity group in appGroups)

                Identity[] groupMembers = sec.ReadIdentities(SearchFactor.Sid, new string[] { group.Sid }, QueryMembership.Expanded);

                foreach (Identity member in groupMembers)


                    if (member.Members != null)
                        foreach (string memberSid in member.Members)
                            Identity memberInfo = sec.ReadIdentity(SearchFactor.Sid, memberSid, QueryMembership.None);

                            Console.WriteLine(member.DisplayName + "----" + memberInfo.DisplayName.ToString());





Version Control System - 10 Best Practices for Developers

“I have been working in Software Configuration Management area for almost last 5 years.  I have administrated some of the efficient Version Control Systems like “VSS, Dimensions, and TFS.” As a part my daily experience in this area, I have learned some best practices we should follow for a quality software development.
I have documented these best practices and sharing with you all. I hope you get something good out of it.”

Version Control Systems:  A Version Control System secures your artifacts, tracks the changes to the artifacts and provides you many features for a quality deliverable.  The Version Control System enables everyone in the team to work more efficiently in a collaborative way.
Version Control System is a common requirement in all modern software development projects. It not only provides a mechanism for checking in and out the source code from central repository but also it keeps track of which changes were made, who made those changes, when & why they were made. Modern Version Control Systems provide many more additional features like efficient branching & merging methods, builds features, testing & deployment features etc.
In order to be successful using a source code repository as part of the software development process, the development team must agree that they always refer Version Control Systems for using the artifacts. All developers must be in the habit of following all good practices when using a version control system.
Please refer the following best practices I have documented below:

Following are the best practices all developers should follow.
1.)  All developers must use Version Control as their source code repository.
All development teams must have an efficient Version Control System for securing their work. And the first step should be to add the source code to Version Control systems at the earliest. No member should be allowed to work offline of Version Control systems. All members should reference the code for Version Controls systems and make sure that the project is online.

2.)  Developers should not circumvent Version Control.
In order to modify any files, developers must check the files out from Version Control.
I have seen in practice that many developers avoid/skip using Version Control System for checking-out/checking-in the code. Many developers checkout the file but they don’t checkin the changes on regular basis, which is very bad approach. Consider an example, you checked out a file three days back and made lot of changes but you didn’t check the changes in and now unfortunately your machine gets crashed. What you will do? So get into the habit of always using Version Control for checking out the files and do the regular check-ins.

3.)  Developers should not change the attributes of files on their file system.
Developers should avoid changing attributes of files on their file systems because when they will check-in the changes, these changes will also be saved in Version Control. Changed attributes may behave differently for other developers, when they will use these files.

4.)  All code / executable should originate from Version Control and should be applied to development, test and production systems using automated methods.  Developers should not modify any of these systems manually.

5.)  Avoid checking-in the unsuccessful code.
Developers should not check in code that cannot be successfully compiled.  Doing so would break the scheduled build process and delay the development cycle. This can create problem for other Team, working parallel on the project. The best practice is always do a local build/compile your application before checking in and if the application builds successfully, then only check-in the changes to code repository.

6.)  Perform regular local & server builds.
Build is process of validating, compiling, testing & integrating your code as a complete solution. A build process makes sure your code is well integrated and working what you are aiming for.  Builds must be done on a regular basis. It’s always a good idea to have a dedicated team for build and successful build should be a top priority for them.
Make sure you regularly perform server builds additional to local builds. Server builds make sure that your application doesn’t have any local machine specific dependencies on code.
Implement efficient build plans for your application which should include Continuous Integration Builds, Scheduled Build and Ad-hoc builds.
Use efficient build tools. Many of the advanced build tools automatically fire a server build whenever you commit the changes to code called CI builds. It helps you in identifying early warning of broken/incompatible code.

7.)  Create a separate common folder for Dependencies.
If we are using any Third Party DLLs/Components, then we should have a common folder in Version Control (Ex. Dependencies or Library) and refer the components from there. I have seen many developers add shared components to all the projects and create different copies of same components, which is not at all a good practice. Instead, we can have a common folder for Shared/Third Party components and refer them.

8.)  Avoid storing Binaries in Version Control.
It’s a good practice to avoid adding binaries (like code generated files like .dlls, .pdb etc.) to Version Control, these eats a lot of space. Also these are not a source code, these are just generated binaries by our code, which we can do anytime, we just need to build our source once and we will have these.  So only add binaries, if it’s really needed for your project.
9.)  Don’t create unnecessary branches.
Before creating branches, pay attention – every branch you create does have a cost so make sure you get some value from it. More the branches you will have, more time/cost you will need to spend on Merge conflicts and additional testing. So only create the branches necessary for your development efforts.

10.)  Avoid changings source in Main line.
While creating directory structure in Version Control systems, make sure you have one main line/base line folder which stores your main code. You must avoid direct changes in this code. This main branch should be a stable snapshot of the product and it’s the latest working copy which can be shared with Customers, QA or external teams.
Always create needed branches, make the code changes are done in those branches and after the successful build merge the changes using proper Reverse & Forward Integration with Main line. In this way, we will make sure Main will always have a good/working code.

Monday, August 15, 2011

Service Management and ITIL

Service Management and ITIL
I have been working in Service area for 4+ years, so familiar with almost all the service related terms. Recently, I have cleared my ITIL foundation certification with 95% and now I am preparing for Intermediate certification.
I thought of sharing my knowledge on this subject to benefit some of the people who will come across this blog.
Here I am giving the definitions of some of the common terms/questions for those who are willing to know ITIL.
Ø  Service: Service is the means of providing value by facilitating the outcomes customer wants to achieve without the ownership of specific costs and risks.
Real life example:  A Restaurant delivering food to its customer, here delivering the food to customer is a “service” provided by Restaurant.  The outcome customer wants to achieve is nice food, Restaurant is facilitating the customer by preparing & serving food to its customer by owning all the processes and risks included in this. So Restaurant is providing a value to its customer in the mean of nice food and Customer is paying him the cost for that.
Ø  IT Service: IT Service is the means of providing value to customer using IT methodologies, tools, software etc.

Ø  Why does a customer want the service? Service Providers are specialized knowledge group who can facilitate the outcomes in an easy way.
Real life example: In the Restaurant example above, the Restaurant is preparing and providing food to its customer, so Restaurant is a Service Provider here. Why customers want to avail Restaurant service? Because Restaurant is expertize on preparing delicious food and customer can enjoy the delicious food any time with no extra efforts.
Similarly in IT, an expert IT company can design and offer some useful tools & techniques to its customer and provide them services for achieving the customer’s outcomes.
Ø  Service Management: Service Management is a set of specialized organizational capabilities for providing value to customer in the form of services.

Ø  IT Service Management: ITSM governs the IT Service department of an organization by defining several important processes, roles & responsibilities, management of third parties (external suppliers/partners) etc. to deliver and support quality IT Services that meet specific business needs and requirements.

Ø  Official ITIL definition of ITSM: “A set of specialized organizational capabilities for providing values to customers in the form of services.”

Ø  ITIL: ITIL is a framework that describes the best practices in IT service management. ITIL provides framework for the governance of IT and focus on continual measurement and improvements. Some of the ITIL benefits include,
·         Increased user and customer satisfaction with IT services.
·         Improved service availability, directly leading to increased business profits and revenue.
·         Financial saving from reduced rework.
·         Improved decision making and optimized risk.
Real Life Exmple: When you want to write a java program or a .net program, you refer the Java Reference Architecture or Class Libraries. These JRA or Class Libraries are well proven templates solution which facilitates you in implementing already proven functions and these align your program with standard. Similarly when you want to implement and effective Service Management in your work, you use Information Technology Infrastructure Library (ITIL). ITIL is set of proven best practices, which if implemented in our work, will help us in better service management and will keep our business as per current standard.
Ø  ITIL Versions:
·         ITIL initial version (1989 ~ 1995) was consisted of 31 associated books covering all aspects of IT service.
·         ITIL second version (2000 ~ 2004) was consisted of 7 more closely connected and consistent books. The 2nd version became universally accepted.
·         ITIL third version (2007) is consist of just 5 core books covering the service lifecycle.

Ø  Service Lifecycle as per ITIL: As per ITIL Framework, a Service has five stages in its lifecycle.
·         Service Strategy
·         Service Design
·         Service Transition
·         Service Operation
·         Continual Service Improvement

ITIL Processes and Functions:

Ø  Process: A Process is a set of coordinated activities combining and implementing resources and capabilities together to produce a desired outcome.
·         A process takes one or more inputs and through the activities performed termed them into defined output.
·         All processes should be measurable.

Ø  Function: A Team or group of people and the tools they use to carry out one or more processes or activities. Function provides units of organization for specific outcomes. IT Functions defines the different roles and responsibilities required for the overall design, delivery and management of IT Services.
Please refer the following figure for understanding of ITIL v3 Lifecycle, Processes and Functions.
There are total 24 Processes and 4 functions in ITIL v3.
Ø  ITIL Certification
There are four levels of qualifications within the scheme:
·         ITIL Foundation
·         ITIL Intermediate Level   
·         ITIL Expert Level
·         ITIL Master Qualification
The modular, tiered structure of the qualification not only offers candidates the flexibility in relating to the different disciplines and areas of ITIL, but generally makes ITIL qualifications more accessible and achievable.

For more information on how to plan for Certification, please go through the ITIL official website, link provide below.

Helpful Links:

Friday, August 12, 2011

How to compare two ChangeSets?

Here are the steps:
Before this, I assume you have latest files in your workspace otherwise do a get latest.
1. Open Source Control Explorer.
2. Right click on the Project folder level and click on Compare.
3. You will see the Compare window opens,  in Source Version, select Changeset from the dropdown.
4. Enter the previous Changeset number you want to compare with the latest code after build and click OK.
5. It will give you Folder Difference window, which will show you all the differences between previous changeset and latest files and you will know what all files are changed after last build.