Answered by:
Can't connect to site with SPSite class

Question
-
Hi guys,
I have a test MOSS portal with Visual Studio 2008 installed on aplication server. In my programm I use SPSite class to connect to MOSS site which is at the same server as Visual Studio:
[code]
SPSite testsite;
testsite = new SPSite("http://myportal/directories");
[/code]
it connects with no problem.
Then I try to connect to another MOSS site wich is resides at another server but have the same name ("http://myportal"). I make changes to hosts file so this URL-address resolves to another ip-address. Connection goes with no problem.
But if I try to connect to another sites at another MOSS portals (so I have to change code):
[code]
[code]
SPSite testsite;
testsite = new SPSite("http://anotherportal/directories");
[/code]
I got an error message "FileNotFound" that says that web application can't be found. I tried to connect to several MOSS portals with the same result.
Eventually I can connect to "http://myportal" portal no matter localy or on network and I can't connect to any other portals.
I've found lots of similar problem description but none of them help me. I run Visual Studio under account which have all possible privileges at all portals application and db servers. Also I can open all these portals at Visual Studio browser so it's not a dns issue.
Any ideas on this issue are welcomeFriday, September 4, 2009 7:06 AM
Answers
-
Hi,
You cannot connect or access moss sites residing on another server through object model.
You will have to use webservices.
Hope that helps, Abdul Khalid.- Proposed as answer by aimin.han Friday, September 4, 2009 7:43 AM
- Marked as answer by Chengyi Wu Friday, September 11, 2009 7:33 AM
Friday, September 4, 2009 7:29 AM -
You can join both servers in the same farm. the object model can access site in the same farm.
Hope it helpful to you!
coding- Proposed as answer by aimin.han Friday, September 4, 2009 7:43 AM
- Marked as answer by Chengyi Wu Friday, September 11, 2009 7:33 AM
Friday, September 4, 2009 7:43 AM -
If you run your console application in the portal server in the same farm, of course you can.
In the same farm, all sites share the same configuration database
coding- Marked as answer by Chengyi Wu Friday, September 11, 2009 7:33 AM
Friday, September 4, 2009 8:03 AM -
I'll just add that SPSite = site collection (though it can work like a site some times).
SPWeb = a site.
It's a historical thing that carried forward from earlier version of sharepoint.
--Paul Galvin, Arcovis
Microsoft MVP - SharePoint
Blogging @ http://feeds.feedburner.com/PaulGalvinsSharePointSpace
Twitter @ http://www.twitter.com/pagalvin- Marked as answer by Chengyi Wu Friday, September 11, 2009 7:32 AM
Friday, September 4, 2009 1:01 PM
All replies
-
Hi,
You cannot connect or access moss sites residing on another server through object model.
You will have to use webservices.
Hope that helps, Abdul Khalid.- Proposed as answer by aimin.han Friday, September 4, 2009 7:43 AM
- Marked as answer by Chengyi Wu Friday, September 11, 2009 7:33 AM
Friday, September 4, 2009 7:29 AM -
You can join both servers in the same farm. the object model can access site in the same farm.
Hope it helpful to you!
coding- Proposed as answer by aimin.han Friday, September 4, 2009 7:43 AM
- Marked as answer by Chengyi Wu Friday, September 11, 2009 7:33 AM
Friday, September 4, 2009 7:43 AM -
If I make a console application and run it on any of my portal servers localy will it work?Friday, September 4, 2009 7:58 AM
-
If you run your console application in the portal server in the same farm, of course you can.
In the same farm, all sites share the same configuration database
coding- Marked as answer by Chengyi Wu Friday, September 11, 2009 7:33 AM
Friday, September 4, 2009 8:03 AM -
I'll just add that SPSite = site collection (though it can work like a site some times).
SPWeb = a site.
It's a historical thing that carried forward from earlier version of sharepoint.
--Paul Galvin, Arcovis
Microsoft MVP - SharePoint
Blogging @ http://feeds.feedburner.com/PaulGalvinsSharePointSpace
Twitter @ http://www.twitter.com/pagalvin- Marked as answer by Chengyi Wu Friday, September 11, 2009 7:32 AM
Friday, September 4, 2009 1:01 PM