user261974
user261974

Reputation:

C#: Overridden methods with Security Attributes in .Net 4

In .Net 4 some methods are now decorated with different security attributes than they were in previous versions (ie the new SecurityCriticalAttribute). In order to override methods with security permissions the relative security accessibilities on the derived declaration must match those on the base declaration (or else a runtime exception).

Legacy assemblies will have no knowledge of these new attributes, and, as the code is already compiled and the metadata already generated, we cannot load any type from those assemblies that overrides a method that now has the new attribute (as the security accessibilities do not match).

Is .Net4 intended to be compatible with pre .Net4 assemblies? If so is there a workaround/solution for this?

Upvotes: 6

Views: 579

Answers (1)

Diadistis
Diadistis

Reputation: 12174

I haven't stumbled on this one before but after some research it seems that there is legacy support by using the NetFx40_LegacySecurityPolicy option.

<configuration>
  <runtime>
    <NetFx40_LegacySecurityPolicy enabled="true" />
  </runtime>
</configuration>

Upvotes: 1

Related Questions