So instead of banging my head against the wall for another couple of hours, I thought I'd just double check a few things here.

First of all, I've been trying to access lists stored on a SharePoint 2007 server (which I should start off by saying is out of my control minus the fact that I'm a member of it who can edit list information) through Visual Studio 2010 on a Windows 7 64bit computer (that is not associated with the server in any real way). I say out of my control because a) the application I'm writing can't be stored on the server comp and b) I can't reconfigure any part of the server (since it's, well, out of my control and such...)

I started off by using web services to read the listitems from a certain list, which worked (to a certain extent.) I couldn't do any more testing because it was immediately recommendeded that I stop using that method and instead try to use SharePoint's own services (like by using Microsoft.Sharepoint and the respective .dll in my project.) I found plenty of tutorials on how to go about doing this online, but I keep getting hung up on one part: namely, the SPSite portion.

I know this question has been brought up dozens of times, but I just can't be sure of what exactly I need control over in order to get this working. Upon reaching this line of code:

SPSite siteCollection = new SPSite(siteUrl);

it fails every time. (Note that siteUrl is a string that leads to a working URL of the server that worked with the web services, so I don't see why it wouldn't work now.)

I've tested multiple .Net Frameworks (3.5, 4.0...) and changed my architecture around from x86 to x64 to Any CPU and it still always fails. Now I need credentials to get onto this website, so I'm assuming that's why I can't access it. Is there some sort of credentials I need to associate with my program in order to get this to work? Or would it ask for them if it successfully accessed that site?

Sorry for all of the confusion here, my mind has just been melting from trying to absorb all of this so quickly.

(On a little sidenote, is the .Net Framework requirement of 3.5 strict? Because this is a Microsoft Surface app, which means it needs a minimum of 4.0...) :P

有帮助吗?

解决方案

The SharePoint server-side object model you were recommended to use can't be used for your scenario. It only works when run on a server that is a part of the SharePoint farm (which your code won't in this scenario). Since you're on 2007 (no client object model), you're stuck with the webservices (or writing and deploying your own web service code to a server in the SharePoint farm, which your code then calls).

其他提示

Is this code running in the same App Pool as the SharePoint website? If not, your easiest bet would be to use the list service (/_vti_bin/Lists.asmx). SharePoint 2010 added the Client Object Model, but obviously you're excluded from that. Example code can be found here.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top