I have a weird problem so I'm going to see if the SharePoint community can help shed some light on this.
I am developing a Visual Studio 2008 Add-In which creates some menu items on the 'Project' context menu within the Solution Explorer pane.
When clicking these buttons my code needs to interact with SharePoint - specifically it needs to get a reference to the SPFarm class. I am trying to loop through the solutions that are installed in the farm.
The problem I am having is that SPFarm.Local always returns null and in addition to this I cannot access SharePoint from the code at all - I have also tried the following:
Using (SPSite site = new SPSite("http://myserver"))
{
}
SPAdministrationWebApplication webapp = SPAdministrationWebApplication.Local;
I have read quite a few blog posts that talk about this being an x64 and x86 issue so Ive tried recompiling for both x86 and x64 platforms and that doesn't make a difference. Ive tried downgrading the version of .NET framework from 3.5 to 3.0 and putting my SharePoint code in its own custom class in case the 'connect.cs' class provided by the add-in was causing problems.
I am really stuck as for where to go next with this problem - the strange thing is that I can access SPFarm.Local from a console application just not the add-in.