0

我正在使用 Visual Studio 2010 并尝试构建一个小型控制台程序,以使用 UserProfileManager 在 Sharepoint 2010 中向用户添加数据。

**使用系统;

使用 System.Collections.Generic;

使用 System.Linq;

使用 System.Text;

使用 Microsoft.SharePoint;

使用 Microsoft.Office.Server.UserProfiles;

使用 System.DirectoryServices.AccountManagement;

使用 System.IO;**

我遇到的问题是尝试构建它。如果我的目标框架是 4.0,它构建得很好,但因此不会在部署 sharepoint 的服务器上运行:

*未处理的异常:System.PlatformNotSupportedException:Microsoft .Net 运行时版本 4.0.30319.269 不支持 Microsoft SharePoint。在 Microsoft.SharePoint.Administration.SPConfigurationDatabase.get_Farm() 在 Microsoft.SharePoint.Administration.SPFarm.FindLocal(SPFarm& farm, Boolean & isJoined) 在 Microsoft.SharePoint.SPSite..ctor(String requestUrl) 在 AddRandomMindtags.Program.Main(字符串 [] 参数)*

当目标框架设置为 3.5 时,会出现以下构建错误:

*名称空间“Microsoft”中不存在类型或名称空间名称“Office”(您是否缺少程序集引用?)

找不到类型或命名空间 UserProfileManager...*

有人知道问题可能是什么吗?

非常感谢 :)

4

1 回答 1

0

您可能知道 SP 2010 是在 3.NET Framework 3.5 之上构建的,因此在部署 SP 2010 Server 时不能使用 4.0 DLL。

还有更多关于你试图用 UserProfiles 做什么?

您可以添加此 DLL 的引用,以便解决您的上述错误。C:\Program Files (x86)\Microsoft Chart Controls\Assemblies\System.Web.DataVisualization.dll

谢谢,-桑托什

于 2012-06-03T17:31:16.493 回答