Monday, September 27, 2010

The little things will get you.

I was recently writing a windows forms application that would run on a SharePoint server and run a set of actions if a solution was deployed. I used the standard approach of getting the solution by its ID from the solutions in the farm.

image

When I hit the SPFarm object the Local property was null.

image

How could SPFarm.Local be null?

The project had been given x86 by default when creating it in Visual Studio, and 32-bit application can’t call the SharePoint 2010 64bit Object Model.

image

Quick change to the Platform target and its good to go.

image

image

If your finding this post and changing your platform does not fix your issue, make sure you look at your permission too. You need to have permission to access the farm.

1 comment:

  1. This got me the first several times I wrote a throw away Console app against 2010... hopefully I remember next time and won't bang my head against the wall. :)

    ReplyDelete