none
spsite = new spsite throws FileNotFoundException RRS feed

  • Question

  • Hi,

    I am using the following code in order to open the site

     using (SPSite st = new SPSite("http:/server:43681"))
    {
         using (SPWeb wb = st.OpenWeb())

    However I get the following error

    FileNotFoundException
    The Web application at http://server:43681 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.


    The site does exist, but for some reason the code does not work.  Does anyone have any idea on this?  The application pool identity I am using has access to the database as well.

    Thanks
    Arjuna.
    Friday, February 19, 2010 12:31 PM

Answers

  • Is it a console application? SharePoint 2010 is 64bit. Can you make sure your project's Build Target is x64 and the .NET Framework is 3.5?

    Regards,
    Chakkaradeep || SharePoint Developer - MCTS SharePoint Dev, WSS Dev
    http://www.intergen.co.nz || Twitter: http://twitter.com/chakkaradeep || http://www.chakkaradeep.com
    Sunday, February 21, 2010 5:17 AM

All replies

  • You will receive this error if you set up a new web application with out also setting up a root site collection. Go to "Application Management" in central administration, then go to "Create site collections", change the web application to http://server:43681 and then give it a title and select the template. Once this is done you will be able to open the SPSite and SPWeb. Hope this helps.
    certdev.com
    Saturday, February 20, 2010 5:30 AM
  • Hi Steve,

    Actually a site collection does exist and I can browse the site as well.  But unfortunately I keep getting this error.

    Thanks
    Arjuna.
    Sunday, February 21, 2010 3:43 AM
  • Is it a console application? SharePoint 2010 is 64bit. Can you make sure your project's Build Target is x64 and the .NET Framework is 3.5?

    Regards,
    Chakkaradeep || SharePoint Developer - MCTS SharePoint Dev, WSS Dev
    http://www.intergen.co.nz || Twitter: http://twitter.com/chakkaradeep || http://www.chakkaradeep.com
    Sunday, February 21, 2010 5:17 AM
  • The above post is likely correct.  Make sure your build project is x64.  More information in my post here.
    Corey Roth blog: www.dotnetmafia.com twitter: @coreyroth
    Monday, February 22, 2010 9:49 PM
  • i hv simillar problem, and i use web application not console application..when i tried to change to 64x n .Net3.5 it fail to run..any suggest? thx
    Thursday, August 11, 2011 10:19 AM
  • Leonita,

     

    You got any fix for this? Even am facing same issue.
    ~Praveen
    Tuesday, September 13, 2011 5:56 AM
    • Proposed as answer by Jeets23 Sunday, July 8, 2012 12:54 PM
    Sunday, July 8, 2012 12:54 PM
  • Hi Jeets

    it's a good habit to mention if the blog post is written by yourself (even if you wrote it today), and it's also a good habit not to propose own answers, even if this thread is more than 2 years old. And besides, it has already been answered.


    Kind Regards Bjoern
    Blog




    Sunday, July 8, 2012 3:28 PM
    Moderator