EMIE
EMIE

Reputation: 117

C# Connecting to TFS and Checking Work Item Status

I'm trying to connect to TFS and check the status of a work item. However, every time I execute the code, I get the following error message:

An unhandled exception of type 'System.DllNotFoundException' occurred in Microsoft.TeamFoundation.WorkItemTracking.Client.DataStoreLoader.dll

Additional information: Unable to load DLL 'Microsoft.WITDataStore32.dll': The specified module could not be found. (Exception from HRESULT: 0x8007007E)

Occurs when code hits: WorkItemStore workItemStore = (WorkItemStore)tfs.GetService(typeof(WorkItemStore));

I have the following DLL referenced: - Microsoft.TeamFoundation.Client - Microsoft.TeamFoundation.WorkItemTracking.Client - Microsoft.TeamFoundation.WorkItemTracking.Client.DataStoreLoader

Here is my code.

    private static void connectToTfs(int executionType)
    {
        Console.WriteLine("Starting to work on TFS");

        // Supply the credentials of the user who will be impersonated to create the bug 
        ICredentials credentials = CredentialCache.DefaultNetworkCredentials;

        TfsTeamProjectCollection tfs =
            new TfsTeamProjectCollection(new Uri("http://URL:8080/Team"), credentials);

        if (tfs.HasAuthenticated == true)
        {
            Console.WriteLine("Connected to TFS");
            WorkItemStore workItemStore = (WorkItemStore)tfs.GetService(typeof(WorkItemStore));

            switch (executionType)
            {
                case 1:
                    //create query
                    string queryString = "Select [State] From WorkItems Where [ID] = '4123567' ";

                    //Dictionary for storing variables
                    Dictionary<string, string> variables = new Dictionary<string, string>();
                    variables.Add("ID", "State");

                    Query query = new Query(workItemStore, queryString, variables);
                    WorkItemCollection results = query.RunQuery();

                    foreach (KeyValuePair<string, string> kvp in variables)
                    {
                        Console.WriteLine("ID {0} state is {1}", kvp.Key, kvp.Value);
                    }

                    break;
             }
       }
    }

Upvotes: 0

Views: 822

Answers (1)

Jacob Seleznev
Jacob Seleznev

Reputation: 8131

This possibly has a workaround.

It suggested to manually locate the GAC32 version of Microsoft.WITDataStore rename it to Microsoft.WITDataStore32 and add to the bin folder of your project

Upvotes: 0

Related Questions