SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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.

Thanks for any help in advance!



share|improve this question
up vote 3 down vote accepted

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.

share|improve this answer
Welcome to SharePoint overflow Carsten :-) – Anders Rask Mar 10 '10 at 14:03
Thanks Carsten - I am now developing a console application which I will execute from my add-in. – Anonymous Mar 10 '10 at 15:24

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.