开发者

Missing type, but seems to really be a version mismatch

开发者 https://www.devze.com 2023-03-14 11:00 出处:网络
I am getting this error message when I compile my .NET 4.0 app.: The type \'System.Collections.Specialized.INotifyCollectionChanged\' is defined in an assembly that is not referenced. You must add a

I am getting this error message when I compile my .NET 4.0 app.:

The type 'System.Collections.Specialized.INotifyCollectionChanged' is defined in an assembly that is not referenced. You must add a reference to assembly 'WindowsBase, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'.

The class it says it needs is defined when you add System to the project references.

It seems to be saying that it needs a version 3 reference. I am not sure what to do.

If anyone has an idea I would love to hear it.

As a side note, I am using the TFS API and this code:

// 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 TestCaseResultCh开发者_C百科angedNotification)
{
    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)
    {

    }
}

It is the Iterations collection that is causing the issues.


So did you try to add a reference to WindowsBase version 4? It contains a [TypeForwardedTo] attribute to redirect the INotifyCollectionchanged type to System.dll. That should take care of it.


In .NET 3.0 ObservableCollection was defined in WindowsBase assembly. In .NET 4.0 it is defined in System. It seems that TFS API targets v3.0...

Either retarget your project to earlier version or reference WindowsBase. In second case you may need to use the approach described in this article.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号