Sharepoint SPSite
Asked Answered
C

4

3

I am trying to create a spsite of object for sharepoint search but i am getting exception in production as website not found

SPSite site = new SPSite("sitename");
ServerContext scon = ServerContext.GetContext(site);
SearchContext srchcontext = SearchContext.GetContext(scon);
Scopes sc = new Scopes(srchcontext);

It throws exception site not found i have checked the name of site it exixts.

Any Help??

Constituent answered 30/4, 2009 at 11:54 Comment(0)
U
6

Check that you are building against the correct target. I.e. x86 vs x64. I get this error when I build against x86 and try and run against x64.

Usurp answered 27/4, 2011 at 22:21 Comment(0)
N
3

Do you have your permissions set up correctly? Check out this conversation...

http://social.msdn.microsoft.com/Forums/ja-JP/sharepointdevelopment/thread/4d923b6a-d423-4c42-82dd-3315872db9cc

You need to ensure (taken from the above) that:

  1. The user is a server farm administrator.
  2. The user has Read and Write permissions on the content database.
  3. The user is a site collection administrator.
  4. The user has permissions to access the Windows SharePoint Services site or the SharePoint Server 2007 site through which the code iterates.
Nuncia answered 30/4, 2009 at 12:16 Comment(1)
This simply cannot be the answer. I need to upload a document. Why does my service account need to be a SERVER FARM administrator?Schreibman
C
0

You should also ensure that you are using an ip address you can hit from both your local box, and the server that you are running the program on.

Before executing the program, ping the webaddress from the cmd prompt. Another way to test it is to open up the exact webaddress in a browser from the box that you are executing the program.

It's possible you are trying to hit an internal site from a server which is not on the same domain.

And finally, as it says in the MSDN Documentation you shouldn't be using "SiteName" but rather ensure that you are using "SiteAbsoluteUrl".

Cesium answered 30/4, 2009 at 12:40 Comment(0)
C
0

If you create a console application and try the same code there, the same code works. You have to add application to IIS and change the app pool identity. I did the same and it worked for me.

Carmichael answered 11/3, 2015 at 6:27 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.