简体   繁体   中英

Namespace not available in other project

I have created one C# console application. In that application, I have many namespaces.

for example:

namespace com.xyz.foo.bar
{
}

namespace com.xyz.abc.def
{
}

When I added reference of this console application into an WCF service project, some of the namespaces are not available for import. ie from above example I can get com.xyz.foo.bar namespace but com.xyz.abc.def namespace is not available.

I dont understand why this is happening.

If I open executable of console application from 'object browser' I can see all the namespaces.

Can anyone explain the reason behind this thing??

I had a similar issue where a namespace was not found even though there was a project reference in the same solution, types were public, etc..

It turned out that I needed to change the "Target Framework" to be ".NET Framework 4" instead of ".NET Framework 4 Client Profile". I didn't bother figuring out why this resulted in an "unknown namespace" error, but it solved my problem.

John

Your namespaces must have classes etc marked as public

namespace com.xyz.foo.bar
{
    class MyClass
    {
    }
}

namespace com.xyz.abc.def
{
    public class AnotherClass
    {
    }
}

bar namespace will not be visible while def will (if nothing else is declared with public in them)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM