1

I am trying to connect Azure DevOps in .net core application with following code.

var url = new Uri("https://abcdxyz.visualstudio.com");

var PAT = "XXXXXgdeuxfroaqho4lhtqjdvbagrotypfgfhtuq6w23ie5z3xoq";

VssConnection connection = new VssConnection(url, new VssBasicCredential(string.Empty, PAT));
WorkItemTrackingHttpClient witClient = connection.GetClient<WorkItemTrackingHttpClient>();

it builds successfully. However, it throws error as

System.IO.FileNotFoundException: 'Could not load file or assembly 'System.Net.Http.WebRequest, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. The system cannot find the file specified.'

I tried to update Nuget package. But still this error occurs.

Could you please let me know how to resolve this? thanks

3
  • System.Net.Http.WebRequest doesn't come from Nuget package. Did you try adding from the Add Reference -> Assemblies dialog box? Commented Mar 19, 2019 at 5:03
  • Thanks Deepak for your suggestion. I am trying this with .net core application. However it is working fine with .net framework. Commented Mar 19, 2019 at 6:00
  • What library are you using to connect? WebRequest is not natively supported in .NET Core, and this library is using WebRequest, meaning it was likely designed for .NET Framework. You should try to find an alternate library, or if you cannot not, you should target .NET Framework, instead of .NET Core. You can still use ASP.NET Core, as it will run on either. Commented Mar 19, 2019 at 13:25

1 Answer 1

1

I recall having a similar issue, and this is the way we get the WIT client in our .net core app that uses these libraries:

 vss = new VssBasicCredential(string.Empty, PAT);
 VssConnection connection = new VssConnection(tfsURI, vss);
 witClient = connection.GetClient<WorkItemTrackingHttpClient>();

 workItemClient = new WorkItemClient(witClient);

We are using the preview versions of the Microsoft.TeamFoundationServer.Client and Microsoft.VisualStudio.Services.Client libraries as well.

There is no .net core support ATM from my understanding. A coworker of mine commented on this open issue with some more context of how we made this work.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.