Azure DevOps / C# - GetTeamProjectCollection throws error when mixing .NET Framework and .NET

Viewed 66

I am porting my TFS / Azure DevOps application from .NET Framework 4.8 to .NET 5 right now.

I was able to replace most of the queries with REST API calls.

However, I also want to discover all local workspaces on a machine and unfortunately there is no REST API for that.

Since the client library that allows the queries is only supported for .NET Framework, I have created a separate .NET Framework project that has as its only task to determine the workspaces.

var collection = TfsTeamProjectCollectionFactory.GetTeamProjectCollection(Uri, new 
VssBasicCredential(string.Empty, personalaccesstoken));
var vcServer = collection.GetService<VersionControlServer>();
var loggedInUser = vcServer.AuthorizedUser;
var microsoftWorkspaces = vcServer.QueryWorkspaces(null, loggedInUser, System.Environment.MachineName);

Unfortunately, even when I call the first line, I get the following error message:

System.TypeLoadException: 'Could not load type 'System.Diagnostics.Eventing.EventProvider' from assembly 'System.Core, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.'

However, if I put the same project in a separate solution that contains only .NET Framework projects, I get my workspaces as desired.

Is there a compatibility issue? What can I do to resolve the issue?

Motivated by other forum posts about similar problems, I have already tried adding the following NuGet packages, unfortunately without success:

0 Answers
Related