Isaac
asked on
WinForm server-side object model error
Hi All,
I am trying to create a WinForm that interacts with the SP server-side object model but my site URL is not being recognized. All this is being done on my SharePoint 2010 VM.
Error below:
System.IO.FileNotFoundExce ption was unhandled
Message=The Web application at http://win-2n0d15326id/iad 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.
Here's what my form looks like:
Here's the code:
I am trying to create a WinForm that interacts with the SP server-side object model but my site URL is not being recognized. All this is being done on my SharePoint 2010 VM.
Error below:
System.IO.FileNotFoundExce
Message=The Web application at http://win-2n0d15326id/iad 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.
Here's what my form looks like:
Here's the code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using Microsoft.SharePoint;
namespace WPFSPTestApp
{
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow : Window
{
string strSPSiteURL = "";
string strSPListName = "";
string strProductName = "";
string strProductSKU = "";
string strProductPrice = "";
public MainWindow()
{
InitializeComponent();
}
private void btnLoad_Click(object sender, RoutedEventArgs e)
{
strSPSiteURL = txtbxSPURL.Text;
strSPListName = txtbxListName.Text;
strProductName = txtbxProductName.Text;
strProductSKU = txtbxProductSKU.Text;
strProductPrice = txtbxProductPrice.Text;
using (SPSite site = new SPSite(strSPSiteURL))
{
using (SPWeb web = site.OpenWeb())
{
web.AllowUnsafeUpdates = true;
SPList list = web.Lists[strSPListName];
SPListItem Item = list.Items.Add();
Item["Title"] = strProductName;
Item["Product_SKU"] = strProductSKU;
Item["Price"] = strProductPrice;
Item.Update();
web.AllowUnsafeUpdates = false;
}
}
}
private void btnExit_Click(object sender, RoutedEventArgs e)
{
Application.Current.Shutdown();
}
private void btnClear_Click(object sender, RoutedEventArgs e)
{
txtbxListName.Text = "";
txtbxSPURL.Text = "";
txtbxProductName.Text = "";
txtbxProductSKU.Text = "";
txtbxProductPrice.Text = "";
}
}
}
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER