I am doing an MxRecordLookup. I am getting an error when calling the DnsRecordListFree in the .NET Framework 4.0. I am using Windows 7. How do I get around it? Here is t
Read Security Changes in the .NET Framework 4 to understand what transparent and critical code is. By default, in .NET 4, any code in an assembly marked with AllowPartiallyTrustedCallersAttribute
is transparent, which means it cannot call critical code (code marked with SecurityCriticalAttribute
). Only security safe critical (marked with SecuritySafeCriticalAttribute
) or critical code can call critical code. And security safe critical can be called by transparent called.
In short:
Transparent can call Transparent or Security Safe Critical
Security Safe Critical can call Security Safe Critical or Critical
Critical can call Critical
Enable Code Analysis with the Microsoft Security rules set to see warnings about bad security calls. Note that you can revert back to how security worked in .NET Framework 2.0 (all code is critical) by applying [assembly: SecurityRules(SecurityRuleSet.Level1)]
or removing AllowPartiallyTrustedCallersAttribute
. See Security-Transparent Code, Level 2 for more information.
To comply with the new rules, GetMXRecords
should become SecuritySafeCritical
and the DLL import calls must be marked with SecurityCritical
.