导入/引用的问题 [英] Problems with imports / reference

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

问题描述









我试图用Sharpdevelop构建一个项目,该项目引用名称空间在一个不同的并行项目中。



我在外部命名空间的项目文件中添加了reference,并在本地文件中添加了一个IMPORTS语句。



我收到消息



项目级Imports中指定的命名空间或类型..不包含任何公开成员或无法找到...



通过将错误构建到外部项目文件和其中一个vb源文件中,我可以验证是否存在无法访问来源!



为什么.....缺少什么。



我输入了项目文件导入中的路径......没有效果。



我通过项目选项选项卡进入项目参考路径下的路径没有看到anz新条目或任何变化?!



我很沮丧?!







Herbert

Hi,



I have tried to build a project with Sharpdevelop, which references namespaces in a different parallel project.

I added "reference" to the project file of the external namespace and I added a IMPORTS statement in the local file.

I receive the message

Namespace or type specified in the project-level Imports .. doesn´t contain any public member or can not be found ...

By building in a fault into the external project file and in one of the vb source files, I could verify that there is NO access to the source!

Why..... what is missing.

I entered the path in the imports of the project file... no effect.

I entered the path under refernce path in the project via the tab "project options" and did not see anz new entry or any change ?!

I am frustrated ?!



Herbert

推荐答案

我看不到从你的描述你究竟做错了什么,但是,在这一刻,它没有意义,因为你显然你对事物的理解是错误的。你需要首先解决你的理解,如果你这样做,你就会知道自己该做什么。



没有引用命名空间这样的东西。你只做一件必不可少的事情:你引用一些其他程序集的程序集。汇编是.NET的基本概念。在其他程序集中引用程序集时,它可以访问引用程序集的所有公共声明。 (仍然可以使用Reflection访问非公开声明,但这是一个不同的故事。)



在程序集之间的这种关系中,命名空间完全无关紧要。



命名空间不控制任何意义上的访问,它们只定义顶层声明的命名方式。如果我告诉你的话,你或许可以一次理解它:你真的不需要 import 指令,这只不过是为了方便起见。如果您不使用 import ,您只需按完整(完全限定)名称命名所有顶级类型。



了解程序集和名称空间不相关非常重要。相同的程序集可以在一个,两个或更多名称空间下声明类型。可以在不同的程序集中声明相同的命名空间,即使这些程序集一起使用也是如此。不相关是无关的。



这就是你需要知道的全部。现在你可以解决你的问题,无论它是什么。



-SA
I cannot see from your description what exactly did you do wrong, but, at this moment, it does not make sense, because you apparently your understanding of things is wrong. You need to fix your understanding first, and, if you do, you will know yourself what to do.

There is no such thing as "reference a namespace". You do only one essential thing: you reference an assembly by some other assembly. Assembly is the fundamental notion of .NET. When an assembly is referenced in other assembly, it get access to all public declarations of the referenced assembly. (Non-public declaration can still be accessed using Reflection, but this is a different story.)

In this relationship between assemblies, namespaces are totally irrelevant.

Namespaces do not control access in any sense of this word, they only define how top-level declarations are named. You might be able to understand it all at once, if I tell you: you don''t really need the import directive, which is nothing more than a matter of convenience. If you don''t use import, you can simply name all top-level types by their full (fully-qualified) names.

It is important to understand that assemblies and namespaces are unrelated. The same assembly can declare types under one, two or more namespaces. The same namespace can be declared in different assemblies, even if those assemblies are used together. Unrelated is unrelated.

That''s all you need to know. Now you can sort out your problem, whatever it is.

—SA


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

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