Creating an “M” Project in VS 2010.
Posted by Vadim on June 1, 2009
When you install “Oslo”, installation also adds one “Oslo” template in your Visual Studio. It’s “M” Project.
However, if you try to create a new “M” Project or open an existing one you probably will get the following error:
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 legacyCasPolicy configuration switch. Please see http://go2.microsoft.com/fwlink/?LinkId=131738 for more information.
English is not my first language, as you probably already realized that by reading my blog, but I thought that word obsolete is an adjective. In this Microsoft error message it’s used like a verb “obsoleted”.
Well, enough about English. I’m sure that you can take any of my posts and have a lot of fun criticizing my English. If you want to do so, please do. Your criticism probably will improve my English.
Let’s get back to the error. You can follow the link in the message to read more about Security Changes in the .NET Framework 4. One of the thing you can find there is that Code Access Security (CAS) policy got replaced by Windows Software Restriction Policies (SRP).
Historically, the .NET Framework has provided code access security (CAS) policy as a mechanism to tightly control and configure the capabilities of managed code. Although CAS policy is powerful, it can be complicated and restrictive. Furthermore, CAS policy does not apply to native applications, so its security guarantees are limited. System administrators should look to operating system-level solutions such as Windows Software Restriction Policies (SRP) as a replacement for CAS policy, because SRP policies provide simple trust mechanisms that apply to both managed and native code. As a security policy solution, SRP is simpler and provides better security guarantees than CAS.
However, it doesn’t tell us how we can fix our problem. After some research, I got across documentation about legacyCasPolicy Element.
Next I open devenv.exe.config file that is in C:\Program Files\Microsoft Visual Studio 10.0\Common7\IDE folder and added following line:
1: <legacyCasPolicy enabled="true"/>
You should add this line inside <runtime> element.
I understand that “Oslo” and VS 2010 are both Beta products so far. I’m sure that Microsoft will resolve this problem in future releases.
I realize that this is not the best solution. However, it worked for me. Please let me know if you can find a better solution.