C# 使内部类对其他程序集可见
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/14354157/
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
Make internal classes visible to other assemblies
提问by Neir0
Is it possible to make internal classes from my assembly visible to other assemblies?
是否可以使我的程序集中的内部类对其他程序集可见?
I know about the AssemblyInfo file and the [assembly: InternalsVisibleTo()]
attribute, but it doesn't work in my case.
我知道 AssemblyInfo 文件和[assembly: InternalsVisibleTo()]
属性,但它在我的情况下不起作用。
The main purpose is to make it possible to call methods from LINQPAD, so this [assembly: InternalsVisibleTo("LINQPad")]
doesn't work. I don't know why. In my project, I'm using dependency resolver, and it is hard to do such a thing in LINQPAD. Any suggestions?
主要目的是让从 LINQPAD 调用方法成为可能,所以这[assembly: InternalsVisibleTo("LINQPad")]
行不通。我不知道为什么。在我的项目中,我使用了依赖解析器,在 LINQPAD 中很难做到这样的事情。有什么建议?
采纳答案by Joe Albahari
I've just uploaded a new betathat allows this to work.
Add the following attribute to the libraries whose internals you want LINQPad to access:
将以下属性添加到您希望 LINQPad 访问其内部的库:
[assembly: InternalsVisibleTo("LINQPadQuery")]
You'll also need to enable this feature in LINQPad's preferences (Edit | Preferences | Advanced).
您还需要在 LINQPad 的首选项(编辑 | 首选项 | 高级)中启用此功能。
Let me know how you get along.
让我知道你们相处得如何。