-
Notifications
You must be signed in to change notification settings - Fork 4.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Could not load file or assembly System.Net.Http Version=4.0.0.0 in .net core app #25540
Comments
Does it repro in brand new .NET Core 2.0 console app for you? Or does the repro require some additional dependencies? |
I think you can reproduce it with out any additional dependencies. I just tried creating a new .net core console app and execute the below code. try
{
var u = new Uri("https://{My Account}.visualstudio.com");
VssCredentials c = new VssCredentials(new Microsoft.VisualStudio.Services.Common.VssBasicCredential(username, password));
var connection = new VssConnection(u, c);
var testClient = connection.GetClient<TestManagementHttpClient>();
int testpointid = 1;
string teamProject = "MyProjectName";
RunCreateModel run = new RunCreateModel(name: "TestCase Name", plan: new Microsoft.TeamFoundation.TestManagement.WebApi.ShallowReference("TestPlan Id"), pointIds: new int[] { testpointid });
TestRun testrun = testClient.CreateTestRunAsync(run, teamProject).Result;
TestCaseResult caseResult = new TestCaseResult() { State = "Completed", Outcome = "passed", Id = 100000 };
var testResults = testClient.UpdateTestResultsAsync(new TestCaseResult[] { caseResult }, teamProject, testrun.Id).Result;
RunUpdateModel runmodel = new RunUpdateModel(state: "Completed");
TestRun testRunResult = testClient.UpdateTestRunAsync(runmodel, teamProject, testrun.Id, runmodel).Result;
}
catch (AggregateException e)
{
Console.WriteLine(e.InnerException.Message);
} [EDIT] Add C# syntax highlighting by @karelz |
Where do you get these types from then?
Do you need more than the first 3 lines of code to reproduce it? |
ok here you go. .visualstudio.com hope this helps you to recreate the issue. incase you're not able to add the extended client package. just add the below code in .csproj portable-net451+win8 |
@rizwaans What version of Visual Studio are you using? Visual Studio 2017? And what update are you using? We recommend the latest Update 15.7 for Visual Studio 2017. |
Hi I'm also getting the same error while using the below code. I'm using .NET Core 2.0 version. |
@SivakumarShan can you answer @davidsh's questions above please? (https://github.com/dotnet/corefx/issues/28267#issuecomment-388199656) |
@karelz I'm using VS 2017 with 15.5.6 version. Let me update to the above mentioned version and try it out. Thanks :) |
@karelz I've updated to VS Enterprise 2017 to 15.7.3 and still getting the same issue. I'm using netcoreapp2.0. Please help me to resolve this issue. Thanks. |
I am getting slightly different error, which is by design - it seems that the NuGet packages you're using are not compatible with .NET Core and use .NET Framework API surface (from System.Net.Http.WebRequest.dll) which is not available on .NET Core. Repro steps: (based on https://github.com/dotnet/corefx/issues/28267#issuecomment-374809539) using Microsoft.VisualStudio.Services.Common;
using Microsoft.VisualStudio.Services.WebApi;
class Program
{
static void Main()
{
VssCredentials c = new VssCredentials(new Microsoft.VisualStudio.Services.Common.VssBasicCredential("my_name", "abc"));
var connection = new VssConnection(new System.Uri("https://my_name.visualstudio.com"), c);
}
} Note build warnings - listing assemblies which target .NET Framework 4.6.1 instead of .NET Core 2.0:
At runtime, I get exception explaining System.Net.Http.WebRequest is not available:
Using .NET Framework assets on .NET Core is a bridge which helps to try libraries that didn't start targeting .NET Core / .NET Standard yet. It is not guaranteed to work and in this case, it won't work as the libraries have dependencies which cannot be satisfied on .NET Core. Closing as by design - the libraries you use need to ship targeting .NET Core, or you can use them only on .NET Framework. |
Hi everybody! |
I had the same problem. I figured out that I created a wrong type of project. It should be Windows Console application that runs on .NET Framework,, not CoreApp console application that runs on CoreApp2.0. I am new to .NET and hope my experience helps those like me. |
I've got this issue in .net core 2.0, just to give you more idea about what I'm trying to achieve. I'm trying to connect to VSTS and update the test status "Passed" or "Failed" based on my unit tests
I run of this "Could not load file or assembly System.Net.Http Version=4.0.0.0" issue where the code is trying to open a connection to vsts.
var connection = new VssConnection("https://.visualstudio.com", credentials);
The text was updated successfully, but these errors were encountered: