Skip to content

[Breaking change]: ServicePointManager is fully marked as obsolete #43144

@MihaZupan

Description

@MihaZupan

Description

Introduced with .NET 9 preview 6 - dotnet/runtime#103456.

Version

.NET 9 Preview 6

Previous behavior

The affected APIs had, and continue to have, no effect on types like SslStream or HttpClient.
This wasn't fully communicated to the user with existing obsoletions.

New behavior

Source code using any of the obsoleted static members will issue a warning.

Type of breaking change

  • Binary incompatible: Existing binaries might encounter a breaking change in behavior, such as failure to load or execute, and if so, require recompilation.
  • Source incompatible: When recompiled using the new SDK or component or to target the new runtime, existing source code might require source changes to compile successfully.
  • Behavioral change: Existing binaries might behave differently at run time.

Reason for change

In .NET 6, we've obsoleted WebRequest, WebClient, and ServicePoint (SYSLIB0014).
See https://learn.microsoft.com/en-us/dotnet/core/compatibility/networking/6.0/webrequest-deprecated

To reduce the number of warnings, we didn't always obsolete the types themselves, instead obsoleting just the methods/constructors used to obtain their instances. For example, instead of marking ServicePoint as obsolete, we've obsoleted ServicePointManager.FindServicePoint instead.

This failed to properly communicate to the user that they shouldn't be using ServicePointManager at all, as seen in issues like dotnet/dotnet-api-docs#6867 (ServicePointManager.ReusePort).

In .NET 9, we've expanded the use of the SYSLIB0014 obsoletion diagnostic to apply to the whole ServicePointManager type instead, and updated the documentation to note that settings on ServicePointManager no longer have any effect on SslStream or HttpClient.
This is not a change in behavior in .NET 9, they had no effect in previous versions of .NET (Core) either.

Recommended action

Use HttpClient and related APIs like settings on SocketsHttpHandler instead.

We've written a new guide that offers more help around how to migrate to these types: https://learn.microsoft.com/dotnet/fundamentals/networking/http/httpclient-migrate-from-httpwebrequest

Feature area

Networking

Affected APIs

The ServicePointManager type.
Note that some methods on the type were already marked as obsolete previously, and in .NET 9 we've expanded the obsoletion to the whole type instead. For example this means that properties like ServicePointManager.ReusePort would now show up as obsolete.


Associated WorkItem - 340222

Metadata

Metadata

Assignees

Labels

📌 seQUESTeredIdentifies that an issue has been imported into Quest.breaking-changeIndicates a .NET Core breaking changein-prThis issue will be closed (fixed) by an active pull request.source incompatibleSource code may encounter a breaking change in behavior when targeting the new version.

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions