SPFarm.Local is return null

爱⌒轻易说出口 提交于 2020-01-15 05:34:06

问题


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.


回答1:


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




回答2:


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:


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!




回答4:


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.



来源:https://stackoverflow.com/questions/7105512/spfarm-local-is-return-null

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!