c# - Security Transparent alternative for RuntimeHelpers.PrepareDelegate -
i need pre-jit emitted delegates ahead of time , tried using runtimehelpers.preparedelegate this, method marked securitycritical
attribute. assembly marked allowpartiallytrustedcallers
attribute , can hence not phone call security critical code.
why preparedelegate
, preparemethod
security critical , alternatives alternatives have in pre-jitting delegates?
as referenced in msdn article ca2140: transparent code must not reference security critical items:
how prepare violations
to prepare violation of rule, 1 of following:
mark code element uses security critical code securitycriticalattribute
attribute
- or -
remove securitycriticalattribute
attribute code elements marked security critical , instead mark them securitysafecriticalattribute
or securitytransparentattribute
attribute.
you have mark method pre-jiting [securitysafecriticalattribute]
. here in action:
using system; using system.runtime.compilerservices; using system.reflection; using system.security; [assembly: allowpartiallytrustedcallers] namespace consoleapplication1 { class programme { static void main(string[] args) { prejit(); } [securitysafecritical] static void prejit() { runtimehelpers.preparemethod( system.reflection.emit.dynamicmethod.getcurrentmethod() .methodhandle); } } }
c# .net code-access-security
No comments:
Post a Comment