tags:

views:

66

answers:

3

I create a C# console application using Microsoft.SharePoint object model VS WSS extensions on Windows Server 2003. The application is supposed to iterate WSS3.0 sites looking for all available lists. It runs just fine on the server. But if I try to run the exe from another computer on the network, the application crashes instantly on SPSite siteCollection = new SPSite("http://devsharepoint); Even my try and catch doesn't help as catch is not executed.

Is it intended to run the Sharepoint object model applications only on machines with VS SharePoint extensions installed?

Here is the code:

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);
            }

        }
    }
}
+6  A: 

You cannot use the SP object model ”outside sharepoint” you will have to use web services (or if your go with sharepoint 2010 you can use the new client object model)

Danielvg
+1  A: 

Anything built with the SharePoint object model can only run on a server with SharePoint installed. There is however no dependency on the VS extensions.

Tom Clarkson
Oh, dear... Well, back to web services then ;-)Thank you all.
val
@Val: Mark it as answered, it will help someone in need.
Kusek
A: 

SharePoint 2010 is came up with new concept called Client Object Model. This is one of the great and excellent feature which can help developers. Through which we can do more than what we were able to do in SharePoint 2007. This great feature came up with 3 options and all the complete information is listed here very clearly. Hope this helps.

Rare Solutions