“The type or namespace name ‘SharePoint’ does not exist in the namespace ‘Microsoft’ (are you missing an assembly reference?”
(Even you add Microsot.SharePoint.dll reference in your project and import the namespace in code but while building the solution you will get above mentioned annoying error.)
“FileNotFoundException was unhandled: The Web application at http://localhost/ 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.”
(When you initialize the SPSite class in your code the above mentioned error will thrown. Well some people suggest that in place of localhost you should use machine name or ip of the machine but trust me I used all tricks but even then I couldn’t get rid of above mentioned error)
The above two problems are most annoying when you develop an application for SharePoint 2010 using Visual Studio 2010. Well no problems below are the solution of above two problems. Before writing the code just check for two things that are by default set by Visual Studio 2010 and need to change.
- Right Click on your project (Not your solution).
- Click on Properties.
- On project properties page, Click on Application tab.
- Under Target Framework select .NET Framework 3.5 in drop down list.
- Click on save button in toolbar.
- Now click on Build tab.
- In Platform Target, select x64 option.
- Click on save and close the project properties page.
Build and run the application and it would work fine now 🙂