命名空间问题 [英] Namespace issue

查看:94
本文介绍了命名空间问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我面临一个奇怪的问题。在我的解决方案中,我有一个具有不同命名空间的不同项目。

I'm facing a weird problem. In my solution I have a different projects with different namespaces.

project-1 使用名为"Namespace.Project.folder.Subfolder"的命名空间并且它在不同的文件夹下有不同的类,我有另一个新添加的项目-2,名称空间名为"Refactored.Namespace.DifferentProject"。
现在我又增加了一个项目(第三个项目),我添加了项目-1&这里有2个引用。

project-1  with a namespace called "Namespace.Project.folder.Subfolder" and it's having different classes under different folders, and I have another newly added project-2 with a name space called "Refactored.Namespace.DifferentProject". Now I added one more project(3rd project) and I added the project-1 & 2 references here.

我面临的问题是:如果我尝试使用"Namespace.Project.folder.Subfolder"从项目-1访问Project-3中的任何类。命名空间然后它显示错误消息说  "夹"在"Refactored.Namespace"中不存在。

Problem I'm facing is that: If I try to access any class in Project-3 from project-1 using "Namespace.Project.folder.Subfolder" namespace then it's showing error message saying that  "folder" does not exist in the "Refactored.Namespace".

我无法理解为什么编译器正在搜索"文件夹"。下  " Refactored.Namespace"即使我将完全限定的名称空间作为 "Namespace.Project.folder"

I'm not able to understand why compiler is searching for the "folder" under  "Refactored.Namespace" even though I'm giving fully qualified namespace as "Namespace.Project.folder"

推荐答案

您能确保将类定义为公共。如果未指定访问修饰符,则内部是默认值。在内部访问修饰符类型或成员可以由同一程序集中的任何代码访问,但不能从另一个程序集访问。
Can you make sure you class is defined as public. Internal is the default if no access modifier is specified. In Internal access modifier type or member can be accessed by any code in the same assembly, but not from another assembly.


这篇关于命名空间问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆