Error message when you try to import a work item type in Visual Studio Team Foundation Server: "Cannot complete the operation" (921319)



The information in this article applies to:

  • Microsoft Visual Studio 2005 Team System Team Foundation:

SYMPTOMS

When you try to import a work item type in Microsoft Visual Studio 2005 Team Foundation Server, you receive the following error message:
Cannot complete the operation. An unexpected error occurred.

CAUSE

This problem occurs if the following conditions are true:
  • You modify an existing rule by setting both the for attribute and the not attribute.
  • The existing rule already had one of the two attributes set.

WORKAROUND

To work around this problem, remove the rule that causes the problem from the original work item type, and then import the updated work item type. Modify the work item type by creating the rule with both the for attribute and the not attribute, and then import the updated work item type again. To do this, follow these steps:
  1. Assume that you have the following work item type already imported into your project.
    <?xml version="1.0" encoding="utf-8"?>
    <wit:WITD xmlns:wit="http://schemas.microsoft.com/VisualStudio/2005/workitemtracking/typedef" version="1.0">
        <WORKITEMTYPE name="000.001">
            <FIELDS>
                <FIELD refname="D000.001" name="001" type="String">
                    <ALLOWEDVALUES for="[global]\Team Foundation Administrators">
                        <LISTITEM value="Item 1"/>
                        <LISTITEM value="Item 2"/>
                    </ALLOWEDVALUES>
                </FIELD>
            </FIELDS>
            <WORKFLOW>
                <STATES>
                    <STATE value="State 1"/>
                </STATES>
                <TRANSITIONS>
                    <TRANSITION from="" to="State 1">
                        <REASONS>
                            <DEFAULTREASON value="State *-1-1"/>
                        </REASONS>
                    </TRANSITION>
                </TRANSITIONS>
            </WORKFLOW>
            <FORM>
                <Layout/>
            </FORM>
        </WORKITEMTYPE>
    </wit:WITD>
    
  2. Modify the work item type by removing the original rule, and then save the file as 1.xml. The XML will resemble the following.
    <?xml version="1.0" encoding="utf-8"?>
    <wit:WITD xmlns:wit="http://schemas.microsoft.com/VisualStudio/2005/workitemtracking/typedef" version="1.0">
        <WORKITEMTYPE name="000.001">
            <FIELDS>
                <FIELD refname="D000.001" name="001" type="String">
                </FIELD>
            </FIELDS>
            <WORKFLOW>
                <STATES>
                    <STATE value="State 1"/>
                </STATES>
                <TRANSITIONS>
                    <TRANSITION from="" to="State 1">
                        <REASONS>
                            <DEFAULTREASON value="State *-1-1"/>
                        </REASONS>
                    </TRANSITION>
                </TRANSITIONS>
            </WORKFLOW>
            <FORM>
                <Layout/>
            </FORM>
        </WORKITEMTYPE>
    </wit:WITD>
  3. Click Start, click Run, type cmd, and then click OK.
  4. Type the following command, and then press ENTER:

    cd C:\Program Files\Microsoft Visual Studio 8\Common7\IDE

  5. Type the following command, and then press ENTER:

    witimport /f 1.xml /t Team_Foundation_Server_Name /p Project_Name

  6. Modify the work item type by adding the rule again. Add both the for attribute and the not attribute. The XML file will resemble the following.
    <?xml version="1.0" encoding="utf-8"?>
    <wit:WITD xmlns:wit="http://schemas.microsoft.com/VisualStudio/2005/workitemtracking/typedef" version="1.0">
        <WORKITEMTYPE name="000.001">
            <FIELDS>
                <FIELD refname="D000.001" name="001" type="String">
                    <ALLOWEDVALUES for="[global]\Team Foundation Administrators" not="[global]\Team Foundation Valid Users" >
                        <LISTITEM value="Item 1"/>
                        <LISTITEM value="Item 2"/>
                    </ALLOWEDVALUES>
                </FIELD>
            </FIELDS>
            <WORKFLOW>
                <STATES>
                    <STATE value="State 1"/>
                </STATES>
                <TRANSITIONS>
                    <TRANSITION from="" to="State 1">
                        <REASONS>
                            <DEFAULTREASON value="State *-1-1"/>
                        </REASONS>
                    </TRANSITION>
                </TRANSITIONS>
            </WORKFLOW>
            <FORM>
                <Layout/>
            </FORM>
        </WORKITEMTYPE>
    </wit:WITD>
    
  7. At the command prompt, type the following command, and then press ENTER:

    witimport /f 1.xml /t Team_Foundation_Server_Name /p Project_Name

STATUS

Microsoft has confirmed that this is a problem in the Microsoft products that are listed in the "Applies to" section.

MORE INFORMATION

Steps to reproduce this problem

  1. Create an XML file that is named 1.xml and that contains the following code.
    <?xml version="1.0" encoding="utf-8"?>
    <wit:WITD xmlns:wit="http://schemas.microsoft.com/VisualStudio/2005/workitemtracking/typedef" version="1.0">
        <WORKITEMTYPE name="000.001">
            <FIELDS>
                <FIELD refname="D000.001" name="001" type="String">
                    <ALLOWEDVALUES for="[global]\Team Foundation Administrators">
                        <LISTITEM value="Item 1"/>
                        <LISTITEM value="Item 2"/>
                    </ALLOWEDVALUES>
                </FIELD>
            </FIELDS>
            <WORKFLOW>
                <STATES>
                    <STATE value="State 1"/>
                </STATES>
                <TRANSITIONS>
                    <TRANSITION from="" to="State 1">
                        <REASONS>
                            <DEFAULTREASON value="State *-1-1"/>
                        </REASONS>
                    </TRANSITION>
                </TRANSITIONS>
            </WORKFLOW>
            <FORM>
                <Layout/>
            </FORM>
        </WORKITEMTYPE>
    </wit:WITD>
    
  2. Click Start, click Run, type cmd, and then click OK.
  3. Type the following command, and then press ENTER:

    cd C:\Program Files\Microsoft Visual Studio 8\Common7\IDE

  4. Type the following command, and then press ENTER:

    witimport /f 1.xml /t Team_Foundation_Server_Name /p Project_Name

  5. Open the 1.xml file. Replace the content of the file with the following code.
    <?xml version="1.0" encoding="utf-8"?>
    <wit:WITD xmlns:wit="http://schemas.microsoft.com/VisualStudio/2005/workitemtracking/typedef" version="1.0">
        <WORKITEMTYPE name="000.001">
            <FIELDS>
                <FIELD refname="D000.001" name="001" type="String">
                    <ALLOWEDVALUES for="[global]\Team Foundation Administrators" not="[global]\Team Foundation Valid Users" >
                        <LISTITEM value="Item 1"/>
                        <LISTITEM value="Item 2"/>
                    </ALLOWEDVALUES>
                </FIELD>
            </FIELDS>
            <WORKFLOW>
                <STATES>
                    <STATE value="State 1"/>
                </STATES>
                <TRANSITIONS>
                    <TRANSITION from="" to="State 1">
                        <REASONS>
                            <DEFAULTREASON value="State *-1-1"/>
                        </REASONS>
                    </TRANSITION>
                </TRANSITIONS>
            </WORKFLOW>
            <FORM>
                <Layout/>
            </FORM>
        </WORKITEMTYPE>
    </wit:WITD>
    
  6. At the command prompt, type the following command, and then press ENTER:

    witimport /f 1.xml /t Team_Foundation_Server_Name /p Project_Name


Modification Type:MinorLast Reviewed:9/8/2006
Keywords:kberrmsg kbtshoot kbinfo kbBug kbprb KB921319 kbAudDeveloper kbAudITPRO