0

I wrote a small C# .Net 4.5.2 application to rename some doc libraries. It fails at the very beginning:

using(SPSite sitecoll=new SPSite("http://192.168.0.14:8069"))

with the message

Web application at http://localhost cannot be found
  • The same app in the dev server runs fine, but there sharepoint is mapped to http://localhost.
  • The same commands issued via powershell run fine.
  • Sharepoint is totally accessible both locally and remotely via VPN, and I'm running the application as a sharepoint/site administrator.
  • I also tried using the machine name http://sharepoint:8069 and http://localhost:8069
  • I get slightly different errors running from the dev machine, remotely via VPN, in this case the URL is reported correctly:

    The web application at http://192.168.0.14:8069 cannot be found

UPDATE I even tried a non-existing name, http://foo:8069, and I get the same reply! Any advice? Thank you

1
  • are you tried to use server name instead IP ? Commented Jul 21, 2016 at 16:28

1 Answer 1

0

Solved

It was a matter of security and permissions: I solved by running the code with

var elevata = new SPSecurity.CodeToRunElevated(
               delegate () { myCode(); });
SPSecurity.RunWithElevatedPrivileges(elevata);

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.