Freigeben über


Debugging SharePoint – Web application could not be found Issue

Sometimes when I debug my SharePoint code from Visual Studio, I get the exception:

System.IO.FileNotFoundException was unhandled
Message=The Web application at https://jl-sp2010/ 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.
Source=Microsoft.SharePoint
StackTrace:
at Microsoft.SharePoint.SPSite..ctor(SPFarm farm, Uri requestUri, Boolean contextSite, SPUserToken userToken)
at Microsoft.SharePoint.SPSite..ctor(String requestUrl)
at SPConsoleApplication_SPRouterRule.Program.Main(String[] args) in C:\Install\SPConsoleApplication_SPInstall.Solution\SPConsoleApplication_SPRouterRule\Program.cs:line 33
at System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
InnerException:

Most often this is due to one of three things:

  • Must run as administrator
  • Wrong target framework
  • Wrong target application

 

Run as administrator

The Visual Studio instance must be started as “Run as administrator”.

image

Target framework: .NET Framework 3.5

Visual studio creates a new console application with the setting  .NET 4.0 . For SharePoint you need to set it to .NET Framework 3.5

image

Platform target: Any CPU

Visual studio creates a new console application with the setting  x.86 . For SharePoint you need to set it to Any CPU

image

Comments

  • Anonymous
    August 31, 2010
    Great Post - Short, Sweet and to the point. Thanks.

  • Anonymous
    September 15, 2010
    Yes, ANY CPU resolved the issue. Thanks so much

  • Anonymous
    September 20, 2010
    I have tried all these steps but it  gives the same error, can you tell me what else i can do to make this run?

  • Anonymous
    October 06, 2010
    Thank you so much for this post. I was finally able to get my first sharepoint program to work.

  • Anonymous
    December 02, 2010
    The comment has been removed