2011-06-21 28 views
1

当我编译我的.NET 4.0的应用程序:缺少类型,但似乎真的是版本不匹配

类型“System.Collections.Specialized.INotifyCollectionChanged”的定义我收到此错误信息未引用的程序集。您必须添加对程序集“WindowsBase,版本= 3.0.0.0,文化=中立,PublicKeyToken = 31bf3856ad364e35”的引用。

当您将系统添加到项目引用时,它说它需要的类是定义的。

这似乎是说它需要一个版本3的参考。我不知道该怎么做。

如果有人有想法,我很乐意听到它。

作为一个方面说明,我现在用的是TFS API和验证码:

// Get the id of the work item that we got from the server (or the work item associated with it) 
int workItemId; 

// If this is a test run then we need to look up the work item it is running off of 
if (notificationEventArgs is TestCaseResultChangedNotification) 
{ 
    TestCaseResultChangedNotification testCaseResultChangedNotification = (notificationEventArgs as TestCaseResultChangedNotification); 
    ITestManagementTeamProject testManagementTeamProject = TFSAccess.Instance.TestManagement.GetTeamProject(testCaseResultChangedNotification.ProjectName); 
    ITestCaseResult testCaseResult = testManagementTeamProject.TestResults.Find(testCaseResultChangedNotification.TestCaseResultIdentifier.TestRunId, testCaseResultChangedNotification.TestCaseResultIdentifier.TestResultId); 
    workItemId = testCaseResult.TestCaseId; 

    foreach (ITestIterationResult testIterationResult in testCaseResult.Iterations) 
    { 

    } 
} 

这是迭代集合导致该问题。

回答

2

你是否尝试添加对WindowsBase版本4的引用?它包含[TypeForwardedTo]属性以将INotifyCollectionchanged类型重定向到System.dll。这应该照顾它。

+0

工作完美!谢谢! – Vaccano

+0

那么你究竟做了什么来解决这个问题? –

+0

他添加了对WindowsBase的引用。 –

1

在.NET 3.0中ObservableCollection被定义在WindowsBase程序集中。在.NET 4.0中,它在System中定义。看来,TFS API目标v3.0 ...

重定向您的项目到早期版本或引用WindowsBase。在第二种情况下,您可能需要使用this article中描述的方法。

相关问题