This is the actual exception :
"The Web application at http://nb16 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."
Below figure gives you complete details.
Below is the code [Console application] I have used to communicate with the sharepoint server.
class Program
{
static void Main(string[] args)
{
DeleteAllItemsUsingBatch();
}
private static void DeleteAllItemsUsingBatch()
{
using (SPSite site = new SPSite("http://nb16"))
{
SPWeb web = site.OpenWeb("/");
SPList list = web.Lists["Documents"];
StringBuilder sb = new StringBuilder();
sb.Append(""); ");
string batchCommand = "<method><setlist scope=\"Request\">" + list.ID + "</setlist><setvar name=\"ID\">{0}</setvar><setvar name=\"Cmd\">DELETE</setvar><setvar name=\"owsfileref\">{1}</setvar></method>";
foreach (SPListItem item in list.Items)
{
sb.AppendFormat(batchCommand, item.ID.ToString(), item.File.ServerRelativeUrl);
}
sb.Append("
web.AllowUnsafeUpdates = true;
site.RootWeb.ProcessBatchData(sb.ToString());
web.AllowUnsafeUpdates = false;
web.Close();
}
}
}
Did you find any problem with the code? Not really. There are no problems with the code at all.. Then what's wrong?
When I researched on the net for the solutions I found below information.
1. Is SharePoint site running?
2. Did you develop code on the same SharePoint server?
But, everything fine. There are no issues. Then what was the problem? I was frustrated for 3 hours to find the solution.
Solution:
It's simple that the platform target in build options was set to the x86 format by default. It should be set to x64 to work correct.
So, sometimes the simple problems will take more time to fix. Enjoy the nice series of posts on SharePoint 2010.
0 komentar:
Post a Comment