I am trying to setup web application project in visual studio 2012 that my boss just gave me for setup.
When I was opening project in VS by .sln
file it gives me following error:
The imported project "..\.nuget\nuget.targets" was not found. Confirm that path in the ,<Import> declaration is correct and that the file exist on disk.
So I found the solution on SO and removed following line form .csproj
file:
<Import Project="$(SolutionDir)\.nuget\nuget.targets" />
and reload the project this time it opened correctly but when I built the project it gave following error:
Assembly 'System.Web.Http.Cors, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' uses 'System.Web.Http, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' which has a higher version than referenced assembly 'System.Web.Http, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'
and this is packages.config
file:
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="AutoMapper" version="3.1.0" targetFramework="net45" />
<package id="EntityFramework" version="6.0.0-beta1" targetFramework="net45" />
<package id="Microsoft.AspNet.Cors" version="5.0.0-beta2" targetFramework="net45" />
<package id="Microsoft.AspNet.Mvc" version="4.0.30506.0" targetFramework="net45" />
<package id="Microsoft.AspNet.Mvc.FixedDisplayModes" version="1.0.1" targetFramework="net45" />
<package id="Microsoft.AspNet.Razor" version="2.0.30506.0" targetFramework="net45" />
<package id="Microsoft.AspNet.WebApi" version="4.0.30506.0" targetFramework="net45" />
<package id="Microsoft.AspNet.WebApi.Client" version="5.0.0-beta2" targetFramework="net45" />
<package id="Microsoft.AspNet.WebApi.Core" version="5.0.0-beta2" targetFramework="net45" />
<package id="Microsoft.AspNet.WebApi.Cors" version="5.0.0-beta2" targetFramework="net45" />
<package id="Microsoft.AspNet.WebApi.WebHost" version="4.0.30506.0" targetFramework="net45" />
<package id="Microsoft.AspNet.WebPages" version="2.0.30506.0" targetFramework="net45" />
<package id="Microsoft.AspNet.WebPages.Data" version="2.0.20710.0" targetFramework="net45" />
<package id="Microsoft.AspNet.WebPages.WebData" version="2.0.30506.0" targetFramework="net45" />
<package id="Microsoft.Web.Infrastructure" version="1.0.0.0" targetFramework="net45" />
<package id="Mvc4Futures" version="4.0.20710.0" targetFramework="net45" />
<package id="Newtonsoft.Json" version="5.0.6" targetFramework="net45" />
</packages>
I then installed Microsoft.AspNet.WebApi 4.0.30506.0
and Microsoft.AspNet.WebApi.Cors 5.0.0-beta2
from package manager console.
Now the project built successfully but when I am executing the project, i am getting following error:
Attempt by security transparent method 'System.Web.Http.Cors.EnableCorsAttribute..ctor(System.String, System.String, System.String, System.String)' to access security critical method 'System.Web.Cors.CorsPolicy..ctor()' failed.
Assembly 'System.Web.Http.Cors, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' is marked with the AllowPartiallyTrustedCallersAttribute, and uses the level 2 security transparency model. Level 2 transparency causes all methods in AllowPartiallyTrustedCallers assemblies to become security transparent by default, which may be the cause of this exception.
at this line:
var cors = new EnableCorsAttribute("*", "*", "*");
Please guide me.
Thanx.