Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

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!

Cheers,

Alex

share|improve this question
add comment

1 Answer

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
add comment

Your Answer

 
discard

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