SPFarm.Local is return null

2019-07-23 05:39发布

SPFarm.Local is return null

I have googled.

  1. x64 and x86 problem - No
  2. Access issue - No

Additional 1. Database server is up 2. Sites are opening 3. CA is opening

The account is 'System Account' under which the code is running. Always worked before. Now suddenly it started returning null.

Any ideas?

Thanks in advance.

4条回答
冷血范
2楼-- · 2019-07-23 05:57

I tried by changing from x64 or x86 to Any CPU in my VS2012 project but it didn't help. Finally i opened VS in administrator mode and it worked fine.

查看更多
我欲成王,谁敢阻挡
3楼-- · 2019-07-23 06:06

A simple server/machine restart solved the problem. Some of my friends faced similar issue and restarting solved the issue. :)

查看更多
4楼-- · 2019-07-23 06:07

If you are migrating from SharePoint 2010 to SharePoint 2013 this can happen if you use Microsoft.SharePoint assemblies from 2010 version in SharePoint 2013. Simple convert your project to use 4.5 framework and you are good to go.

查看更多
太酷不给撩
5楼-- · 2019-07-23 06:09

Quote from here:

SPFarm.Local = null. SPFarm.Local wants to create a connection to the configuration database. In order to do so, you'll need to have permissions on the configuration database. Usually the service account and the application pool accounts can read the configuration database. If you don't have the right to read the configuration database, SPFarm.Local will be null!

查看更多
登录 后发表回答