0

I have googled it but am unable to find the correct answer to this problem. Below is my code that I used in my development server. Please tell me the exact solution related to that problem:

The Web application at [URL] could not be found. Verify that you have typed the URL correctly. If the URL should be serving existing content, the system administrator may need to add a new request URL mapping to the intended application.

using (SPSite _Site = new SPSite("http://demo2010a:8082/sites/Test2"))
{
    using (SPWeb _Web = _Site.OpenWeb())
    {
        foreach (SPList list in _Web.Lists)
        {
            if (count <= 4)
            {
                string listLink = "<a  href='" + list.DefaultView.Url.ToString() + "'>" + list.Title + "</a>(<b>" + list.Items.Count + "</b>)<br>";
                linksHtml += listLink;
            }
            count++;
        }

    }
}

4 Answers 4

2

Do you build against x64 and against the 3.5 framework?

Regards,

Kjetil Hovding Crayon, Oslo

2
  • I do not know about X64. But yes i am using 3.5 framwork. Jun 14, 2010 at 11:28
  • 1
    Make sure that your build target is x64 or any CPU Jun 14, 2010 at 12:12
1

I was stung by the same problem and found it to be the Build option, Platform Target in my VS project Properites was set to x86. Changed to Any CPU or x64 to solve the problem.

0

How is your code executed? Webpart? Feature? CLI?

Is there some other way to open the site collection, such as Context?

If not, have you tried opening the root site collection first, and then try your Test2 site collection?

1
  • I am geeting same error. while opning site from root site collection Jun 14, 2010 at 12:11
0

please check the alternate access mappings in cenztral administration. The URL must be configured. Maybe your created the application with host header and the AAM is not what your are using in your code. If you confired the iis site manualy sharepoint "may" seem to work correct, but unless AAM is configured it is only working somehow :-)

SO check your AAM and see if http://demo2010a:8082 is there. FQDN is something different... etc. It must match. No SSL, etc. Exact match :-)

Using the object model seems to use the URL to access it via HTTP, but all it does is making a SQL query to the database to see if the HOST part of your URL is a valid AAM entry.

Ciao Marco

AAM Link: http://<>/_admin/AlternateUrlCollections.aspx

PowerSHell test code: [System.reflection.Assembly]::LoadWithPartialName(“Microsoft.SharePoint”) $site = new-object Microsoft.SharePoint.SPSite("http://demo2010a:8082/sites/Test2")

2
  • I have set the cenztral administration Following settings. Internal URL Zone Public URL for Zone demo2010a:8082 Default demo2010a:8082 Please let me know it correct... Jun 15, 2010 at 7:09
  • I have added a powershell sample you can try. Did you add the urls or did they allready exist? Jun 15, 2010 at 7:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.