none
The given key was not present in the dictionary.

    Question

  • Hi All,

    I have written some code in the infopath form and have published it into the form libraray in sharepoint. Whenever i am clicking on the new document, it says there is an error in loading the form and asks for continue or start over. when i click on continue the form opens. The error that is being indicated is this:

    The given key was not present in the dictionary.

    System.Collections.Generic.KeyNotFoundException: The given key was not present in the dictionary.
    at System.ThrowHelper.ThrowKeyNotFoundException()
    at System.Collections.Generic.Dictionary`2.get_Item(TKey key)
    at Microsoft.Office.InfoPath.Server.Util.ReadOnlyDictionary`2.System.Collections.Generic.IDictionary<K,V>.get_Item(K key)
    at PC.FormCode.FormEvents_Loading(Object sender, LoadingEventArgs e)
    at Microsoft.Office.InfoPath.Server.SolutionLifetime.FormEventsHost.<>c__DisplayClass6.<>c__DisplayClass8.<add_Loading>b__1()
    at Microsoft.Office.InfoPath.Server.Util.DocumentReliability.InvokeBusinessLogic(Thunk thunk)
    at Microsoft.Office.InfoPath.Server.SolutionLifetime.FormEventsHost.<>c__DisplayClass6.<add_Loading>b__0(Object sender, LoadingEventArgs e)
    at Microsoft.Office.InfoPath.Server.SolutionLifetime.FormEventsHost.<>c__DisplayClass34.<FireLoadingEvent>b__30()
    at Microsoft.Office.InfoPath.Server.DocumentLifetime.OMExceptionManager.CallFormCodeWithExceptionHandling(UserMessages userMessages, OMCall d)

    An entry has been added to the Windows event log of the server.
    Log ID:5337
    <input style="width: 0px; position: absolute; height: 0px; border: 0px; padding: 0px;" type="text" tabindex="65535" />
     
    <input id="DialogButton0" class="DialogButton" onclick="Dialog.OnTerminateButton();Util.StopEventProprogation(event);" type="button" value="Continue" accesskey="c" /><input id="DialogButton0" class="DialogButton" onclick="UserMessageError_StartAgainClicked();Util.StopEventProprogation(event);" type="button" value="Start Over" accesskey="s" />

    my requirement is i want to send values of 2 fields from the previous form to the next form in the form library through a URL using query. I will add the lookups to the 2 fields from the SPD Workflow in a mail. The code i have written in the infopath form is:

     

    string bazvalue = "Default Value";

     

    if (e.InputParameters["baz"] != null)

    {

    bazvalue = e.InputParameters[

    "baz"];

    }

     

    else

    {

    e.InputParameters[

    "baz"] = bazvalue;

    }

     

    string bizvalue = "Default Value";

     

    if (e.InputParameters["biz"] != null)

    {

    bizvalue = e.InputParameters[

    "biz"];

    }

     

    else

    {

    e.InputParameters[

    "biz"] = bizvalue;

    }

    }

     

     

     

    public void FormEvents_Loading(object sender, LoadingEventArgs e)

    {

     

    string bazvalue = e.InputParameters["baz"];

     

    string bizvalue = e.InputParameters["biz"];

     

    XPathNavigator test =MainDataSource.CreateNavigator();

    test.SelectSingleNode(

    "//my:field38", NamespaceManager).SetValue(bazvalue);

    test.SelectSingleNode(

    "//my:employeeidprojectclearance", NamespaceManager).SetValue(bizvalue);

    }.

    I am unable to understand where am i erring? Please help! Would appreciate it!

    Wednesday, May 12, 2010 1:16 PM

Answers

  • I found the solution. What you have mentioned might also be one of the possibilities. But the usage of trygetvalue() in the code has done the trick.
    • Marked as answer by Seven M Monday, May 17, 2010 9:01 AM
    Sunday, May 16, 2010 10:02 AM
  • This may be un-related to your code, sometimes we have to delete the list (form library) we are developing  on in order completly remove a form and start a fresh. If we do this and we are using a data connection to the forms library for any reason, we need to update this data connection as the GUID has changed for the list.


    How much of your life do you spend watching blue bars?
    • Marked as answer by Seven M Monday, May 17, 2010 9:01 AM
    Friday, May 14, 2010 9:58 PM

All replies

  • This may be un-related to your code, sometimes we have to delete the list (form library) we are developing  on in order completly remove a form and start a fresh. If we do this and we are using a data connection to the forms library for any reason, we need to update this data connection as the GUID has changed for the list.


    How much of your life do you spend watching blue bars?
    • Marked as answer by Seven M Monday, May 17, 2010 9:01 AM
    Friday, May 14, 2010 9:58 PM
  • I found the solution. What you have mentioned might also be one of the possibilities. But the usage of trygetvalue() in the code has done the trick.
    • Marked as answer by Seven M Monday, May 17, 2010 9:01 AM
    Sunday, May 16, 2010 10:02 AM
  • Thanks this helped me, I changed the line in my code from:

    vView = e.InputParameters["View"];

    to:

    e.InputParameters.TryGetValue("View"out vView);

    and it finally worked!

    Thursday, October 04, 2012 12:12 PM