protected TestManagementService GetMtmServiceInstance(out TfsTeamProjectCollection tfsTeamProjectCollection)
        {
            //Instantiate the connection to MTM
            //Configure the network credentials - used for accessing the MsTfs API
            //If we have a domain provided, use a NetworkCredential, otherwise use a TFS credential
            //TODO: Migrate code to VS2012 and add support for TfsClientCredentials
            ICredentials      tfsCredential     = null;
            NetworkCredential networkCredential = null;

            /*
             * TfsClientCredentials tfsCredential = null;
             * if (String.IsNullOrWhiteSpace(this.txtDomain.Text))
             * {
             *  SimpleWebTokenCredential simpleWebTokenCredential = new SimpleWebTokenCredential(this.externalLogin, this.externalPassword);
             *  tfsCredential = new TfsClientCredentials(simpleWebTokenCredential);
             *  tfsCredential.AllowInteractive = false;
             * }
             * else
             * {*/
            //Windows credentials
            networkCredential = new NetworkCredential(this.txtLogin.Text.Trim(), this.txtPassword.Text.Trim(), this.txtDomain.Text.Trim());
            /*}*/

            //Create a new TFS 2012 project collection instance and WorkItemStore instance
            //This requires that the URI includes the collection name not just the server name
            Uri tfsUri = new Uri(this.txtServer.Text.Trim());

            if (tfsCredential == null)
            {
                tfsTeamProjectCollection = new TfsTeamProjectCollection(tfsUri, networkCredential);
            }
            else
            {
                tfsTeamProjectCollection = new TfsTeamProjectCollection(tfsUri, tfsCredential);
            }

            try
            {
                //Now try authenticating
                try
                {
                    tfsTeamProjectCollection.Authenticate();
                }
                catch (Exception exception)
                {
                    MessageBox.Show("That domain/login/password combination was not valid for the instance of MTM:" + exception.Message, "Authentication Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    return(null);
                }

                //Get access to the work item and test manager server services
                WorkItemServer        workItemServer        = tfsTeamProjectCollection.GetService <WorkItemServer>();
                TestManagementService testManagementService = tfsTeamProjectCollection.GetService <TestManagementService>();

                //Make sure Team Manager is a supported feature
                if (!testManagementService.IsSupported())
                {
                    MessageBox.Show("This instance of TFS does not support Microsoft Test Management Services!", "Connection Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    return(null);
                }
                return(testManagementService);
            }
            catch (Exception exception)
            {
                MessageBox.Show("Error Logging in to MTM: " + exception.Message, "Connection Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return(null);
            }
        }