.net 未声明。由于其保护级别,它可能无法访问
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/4221635/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
not declared. It may be inaccessible due to its protection level
提问by VJK
I have 2 WinForm Apps.
我有 2 个 WinForm 应用程序。
A completed, working WinFormApp1 has a reference to CompanyName.BusinessObjects.dll.
一个完整的、工作的 WinFormApp1 有一个对 CompanyName.BusinessObjects.dll 的引用。
A fresh WinForm app with nothinhg in it has a reference to BusinessObjects.dll. when I type "Import CompanyName.BusinessObjects" intellisense recognized it and shows available methods when I reference contained objects.
一个没有任何内容的新 WinForm 应用程序引用了 BusinessObjects.dll。当我输入“Import CompanyName.BusinessObjects”时,intellisense 识别出它并在我引用包含的对象时显示可用的方法。
However,. when I compile it, I get the error "not declared. It may be inaccessible due to its protection level." and it seems to no longer recognize the BusinessObjects project.
然而,。当我编译它时,我收到错误“未声明。由于其保护级别,它可能无法访问。” 它似乎不再识别 BusinessObjects 项目。
I swear this is a bug. This happened once before and I think I was able to clear it by bouncing VS2010, cleaning and recompiling all.
我发誓这是一个错误。这以前发生过一次,我想我可以通过弹跳 VS2010、清理和重新编译所有内容来清除它。
Now, nothing helps.
现在,没有任何帮助。
I'm desperate and ticked off because I think its a bug and I don't know how to resolve it.
我很绝望并且被打勾,因为我认为这是一个错误,我不知道如何解决它。
Herepeople talk of the same issue and resolution that previously worked but it isn;t working for me anymore.
在这里人们谈论以前有效的相同问题和解决方案,但它不再适合我了。
回答by VJK
Answer: Look to the Output window for clues.
答案:查看输出窗口寻找线索。
BusinessObjects.dll" could not be resolved because it has a dependency on "System.Web, Version=4.0.0.0, Culture=neutral
My client app was compiled against the CLIENT framework instead of the full blown one. The solution is to compile against the full, or preferably remove the Web dependency from BO, which is a pain now after the fact.
我的客户端应用程序是针对 CLIENT 框架而不是完整的框架编译的。解决方案是针对完整的编译,或者最好从 BO 中删除 Web 依赖项,这在事后现在很痛苦。
回答by Off The Gold
This happened to me and I found out that all it was that my .designerfile had a Namespaceincluded in the top. Deleting this fixed the projection issues.
这发生在我身上,我发现这只是我的.designer文件Namespace包含在顶部。删除它修复了投影问题。
回答by Eric
Is there anything in BusinessObjects that is declared as internal?
BusinessObjects 中是否有声明为内部的内容?
I think it might be a namespaces problem. Make sure everything is in the same Namespace then try again.
我认为这可能是命名空间问题。确保所有内容都在同一个命名空间中,然后重试。
回答by Raymund
Have you tried running your IDE i guess is Visual Studio as an Administrator?
您是否尝试过以管理员身份运行您的 IDE,我猜是 Visual Studio?

