none
Code Access Security Policy Compatibility and Migration RRS feed

  • Question

  • I have migrated from .NET Framework 3.5 to 4.0. Now compilation warnings appears in compilation time like:

    warning CS0618: '' is obsolete: 'This method is obsolete and will be removed in a future release of the .NET Framework. Please use . See for more information.'

    and exception of type NotSupportedException is raised in run-time:

    NotSupportedException : This method uses CAS policy, which has been obsoleted by the .NET Framework. In order to enable CAS policy for compatibility reasons, please use the configuration switch. Please see for more information.

    I have read what microsoft says about it and there are two solution, replace obsolete calls or using the configuration element as described here

    using configuration element is clear but I would like to replace obsolete calls instead. So in my code I have:

    System.CodeDom.Compiler.CompilerParameters compilerParams = new CompilerParameters();
    compilerParams.Evidence = AppDomain.CurrentDomain.Evidence;

    and I am trying to replace the obsolete call compilerParams.Evidence by the equivalent in NET Framework 4 but I do not know what is.

    Using VS2010, C# and .NET Framework 4.

    Wednesday, January 16, 2013 9:59 PM

Answers