This is a known bug in Unity. Here's how to fix it:
1 .Go to File -> Build Settings ... then select your platform.
2 . Click on player settings → Other settings and change the API compatibility level to .NET 2.0.
If it is already installed in .NET 2.0, change it to a subset of .NET 2.0, and then back to .NET 2.0.
3 . Close and reopen Visual Studio. From Visual Studio, go to build -> Clean solution, then do Build -> Rebuild Solution.
Try debugging again and it should work.
If the steps above did not work, go to the Project Library folder and then share it. Restart Unity and Visual Studio.
source share