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.

1 Answer 1


Visual Studio is always running in 32bit mode, therefore your .NET Addin will run in a 32bit context. So if your running on a 64bit environment this may be the reason to the problem.

  • Welcome to SharePoint overflow Carsten :-) Mar 10, 2010 at 14:03
  • Thanks Carsten - I am now developing a console application which I will execute from my add-in.
    – Anonymous
    Mar 10, 2010 at 15:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.