I was creating a Windows application to attack my site SharePoint 2010 when I came across a strange problem. My first test was to try to display the name of my site in my Windows Form.
A simple code that runs by clicking the button:
private void btnGO_Click(object sender, EventArgs e)
using (SPSite site = new SPSite(tbUrl.Text))
using (SPWeb web = site.OpenWeb(site.RootWeb.ID))
lblResult.Text = "Titre du site web = "+web.Title;
Nothing is more basic, but I was surprised to see the following error appears:
FileNotFound on a new SPSite when I was just surfing on it.
Being accustomed to the oddity of SharePoint I did several tests, I used “localhost: 5555” instead of the address of my server, hardcoded the link into the code, nothing to do, always wrong.
After cursing SharePoint 2010 for 10 minutes (since this code works perfectly in 2007, I admit I was a little frustrated) I browsed in the project properties and came across the next section.
And then the penny dropped, SharePoint 2010 is 64 bit … After changing it, I renewed my attempt and it wor … no, it did not work. But at least the error was different.
A small compatibility issue between SharePoint and . Net 4.0 . So I went back in to change the properties Framework to target and the 3.5
Rebuild , and then retry and it worked !
In summary, if Visual Studio 2010 is very user friendly for SharePoint component developments, yet he does not do ALL work and some settings are still to be done manually for developments “exotic”.
Hope this helps.