SharePoint error: Web application at xxxx could no

2019-04-18 14:19发布

When I try to execute this code:

SPSite siteCollection = new SPSite(@"http://sp-devxxx:10000/");

It throws the following error:

The Web application at http://sp-devxxx:10000 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.

I can hit this site from my web browser, it is compiling in x64, my account has read/write access to the content db, the code is running on the server that the site is running on and there exists an access mapping for this site. Why would it be throwing this error?

13条回答
唯我独甜
2楼-- · 2019-04-18 14:36

In my case, I re-opened Visual Studio 2012 running as Administrator, and the problem is solved.

查看更多
萌系小妹纸
3楼-- · 2019-04-18 14:38

Had the same issue while running my code as "exe" file. Problem solved by running cmd as administrator. Hope this help someone.

查看更多
我想做一个坏孩纸
4楼-- · 2019-04-18 14:40

In case the user's account is already a member of WSS_ADMIN_WPG and still the issue persists, As mentioned by Tim.

Try the following steps:

  1. Go to Project Properties
  2. Build Tab
  3. Change the Platform Target value to Any CPU from the drop down.

It resolved the problem for our console Application.

查看更多
Evening l夕情丶
6楼-- · 2019-04-18 14:43

In a console application using visual studio 2012 it was changing the Target framework to 3.5 for me....

查看更多
Ridiculous、
7楼-- · 2019-04-18 14:43

In my case, I needed to add the user db_owner permission to the SharePoint_Config, SharePoint_AdminContent and WSS_Content databases, following the suggestions in this blog.

查看更多
登录 后发表回答