SPSite – FileNotFoundException

You may be writing a consoleapp that uses the SPSite object. You write something like:

SPSite site = new SPSite(“http://yourSiteHere”);

Running the code produces the following error:

The Web application at http://yourSiteHere 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 inteded application.

You may need to go to your Solution properties and select Any CPU. If one doesn’t exist, you can make a copy of an existing platform to create it.

Hiding Items in the Site Actions Menu

I have a client that wanted to trim down the site actions menu to reduce clutter and confusion on their publishing site.  I originally went down the route of using

GroupId = "Text"
HideActionId = "Text"
Id = "Text"
Location = "Text">

in the element manifest but that wasn’t working.  The next attempt involved the CustomSiteAction.xml file found in the Masterpage gallery’s Editing Menu folder.

The file contains an empty Console node.  The example below shows how to remove items.  You can tell from the ChangedNodeID which item in SiteActions is being removed.  Those ID’s can be found in the v4.master or simply by viewing the page’s source.