我在Windows Server 2003上使用Microsoft.SharePoint对象模型VS WSS扩展创建了一个C#控制台应用程序。该应用程序应该迭代WSS3.0站点以查找所有可用列表。它在服务器上运行得很好。但是如果我尝试从网络上的另一台计算机运行exe,则应用程序会立即在SPSite siteCollection = new SPSite(“http://devsharepoint)上崩溃; 即使我的尝试和捕获也没有帮助,因为没有执行捕获。
是否仅在安装了VS SharePoint扩展的计算机上运行Sharepoint对象模型应用程序?
以下是代码:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.SharePoint;
namespace ConsoleApplicationWSSobjectModel
{
class Program
{
static void Main(string[] args)
{
string url = "http://sharepoint";
Console.WriteLine("Trying to access: " + url);
try
{
SPSite siteCollection = new SPSite(url);//"http://Server_Name");
SPWebCollection sites = siteCollection.AllWebs;
foreach (SPWeb site in sites)
{
SPListCollection lists = site.Lists;
Console.WriteLine("Site: " + site.Name + " Lists: " + lists.Count.ToString());
}
Console.WriteLine("Press ENTER to continue");
Console.ReadLine();
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
}
}
}
答案 0 :(得分:9)
您不能使用SP对象模型“外部共享点”,您必须使用Web服务(或者如果您使用sharepoint 2010,则可以使用新的客户端对象模型)
答案 1 :(得分:3)
使用SharePoint对象模型构建的任何内容只能在安装了SharePoint的服务器上运行。但是,VS扩展没有依赖性。
答案 2 :(得分:0)
您可以使用C#或VB作为您的语言使用客户端对象模型。添加引用Microsoft.sharepoint.client.dll和Microsoft.sharepoint.client.Runtime.dll,它可以在14(SP2010)或15(SP2013)hive ISAPI文件夹下找到。