我怎样才能限制反射某些组件? [英] How can I restrict reflection for certain assemblies?

查看:122
本文介绍了我怎样才能限制反射某些组件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的.net应用程序我想限制反射某些组件。我的意思是我想,我的一个特定的组件可以通过pdefined只有一些$ P $组件反映不是比任何其他。我怎样才能做到这一点?

In my .net application I want to restrict reflection to certain assemblies. I mean I want that my a particular assembly can be reflected by only some predefined assemblies not by any other than that. How can i do that?

这个工具完全关闭的程序集的.NET反汇编和反编译。我想允许一些predefined组件,以反映本次大会,但限制其他人这样做。我想要的东西,应该被宣布组装聪明如AssemblyOne有给权限AssemblyTwo可以反映我的,所以只有AssemblyTwo应该能够以完全信任体现出这一点,没有其他人。

This tool completely shuts down .NET disassembly and decompilation of an assembly. I want to allow some predefined assemblies to reflect this assembly but restrict others doing this. I want something that should be declared assembly wise e.g. AssemblyOne has gives permission to AssemblyTwo that you can reflect me, so only AssemblyTwo should be able to reflect it with full trust, no one else.

推荐答案

您链接到基本编译整个应用程序到本地code的工具。这并不是真正的关机反思或其他任何东西,它只是打开应用程序到完全不同的东西,它不再字节code和不是技术上的.NET程序集了。

The tool you linked to basically compiles the entire application into native code. That doesn't really "shut down" Reflection or anything else, it just turns the application into something entirely different, it's no longer bytecode and not technically a .NET assembly anymore.

来电者以完全信任能总是使用上的.NET程序集反射,一切都在它里面。除了(一)混淆,这人有足够的耐心和决心,可以去进行模糊处理,或(b)编译为本地code,这将prevent的任意的一种反映(和其他许多有用的功能),则不能发生prevent这一点,你肯定不能把它限制在特定的组件。

Callers with full trust can always use reflection on a .NET assembly and everything inside it. Aside from (a) obfuscation, which anybody with enough patience and determination could de-obfuscate, or (b) compiling into native code, which would prevent any kind of reflection (and many other useful features), you can't prevent this from happening, and you certainly can't restrict it to specific assemblies.

ReflectionPermissionAttribute ,相反的是其他的答案中的一个说,确实的不可以 prevent从反映的的<来电/ strong>您的code;相反,它控制着从的code 的反射API的访问即可。它不会是这里的任何帮助。

The ReflectionPermissionAttribute, contrary to what one of the other answers says, does not prevent callers from reflecting on your code; rather, it controls access from that code to the Reflection APIs. It's not going to be of any help here.

为什么如此重要隐藏你的code或类结构呢?除非你的工作为国家安全局,最code只是没有有价值/秘密,大多数应用程序是很轻松进行反向工程给予足够的时间和资源。实际上,攻击者或抄袭站获得很少的抄袭code OUT反射器和/或使用反射来发现你的API。

Why is it so important to hide your code or class structure anyway? Unless you're working for the NSA, most code just isn't that valuable/secret, and most applications are trivially easy to reverse-engineer given sufficient time and resources. Realistically, an attacker or plagiarist stands to gain very little from copying code out of Reflector and/or using Reflection to discover your API.

我想我只能说我自己,但鉴于1自由的一天执行一项很酷的功能,或投资于试图保护内部code,我会一直努力的新功能,实际上增加价值。

I suppose I can only speak for myself, but given 1 free day to either implement a cool feature or invest in trying to protect the internal code, I would always work on new features that actually add value.

这篇关于我怎样才能限制反射某些组件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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