Calling internal methods in Medium Trust
-
06-07-2019 - |
Question
I have the requirement to call an internal method of a 3rd party object (I cannot make it public for example). I can do that via reflection. Unfortunately this does not work in ASP.NET Medium trust due to insufficient rights:
<IPermission class="ReflectionPermission" version="1" Flags="RestrictedMemberAccess"/></PermissionSet>
Is there any way I can internal methods in this case? I've heard that LINQ expressions can be used to call private/internal methods. Would expression methods somehow override the ReflectionPermission?
Solution
I don't see a way to call it. The .NET security/trust model is designed to prevent exactly this sort of thing. If you could somehow circumvent it, you would have to file a security bug with Microsoft which would then (hopefully) be fixed and make your solution useless again ;-)
Can't you negotiate a higher trust level with the deployer/operator of your solution?