【问题标题】:Missing type, but seems to really be a version mismatch缺少类型,但似乎真的是版本不匹配
【发布时间】:2011-06-21 01:06:58
【问题描述】:

我在编译 .NET 4.0 应用程序时收到此错误消息。:

“System.Collections.Specialized.INotifyCollectionChanged”类型在未引用的程序集中定义。您必须添加对程序集 'WindowsBase, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' 的引用。

它说它需要的类是在您将 System 添加到项目引用时定义的。

似乎是说它需要版本 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)
    {

    }
}

导致问题的是 Iterations 集合。

【问题讨论】:

    标签: .net reference dllimport dll


    【解决方案1】:

    那么您是否尝试添加对 WindowsBase 版本 4 的引用?它包含一个 [TypeForwardedTo] 属性,用于将 INotifyCollectionchanged 类型重定向到 System.dll。那应该会照顾它。

    【讨论】:

    • 那么您实际上做了什么来解决这个问题?
    • 他添加了对 WindowsBase 的引用。
    【解决方案2】:

    在 .NET 3.0 中,ObservableCollectionWindowsBase 程序集中定义。在 .NET 4.0 中,它在 System 中定义。似乎 TFS API 针对 v3.0...

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

    【讨论】:

      猜你喜欢
      • 2019-07-01
      • 1970-01-01
      • 1970-01-01
      • 2019-01-07
      • 1970-01-01
      • 1970-01-01
      • 2014-09-08
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多