本文介绍了如何prevent他人使用我的.NET程序集?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我应该的不可以要使用非指定可执行的其他任何应用程序的组件。请给我一些指示这样做的。
I have an assembly which should not be used by any application other than the designated executable. Please give me some instructions to do so.
推荐答案您可以登录装配和使用相同的密钥的可执行文件,然后把支票在类的构造函数要保护:
You can sign the assembly and the executable with the same key and then put a check in the constructor of the classes you want to protect:
public class NotForAnyoneElse { public NotForAnyoneElse() { if (typeof(NotForAnyoneElse).Assembly.GetName().GetPublicKeyToken() != Assembly.GetEntryAssembly().GetName().GetPublicKeyToken()) { throw new SomeException(...); } } }更多推荐
如何prevent他人使用我的.NET程序集?
发布评论