Unanswered Getting exceptions when trying to get Work Items and Work Item Stores

  • Wednesday, April 04, 2012 1:35 PM
     
      Has Code

    I have written a tool that will report on the Changesets and Work Items included in builds. When I run this tool on my local machine that has TFS 2010 installed, it works fine, however when I run the tool on a machine that is on our domain but does not have TFS installed, I get exceptions when the tool tries to get Work Items or Work Item Stores.

    Initially, my tool selects the builds between selected dates, and for each build it will get the details for the associated changesets

    Changeset changeSet = versionControl.GetChangeset(changeSetId);

    For each changeset, it will get the associated work items

    WorkItem[] csWorkItems = changeSet.WorkItems

    I am getting the following exception at this point on domain machines (that do not have any sort of development suite installed):

    System.NullReferenceException: Object reference not set to an instance of an object at 
    Microsoft.TeamFoundation.VersionControl.Client.Changeset.get_WorkItems()

    As I have not been able to find a way to get around this, I tried a different route and decided to get the work items straight from the build information. In order to do this I need a WorkItemStore

    workItemStore = new WorkItemStore(tfs);

    I am getting the following at this point:

    System.TypeInitializationException: The type initializer for 'Microsoft.TeamFoundation.WorkItemTracking.Client.WorkItemStore' threw an exception. ---> System.IO.FileLoadException: Mixed mode assembly is built against version 'v2.0.50727' of the runtime and cannot be loaded in the 4.0 runtime without additional configuration information.
       at Microsoft.TeamFoundation.WorkItemTracking.Client.WorkItemStore..cctor()

    There are several things I don't understand about these problems:

    1. It would seem that my tool can connect to TFS, query the builds and get details for the changesets BUT NOT THE WORK ITEMS - why is this? At this point I'm assuming that it is due to TFS not being installed, but if that is the case then why can it connect to TFS, and then get build and changeset information?

    2. Am I missing something from my tool? I have packaged it into an installer and the detected dependencies have included the following libraries:

    Microsoft.TeamFoundation.Build.Client.dll
    Microsoft.TeamFoundation.Build.Common.dll
    Microsoft.TeamFoundation.Client.dll
    Microsoft.TeamFoundation.Common.dll
    Microsoft.TeamFoundation.Common.Library.dll
    Microsoft.TeamFoundation.dll
    Microsoft.TeamFoundation.TestManagement.Client.dll
    Microsoft.TeamFoundation.TestManagement.Common.dll
    Microsoft.TeamFoundation.VersionControl.Client.dll
    Microsoft.TeamFoundation.VersionControl.Common.dll
    Microsoft.TeamFoundation.VersionControl.Common.Integration.dll
    Microsoft.TeamFoundation.WorkItemTracking.Client.Cache.dll
    Microsoft.TeamFoundation.WorkItemTracking.Client.DataStore.dll
    Microsoft.TeamFoundation.WorkItemTracking.Client.dll
    Microsoft.TeamFoundation.WorkItemTracking.Client.Provision.dll
    Microsoft.TeamFoundation.WorkItemTracking.Client.QueryLanguage.dll
    Microsoft.TeamFoundation.WorkItemTracking.Client.RuleEngine.dll
    Microsoft.TeamFoundation.WorkItemTracking.Proxy.dll

    Can anyone help me with getting the details for the Work Items?

    Thanks in advance



    • Edited by TheVermin Wednesday, April 04, 2012 1:38 PM
    •  

All Replies

  • Wednesday, April 04, 2012 4:18 PM
     
     

    Hello TheVermin,

     This exception might be related to local TFS Cache missing on the machine.

    Here is the similar thread

    http://social.msdn.microsoft.com/Forums/en-US/tfsgeneral/thread/5bd26885-ab95-483b-be0d-2ae34460460d

    Hope this helps


    Regards,
    Adhi
    My TFS Blog
    Please remember to mark as answered, if this reply helps

  • Tuesday, August 28, 2012 8:42 PM
     
      Has Code

    Adding the following section to my App.config worked for me

    <?xml version="1.0"?>
    <configuration>
     
    <startup useLegacyV2RuntimeActivationPolicy="true">
       
    <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/>
     
    </startup>
    </configuration>

    (per http://stackoverflow.com/questions/2455654/what-additional-configuration-is-necessary-to-reference-a-net-2-0-mixed-mode)