Answered spsite = new spsite throws FileNotFoundException

  • Friday, February 19, 2010 12:31 PM
     
     
    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.

Answers

  • Sunday, February 21, 2010 5:17 AM
    Moderator
     
     Answered
    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

All Replies

  • Saturday, February 20, 2010 5:30 AM
     
     
    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
  • Sunday, February 21, 2010 3:43 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 5:17 AM
    Moderator
     
     Answered
    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
  • Monday, February 22, 2010 9:49 PM
     
     
    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
  • Thursday, August 11, 2011 10:19 AM
     
     
    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
  • Tuesday, September 13, 2011 5:56 AM
     
     

    Leonita,

     

    You got any fix for this? Even am facing same issue.
    ~Praveen