Error: System.IO.FileNotFoundException was unhandled by user code

Title: Error(s) while running SharePoint 2010 projects using Visual Studio 2010

Details: Have you encountered the below errors while you are running SharePoint 2010 projects using Visual Studio 2010?

System.IO.FileNotFoundException was unhandled by user code
Message="The Web application at http://sp2010/ could not be found. Verify that you have typed the URL correctly. If the URL should be serving existing content, the system administrator may need to add a new request URL mapping to the intended application."

or

Request for the permission of type 'Microsoft.SharePoint.Security.SharePointPermission, Microsoft.SharePoint.Security, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c' failed.

Resolution: Verify what framework you are running against. By default Visual Studion 2010 runs with .NET Framework 4.0 and SharePoint 2010 is built against to run on .NET Framework 3.5.
Change you project settings to run against 3.5 and you should be good

Comments

Anonymous said…
Hi,
I tried changing target framework to 3.5 plus I have changed target CPU to 64x. Nothing seems to work for me...
Please help...
Srini Sistla said…
Are you running VS 2010? Did you also verify with 'Any CPU' mode?
http://spserver2010.blogspot.com/2010/09/visual-studio-2010-beta-console.html