Cry about...
MS-Windows Troubleshooting
Namespace or type specified in the Imports ... doesn't contain any public member or cannot be found
Symptom:
After adding an "imports" clause the following warning is generated:
Namespace or type specified in the Imports 'Some.Import' doesn't contain any public member or cannot be found. Make sure the namespace or the type is defined and contains at least one public member. Make sure the imported element name doesn't use any aliases.
where "Some.Import
" in the above is the name of the imported namespace. If you are
trying to use types that you expect to be provided by this import then
the warning may be followed by errors.
Cause
Typically this means that the project is missing a reference, so the project cannot find the import.
Possible Remedies:
- If the namespace is provided by another project in the solution
then:
- Open the Solution Explorer.
- Right click the project and select "Add Reference..."
- On the "Projects" tab highlight the project that provides the namespace and click [OK].
- If the namespace is provided as part of the .NET framework then:
- Open the Solution Explorer.
- Right click the project and select "Add Reference..."
- On the ".NET" tab highlight the component name which corresponds to what you are trying to import and click [OK].
If you cannot see the specific component you are looking for then for a more generic one and see whether that will satisfy. For example, for the imports "
System.Web.HttpContent
" you would need to add the component "System.Web
".
These notes have been tested with .Net 2.0, .NET 3.5 and .NET 4 applications developed using Visual Studio 2005, Visual Studio 2008 and Visual Studio 2010, and may apply to other versions as well.
About the author: Brian Cryer is a dedicated software developer and webmaster. For his day job he develops websites and desktop applications as well as providing IT services. He moonlights as a technical author and consultant.