submiting data from infopath to Sharepoint 2007 list using custom code with VSTA:System.IO.FileNotFoundException RRS feed

  • Question

  • Hi Manas,

    pls can you help me, i have same issue.

    i am submiting data from infopath to Sharepoint 2007 list using custom code with VSTA.
     i am getting this error when clicking on submit button:

    The Web application at http://sharepointqa/global/Testing/ 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.

       at Microsoft.SharePoint.SPSite..ctor(SPFarm farm, Uri requestUri, Boolean contextSite, SPUserToken userToken)
       at Microsoft.SharePoint.SPSite..ctor(String requestUrl)
       at TemplateTesting.FormCode.BTN_Submit_Clicked(Object sender, ClickedEventArgs e)
       at Microsoft.Office.InfoPath.Internal.ButtonEventHost.OnButtonClick(DocActionEvent pEvent)
       at Microsoft.Office.Interop.InfoPath.SemiTrust._ButtonEventSink_SinkHelper.OnClick(DocActionEvent pEvent)

    now getting this error with RunWithElevatedPrivileges method and try block :("System.NullReferenceException
    Object reference not set to an instance of an object.")

    without RunWithElevatedPrivileges method and try block  now i am using this code:



    XPathNavigator xnTargetSite = MainDataSource.CreateNavigator().SelectSingleNode("//my:field2", NamespaceManager);



    MessageBox.Show("Hello!!!");//only this event is working











    using (SPSite site = new SPSite("http://sharepointqa/global/project"))//not working

    using (SPSite site = new SPSite("http://sharepointqa))//not working

    using (SPSite site = new SPSite(http://sharepointqa/))//not working

    //http://sharepointqa/global/Project/TestNew/Forms/AllItems.aspx //not working




    using (SPWeb web = site.OpenWeb("global/project"))//not working



    using (SPWebweb = site.OpenWeb())//not working


    web.AllowUnsafeUpdates =







    SPList taskList = web.Lists["TestNew"];



    SPListItem taskItem = taskList.Items.Add();



    "Title"] = MainDataSource.CreateNavigator().SelectSingleNode("//my:xnTargetSite", NamespaceManager).Value;


    web.AllowUnsafeUpdates =









    catch (Exception ex)




    throw ex;


    Monday, December 12, 2011 9:26 AM