APIs that always throw exceptions on .NET Core and .NET 5+

The following APIs will always throw an exception on .NET (Core) on all or a subset of platforms. In most cases, the exception that's thrown is PlatformNotSupportedException.

This article organizes the affected APIs by namespace.

Note

  • This article is a work-in-progress. It is not a complete list of APIs that throw exceptions on .NET 5+.
  • This article does not include the explicit interface implementations for binary serialization that throw on .NET 5+. For more information, see Binary serialization in .NET Core.

System

Member Platforms that throw
AppDomain.CreateDomain All
AppDomain.ExecuteAssembly(String, String[], Byte[], AssemblyHashAlgorithm) All
AppDomain.Unload(AppDomain) All
Console.CapsLock Linux and macOS
Console.NumberLock Linux and macOS
Delegate.GetObjectData(SerializationInfo, StreamingContext) All
Exception.SerializeObjectState All
MarshalByRefObject.GetLifetimeService() All
MarshalByRefObject.InitializeLifetimeService() All
OperatingSystem.GetObjectData(SerializationInfo, StreamingContext) All
Type.ReflectionOnlyGetType(String, Boolean, Boolean) All

System.CodeDom.Compiler

Member Platforms that throw
CodeDomProvider.CompileAssemblyFromDom All
CodeDomProvider.CompileAssemblyFromFile All
CodeDomProvider.CompileAssemblyFromSource All

System.Collections.Specialized

Member Platforms that throw
NameObjectCollectionBase(SerializationInfo, StreamingContext) All
NameObjectCollectionBase.GetObjectData(SerializationInfo, StreamingContext) All
NameObjectCollectionBase.OnDeserialization(Object) All

System.Configuration

Member Platforms that throw
System.Configuration.RsaProtectedConfigurationProvider (all members) All

System.Console

Member Platforms that throw
Console.Beep() Linux and macOS
Console.BufferHeight (set only) Linux and macOS
Console.BufferWidth (set only) Linux and macOS
Console.CursorSize (set only) Linux and macOS
Console.CursorVisible (get only) Linux and macOS
Console.MoveBufferArea Linux and macOS
Console.SetWindowPosition Linux and macOS
Console.SetWindowSize Linux and macOS
Console.Title (get only) Linux and macOS
Console.WindowHeight (set only) Linux and macOS
Console.WindowLeft (set only) Linux and macOS
Console.WindowTop (set only) Linux and macOS
Console.WindowWidth (set only) Linux and macOS

System.Data.Common

Member Platforms that throw
DbDataReader.GetSchemaTable (throws NotSupportedException) All

System.Diagnostics.Process

Member Platforms that throw
Process.MaxWorkingSet (set only) Linux
Process.MinWorkingSet (set only) Linux
Process.ProcessorAffinity macOS
Process.MainWindowHandle Linux and macOS
Process.Start(String, String, String, SecureString, String) Linux and macOS
Process.Start(String, String, SecureString, String) Linux and macOS
ProcessStartInfo.UserName Linux and macOS
ProcessStartInfo.PasswordInClearText Linux and macOS
ProcessStartInfo.Domain Linux and macOS
ProcessStartInfo.LoadUserProfile Linux and macOS
ProcessThread.BasePriority (set only) Linux and macOS
ProcessThread.BasePriority (get only) macOS
ProcessThread.ProcessorAffinity (set only) Linux and macOS

System.IO

Member Platforms that throw
FileSystemInfo(SerializationInfo, StreamingContext) All
FileSystemInfo.GetObjectData(SerializationInfo, StreamingContext) All

System.IO.Pipes

Member Platforms that throw
NamedPipeClientStream.NumberOfServerInstances Linux and macOS
NamedPipeServerStream.GetImpersonationUserName() Linux and macOS
PipeStream.InBufferSize Linux and macOS
PipeStream.OutBufferSize Linux and macOS
PipeStream.ReadMode (set only) Linux and macOS
PipeStream.WaitForPipeDrain() Linux and macOS

System.Media

Member Platforms that throw
SoundPlayer(SerializationInfo, StreamingContext) All

System.Net

Member Platforms that throw
AuthenticationManager.Authenticate(String, WebRequest, ICredentials) All
AuthenticationManager.PreAuthenticate(WebRequest, ICredentials) All
FileWebRequest(SerializationInfo, StreamingContext) All
FileWebRequest.GetObjectData(SerializationInfo, StreamingContext) All
FileWebResponse(SerializationInfo, StreamingContext) All
FileWebResponse.GetObjectData(SerializationInfo, StreamingContext) All
HttpWebRequest(SerializationInfo, StreamingContext) All
HttpWebRequest.GetObjectData(SerializationInfo, StreamingContext) All
HttpWebResponse(SerializationInfo, StreamingContext) All
HttpWebResponse.GetObjectData(SerializationInfo, StreamingContext) All
WebProxy(SerializationInfo, StreamingContext) All
WebProxy.GetDefaultProxy() All
WebProxy.GetObjectData All
WebRequest(SerializationInfo, StreamingContext) All
WebRequest.GetObjectData(SerializationInfo, StreamingContext) All
WebResponse(SerializationInfo, StreamingContext) All
WebResponse.GetObjectData(SerializationInfo, StreamingContext) All

System.Net.NetworkInformation

Member Platforms that throw
Ping.Send Windows (UWP)

System.Net.Sockets

Member Platforms that throw
Socket(SocketInformation) All
Socket.DuplicateAndClose(Int32) All

System.Net.WebSockets

Member Platforms that throw
WebSocket.RegisterPrefixes() All

System.Reflection

Member Platforms that throw
Assembly.CodeBase All
Assembly.EscapedCodeBase All
Assembly.LoadFrom(String, Byte[], AssemblyHashAlgorithm) All
Assembly.ReflectionOnlyLoad All
Assembly.ReflectionOnlyLoadFrom(String) All
AssemblyName.GetObjectData(SerializationInfo, StreamingContext) All
AssemblyName.KeyPair All
AssemblyName.OnDeserialization(Object) All
StrongNameKeyPair All
StrongNameKeyPair.PublicKey All

System.Runtime.CompilerServices

Member Platforms that throw
DebugInfoGenerator.CreatePdbGenerator() All

System.Runtime.InteropServices

Member Platforms that throw
IDispatchImplAttribute All
Marshal.GetIDispatchForObject(Object) All
RuntimeEnvironment.SystemConfigurationFile All
RuntimeEnvironment.GetRuntimeInterfaceAsIntPtr(Guid, Guid) All
RuntimeEnvironment.GetRuntimeInterfaceAsObject(Guid, Guid) All
WindowsRuntimeMarshal.StringToHString(String) Linux and macOS
WindowsRuntimeMarshal.PtrToStringHString(IntPtr) Linux and macOS
WindowsRuntimeMarshal.FreeHString(IntPtr) Linux and macOS

System.Runtime.Serialization

Member Platforms that throw
System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Serialize(Stream, Object)* All
BinaryFormatter.Deserialize(Stream)* All
XsdDataContractExporter.Schemas All

* .NET 8 and later versions only for all project types except Windows Forms and WPF.

System.Security

Member Platforms that throw
CodeAccessPermission.Deny() All
CodeAccessPermission.PermitOnly() All
PermissionSet.ConvertPermissionSet(String, Byte[], String) All
PermissionSet.Deny() All
PermissionSet.PermitOnly() All
SecurityContext.Capture() All
SecurityContext.CreateCopy() All
SecurityContext.Dispose() All
SecurityContext.IsFlowSuppressed() All
SecurityContext.IsWindowsIdentityFlowSuppressed() All
SecurityContext.RestoreFlow() All
SecurityContext.Run(SecurityContext, ContextCallback, Object) All
SecurityContext.SuppressFlow() All
SecurityContext.SuppressFlowWindowsIdentity() All

System.Security.Claims

Member Platforms that throw
ClaimsPrincipal(SerializationInfo, StreamingContext) All
ClaimsPrincipal.GetObjectData(SerializationInfo, StreamingContext) All
ClaimsIdentity(SerializationInfo) All
ClaimsIdentity(SerializationInfo, StreamingContext) All
ClaimsIdentity.GetObjectData(SerializationInfo, StreamingContext) All

System.Security.Cryptography

Member Platforms that throw
AsymmetricAlgorithm.Create(String) All
System.Security.Cryptography.CngAlgorithm Linux and macOS
System.Security.Cryptography.CngAlgorithmGroup Linux and macOS
System.Security.Cryptography.CngKey Linux and macOS
System.Security.Cryptography.CngKeyBlobFormat Linux and macOS
System.Security.Cryptography.CngKeyCreationParameters Linux and macOS
System.Security.Cryptography.CngProvider Linux and macOS
System.Security.Cryptography.CngUIPolicy Linux and macOS
CryptoConfig.EncodeOID(String) All
CspKeyContainerInfo Linux and macOS
CspKeyContainerInfo.Accessible Linux and macOS
CspKeyContainerInfo.Exportable Linux and macOS
CspKeyContainerInfo.HardwareDevice Linux and macOS
CspKeyContainerInfo.KeyContainerName Linux and macOS
CspKeyContainerInfo.KeyNumber Linux and macOS
CspKeyContainerInfo.MachineKeyStore Linux and macOS
CspKeyContainerInfo.Protected Linux and macOS
CspKeyContainerInfo.ProviderName Linux and macOS
CspKeyContainerInfo.ProviderType Linux and macOS
CspKeyContainerInfo.RandomlyGenerated Linux and macOS
CspKeyContainerInfo.Removable Linux and macOS
CspKeyContainerInfo.UniqueKeyContainerName Linux and macOS
ECDiffieHellmanCng.FromXmlString(String, ECKeyXmlFormat) All
ECDiffieHellmanCng.ToXmlString(ECKeyXmlFormat) All
ECDiffieHellmanCngPublicKey.FromXmlString(String) All
ECDiffieHellmanCngPublicKey.ToXmlString() All
ECDiffieHellmanPublicKey.ToByteArray() Linux and macOS
ECDiffieHellmanPublicKey.ToXmlString() All
ECDsaCng.FromXmlString(String, ECKeyXmlFormat) All
ECDsaCng.ToXmlString(ECKeyXmlFormat) All
HashAlgorithm.Create() All
HMAC.Create() All
HMAC.Create(String) All
HMAC.HashCore All
HMAC.HashFinal All
HMAC.Initialize All
KeyedHashAlgorithm.Create() All
KeyedHashAlgorithm.Create(String) All
ProtectedData.Protect Linux and macOS
ProtectedData.Unprotect Linux and macOS
System.Security.Cryptography.RSACryptoServiceProvider.DecryptValue(Byte[]) All
System.Security.Cryptography.RSACryptoServiceProvider.EncryptValue(Byte[]) All
System.Security.Cryptography.RSA.DecryptValue(Byte[]) All
System.Security.Cryptography.RSA.EncryptValue(Byte[]) All
RSA.FromXmlString All
RSA.ToXmlString All
SymmetricAlgorithm.Create() All
SymmetricAlgorithm.Create(String) All

System.Security.Cryptography.Pkcs

Member Platforms that throw
CmsSigner(CspParameters) All
SignerInfo.ComputeCounterSignature() All

System.Security.Cryptography.X509Certificates

Member Platforms that throw
X509Certificate(SerializationInfo, StreamingContext) All
X509Certificate.Import All
X509Certificate2(SerializationInfo, StreamingContext) All
X509Certificate2.PrivateKey (set only) All

System.Security.Authentication.ExtendedProtection

Member Platforms that throw
ExtendedProtectionPolicy(SerializationInfo, StreamingContext) All

System.Security.Policy

Member Platforms that throw
Hash.GetObjectData(SerializationInfo, StreamingContext) All

System.ServiceProcess.ServiceController

Member Platforms that throw
TimeoutException(SerializationInfo, StreamingContext) All

System.Text.RegularExpressions

Member Platforms that throw
Regex.CompileToAssembly All

System.Threading

Member Platforms that throw
CompressedStack.GetObjectData(SerializationInfo, StreamingContext) All
ExecutionContext.GetObjectData(SerializationInfo, StreamingContext) All
Thread.Abort All
Thread.ResetAbort() All
Thread.Resume() All
Thread.Suspend() All

System.Xml

Member Platforms that throw
XmlDictionaryReader.CreateMtomReader(Byte[], Int32, Int32, Encoding[], String, XmlDictionaryReaderQuotas, Int32, OnXmlDictionaryReaderClose) All
XmlDictionaryReader.CreateMtomReader(Stream, Encoding[], String, XmlDictionaryReaderQuotas, Int32, OnXmlDictionaryReaderClose) All
XmlDictionaryWriter.CreateMtomWriter(Stream, Encoding, Int32, String, String, String, Boolean, Boolean) All

See also