PlatformNotSupportedException

Hello,
I’m trying to use System.DirectoryServices.AccountManagement in my project, for Windows
So,

  1. I’ve downloaded “System.DirectoryServices.AccountManagement.dll”
  2. I’ve put the file in Assets/Plugins folder.
  3. I’ve checked the compatibility options for the plugin (Windows x86, x86_x64).
  4. I’ve switched API compatibility Level from .NET2 to .NET4.x

Now the namespace is recognized, but when I run the game (in Editor, like in the Build) as soon as I call one of the methods I get this error:
System.PlatformNotSupportedException: Operation is not supported on this platform.

Am I missing something?
Many thanks!

Unity is using an old version of Mono and some parts of .Net are not implemented there (this will change in 2021.2).

You can look at the stack trace of the exception and then check the mono sources to see which parts Mono doesn’t implement and if you can avoid them.

But that might be difficult or impossible. As an alternative, you can try calling native Window APIs directly or try to find other ways, e.g. using LDAP.

Many thanks Adrian.
So, from 2021.2 we’ll be able to use every .Net library?
If so I think that I could wait for the new release, it’s not actually a very necessary feature for my project.

With 2021.2, Unity will use a recent version of Mono, which in turn has better coverage (and directly uses more and more) of .Net’s class libraries. I don’t know if it will ever be able to use every .Net library but it’s definitely able to use more of them.

Though, System.DirectoryServices.AccountManagement is only part of .Net Framework, not the new .Net 5/6, .Net Core or .Net Standard. Inclusion in the latter is what will guarantee good support across the .Net ecosystem going forward, being only in .Net Framework (which won’t get major updates anymore) is not the best sign.

Perfectly clear!
Many thanks for your detailed explanation!