?
Solved

WinForm server-side object model error

Posted on 2014-01-20
2
Medium Priority
?
390 Views
Last Modified: 2014-01-20
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.FileNotFoundException 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:
Product Form
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 = "";
        }
    }
}

Open in new window

0
Comment
Question by:Isaac
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 44

Accepted Solution

by:
Rainer Jeschor earned 2000 total points
ID: 39794365
Hi,
can you please verify, that in the build options of your winforms project you have selected x64 build target?
When you build x86/32 bit application you normally get exactly the same error message.

HTH
Rainer
0
 
LVL 5

Author Closing Comment

by:Isaac
ID: 39795861
Thanks!
0

Featured Post

Back Up Your Microsoft Windows Server®

Back up all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

These days socially coordinated efforts have turned into a critical requirement for enterprises.
A recent project that involved parsing Tableau Desktop and Server log files to extract reusable user queries for use in other systems. I chose to use PowerShell to gather the data, and SharePoint to present it...
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question