保护类库与其他项目 [英] Protect class library from other project

查看:85
本文介绍了保护类库与其他项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,



我只想在我的项目中使用我的类库。

我不想要其他的使用我的班级库。

任何人都可以帮助我吗?



谢谢

Hi All,

I want to use my class library only in my project.
I don''t want other can use my class library.
Any body can help me?

Thanks

推荐答案

而不是声明你的方法public将它们声明为内部。



对变量范围进行一些研究。
Instead of declaring your methods public declare them as internal.

Do some research into variable scoping.


不要分享它!!隐藏它,以便没有人能找到你的dll。



你可以使用内部访问说明符,但既然你说它是一个类库你肯定需要公开你的一些类作为Public,所以如果有人引用dll可以访问你声明为public的数据。



但是如果这些类是在dll(类库)中使用的那么你可以使用将类定义为内部

例如:

Dont share it!! Hide it somewhere so that none could find your dll.

You may use internal access specifier but since you said its a class library you definitely need to expose some of your classes as Public, so if someone referring the dll can access what ever the data you declared as public.

but if the classes are used inside a dll (class library) you can use define the class as internal
eg:
internal class MyClass
{
 internal bool CanYouSeeMe
 {
  get;
  set;
 }
}



了解有关C#中的访问说明符的更多信息@ MSDN [ ^ ]


这篇关于保护类库与其他项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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