使用SPList操作SharePoint数据出现 Microsoft .Net Runtime 的版本不支持 Microsoft SharePoint

电脑技术爱好者 2015-10-12 12:08:48
运行 using (SPSite spsite = new SPSite("http://localhost/"))这句话后报错:


请问是怎么回事呢?
...全文
184 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
  • 打赏
  • 举报
回复
引用 3 楼 legendgod 的回复:
你是不是用SharePoint 2010 + PowerShell 3.0? 因為SP2010預設只支持PowerShell 2.0,

參考這個做法:

•Type "PowerShell -v 2" (without quotes). This loads PowerShell version 2, and you should be able to use it for SharePoint. Just type 'Exit' to get back to PowerShell v3
•Add '-version 2.0' parameter when executing PowerShell 3.0, and SharePoint integration should work.
•Change the Target field value for SharePoint 2010 Management Shell to the following:


C:\Windows\System32\WindowsPowerShell\v1.0\PowerShell.exe -Version 2.0 -NoExit " & ' C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\CONFIG\POWERSHELL\Registration\\SharePoint.ps1 ' "


引用 3 楼 legendgod 的回复:
你是不是用SharePoint 2010 + PowerShell 3.0? 因為SP2010預設只支持PowerShell 2.0,

參考這個做法:

•Type "PowerShell -v 2" (without quotes). This loads PowerShell version 2, and you should be able to use it for SharePoint. Just type 'Exit' to get back to PowerShell v3
•Add '-version 2.0' parameter when executing PowerShell 3.0, and SharePoint integration should work.
•Change the Target field value for SharePoint 2010 Management Shell to the following:


C:\Windows\System32\WindowsPowerShell\v1.0\PowerShell.exe -Version 2.0 -NoExit " & ' C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\CONFIG\POWERSHELL\Registration\\SharePoint.ps1 ' "


引用 3 楼 legendgod 的回复:
你是不是用SharePoint 2010 + PowerShell 3.0? 因為SP2010預設只支持PowerShell 2.0,

參考這個做法:

•Type "PowerShell -v 2" (without quotes). This loads PowerShell version 2, and you should be able to use it for SharePoint. Just type 'Exit' to get back to PowerShell v3
•Add '-version 2.0' parameter when executing PowerShell 3.0, and SharePoint integration should work.
•Change the Target field value for SharePoint 2010 Management Shell to the following:


C:\Windows\System32\WindowsPowerShell\v1.0\PowerShell.exe -Version 2.0 -NoExit " & ' C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\CONFIG\POWERSHELL\Registration\\SharePoint.ps1 ' "


引用 3 楼 legendgod 的回复:
你是不是用SharePoint 2010 + PowerShell 3.0? 因為SP2010預設只支持PowerShell 2.0,

參考這個做法:

•Type "PowerShell -v 2" (without quotes). This loads PowerShell version 2, and you should be able to use it for SharePoint. Just type 'Exit' to get back to PowerShell v3
•Add '-version 2.0' parameter when executing PowerShell 3.0, and SharePoint integration should work.
•Change the Target field value for SharePoint 2010 Management Shell to the following:


C:\Windows\System32\WindowsPowerShell\v1.0\PowerShell.exe -Version 2.0 -NoExit " & ' C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\CONFIG\POWERSHELL\Registration\\SharePoint.ps1 ' "

我只是个sharepoint入门者,没明白您说的是什么意思。。。还是要谢谢您。 这个问题解决了:把程序的目标框架改成.NET Framework 3.5就没有问题了。
  • 打赏
  • 举报
回复
你是不是用SharePoint 2010 + PowerShell 3.0? 因為SP2010預設只支持PowerShell 2.0,

參考這個做法:

•Type "PowerShell -v 2" (without quotes). This loads PowerShell version 2, and you should be able to use it for SharePoint. Just type 'Exit' to get back to PowerShell v3
•Add '-version 2.0' parameter when executing PowerShell 3.0, and SharePoint integration should work.
•Change the Target field value for SharePoint 2010 Management Shell to the following:


C:\Windows\System32\WindowsPowerShell\v1.0\PowerShell.exe -Version 2.0 -NoExit " & ' C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\CONFIG\POWERSHELL\Registration\\SharePoint.ps1 ' "
  • 打赏
  • 举报
回复
引用 1 楼 FoxDave 的回复:
你创建的是什么类型的项目?

控制台项目
Justin-Liu 2015-10-12
  • 打赏
  • 举报
回复
你创建的是什么类型的项目?

3,245

社区成员

发帖
与我相关
我的任务
社区描述
企业开发 SharePoint
社区管理员
  • SharePoint社区
  • 霖雨 - LinyuLoveTJ
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧