I'm currently working on a game which has the possibility to create a custom AI which will then get called through reflection. Now I want to deny the use of reflection inside the dll.
for calling methods inside the DLL I'm using this:
Assembly DLL = Assembly.LoadFile(pathToDLL);
type = DLL.GetType("Namespace.Sample");
instance = Activator.CreateInstance(type);
type.InvokeMember("methodName", BindingFlags.InvokeMethod | BindingFlags.Instance | BindingFlags.Public, null, instance, new Object[0]);
Now the problem is that inside the dll, there is the possibility to changes private attributes through reflection. There is only one class inside the dll which need to extend a class in my assembly.
I've already tried to do it with
[ReflectionPermission(SecurityAction.Deny, TypeInformation = true)]
but that do not get inherited.
Aucun commentaire:
Enregistrer un commentaire