2

Am I correct that if I need maximum performance, and I have trusted library I should just set SuppressUnmanagedCodeSecurity attribute to all Dll imports I have?

I.e. convert such import:

    [DllImport("srl.dll", CharSet = CharSet.Ansi)]
    private static extern string ErrorMsg(int ErrCode);

to such import:

    [DllImport("srl.dll", CharSet = CharSet.Ansi), SuppressUnmanagedCodeSecurity]
    private static extern string ErrorMsg(int ErrCode);

everywhere.

Are there any reasons not to set SuppressUnmanagedCodeSecurity?

Oleg Vazhnev
  • 23,239
  • 54
  • 171
  • 305
  • You can also set `SuppressUnmanagedCodeSecurity` on the *class* containing your P/Invoke method declarations, and it will apply to all methods declared within that class. – Sam Harwell May 14 '13 at 15:11

0 Answers0