开发者

Namespace not available in other project

开发者 https://www.devze.com 2023-03-28 04:47 出处:网络
I have created one C# console application. In that application, I have many namespaces. for example : namespace com.xyz.foo.bar

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. i.e. 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)

0

精彩评论

暂无评论...
验证码 换一张
取 消