I'm writing an MVC website using ASP.NET Core 2.0.
In the ASP.NET Core project (let's call it Web
), I reference a .NET Standard 2 project in the same solution (let's call it Service
). The Service
project also references a third .NET Standard 2 library in the solution (let's call this one Business
). The Business
project declares a type called Model
.
The problem is that I can use Model
in the Web
project (i.e. the compiler sees the type Model
and I can do var a = new Model();
) as if the Web
project has referenced Business
, but it actually only has a reference to Service
.
How can I hide Model
from Web
? Is this a new feature in ASP.NET Core 2 or all .NET Standard projects are like this?
Edit
As specified here, this is due to transitive project references which is a new "feature" in .NET Standard, but how do I fix it?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…