将项目目标设为.NET Framework 4.6(net46)实际指的是4.6.0吗?
Hey there! Let's break this down clearly—this is a super common gotcha when dealing with .NET Framework and .NET Standard compatibility.
When you set your project's target framework to net46 (or select ".NET Framework 4.6" in Visual Studio), you're specifically targeting .NET Framework 4.6.0, not the entire 4.6.x family of releases (like 4.6.1 or 4.6.2).
Here's why your fix worked: Your .NET Standard library is configured to target net45;net46—these are framework monikers that map directly to exact major.minor version releases (4.5.0 and 4.6.0). When your project was set to 4.6.1 or 4.6.2, the build system saw a mismatch: the library didn't explicitly target those minor point releases, so it threw a build error, even though 4.6.1/4.6.2 are backward-compatible with 4.6.0 at runtime.
A quick side note: While you can run code compiled for 4.6.0 on 4.6.1 or 4.6.2 without issues, the build process enforces strict matching of target framework monikers. That's why switching your project to net46 aligned it perfectly with your library's target and resolved the build problem.
If you ever need to target a later 4.6.x version while using that library, you could adjust your library's target frameworks to include net461;net462, or add compatibility settings in your project file to allow falling back to compatible frameworks—but in your case, sticking with net46 was the simplest fix.
内容的提问来源于stack exchange,提问作者Josh

