1
votes

I'm developing an MS Word 2010 add-in (using C#), which has a custom Ribbon tab. In that tab there is a button, which should open a particular Word document (MyTemplate.docx), which is located in SharePoint 2010 server's Shared Documents library. The URL of my development server (internal) is 'http://sharepoint2010'. I'm trying to use SP object model elements, such as SPSite, SPWeb, etc... When I try :

SPSite site = new SPSite(@"http://sharepoint2010");

I get error: "The Web application at 'http://sharepoint2010' could not be found"

I do have a valid Web Service Reference:

HomeDataContext dc = new HomeDataContext(new Uri("http://sharepoint2010/_vti_bin/listdata.svc"));

which allows me to obtain a listing of documents in the Shared Documents library. I'm able to iterate through that list and obtain individual SharedDocumentItem, but I don't understand how to open it as a Word document.

1

1 Answers

1
votes

You cannot use SharePoint object model in a remote-access scenario. The object model (mostly represented by Microsoft.SharePoint.dll) depends on the server code, so it can be used on the SharePoint server only. That's why instantiating SPSite will always throw an exception.

Also note that the URL passed to SPSite has nothing to do with accessing a site via HTTP, web services or whatever. It's interpreted as the server-side locator of the site collection.

Should you really need it client-side, have a look client object model.