Encountering sudden namespace visibility problems in Visual Studio 2010 can be frustrating. While it may seem like a project has suddenly become inaccessible to another, the root cause can often be traced to a specific scenario or configuration change.
Problem:
In a C# WinForms solution consisting of a DLL project and a "Sandbox" executable for debugging, the Sandbox project abruptly lost visibility to the DLL project's namespace. Despite attempts to resolve references, the issue persisted upon building the solution.
Investigation:
Upon closer examination, it was discovered that adding an innocent line of code in the DLL project, involving System.Web, triggered the issue. Once that line was commented out, the namespace errors disappeared.
Solution:
After a thorough investigation, the solution was found not to be a bug but a configuration issue. The Target Framework for the Sandbox project was set to the ".NET Framework 4 Client Profile" by default.
Explanation:
The ".NET Framework 4 Client Profile" is a subset of the full .NET Framework, excluding certain features such as System.Web. By changing the Target Framework to ".NET Framework 4" (not the Client Profile) in the Sandbox project properties, the required features were restored, resolving the namespace visibility issue.
The above is the detailed content of Visual Studio 2010 Namespace Visibility: Bug or Incorrect Target Framework Setting?. For more information, please follow other related articles on the PHP Chinese website!