The server instance specified was not found. Please specify the server's address and port.
SPSite MySite = new SPSite(http://spsite);
String SiteURL = MySite.Url.ToString ();
This may occur due to the fact that virtual server of the site is assigned a specific IP address (instead of "All Unassgined" configuration) and server name is mapped in Domain Control (DNS). In these cases, WSS will not query DNS to resolve the host name since the hostname is not mapped in the metabase.
Assign a host header name to the IP address that is configured for the virtual server in IIS. By doing so, Windows SharePoint Services can map the virtual server to the host name. To assign a host header name for a virtual server in IIS, follow these steps:
- Start Internet Information Services (IIS) Manager.
- Expand ServerName, and then expand Web Sites.
- Right-click the Web site that you want, and then click Properties.
- Click the Web Site tab, and then under Web site identification, click Advanced.
- Under Multiple identities for this Web site, click Add.
- In the Add/Edit Web Site Identification dialog box, specify an IP address, TCP port, and host header value, and then click OK
- Click OK, and then click OK.
- If the IP address of the virtual server in IIS is set to All Unassigned, perform the operation on the virtual server by using the server name.
- Perform the operation on the virtual server by using the IP address that is assigned to the virtual server.