getting error "value does not fall within the expected range" on pocket PC 2003 emu

Hey all,
  Im stumped at this seemingly easy task. I need to ask a user for a file name. thats it. But im getting the above error.

here is the code: (Where UserInput is a basic form with 2 buttons and a text box)

UserInput ui = new UserInput();
ui.Parent = this;

if (ui.ShowDialog() == DialogResult.OK) <-- ERROR HERE
{
    fileName = ui.FileName;

    FileStream fs = new FileStream(filePath + "\\" + fileName, FileMode.Create);

    XmlTextWriter xtw = new XmlTextWriter(fs, System.Text.Encoding.Unicode);

    xtw.WriteProcessingInstruction("xml", "version=\"1.0\"");
    xtw.WriteProcessingInstruction("xml-stylesheet", "type='text/xsl' href='conditionReport.xslt'");

    _writeSet.WriteXml(xtw);
    xtw.Close();
    fs.Close();


    //display success message
    MessageBox.Show("File Successfully Extracted as " + fileName);
}
else
{
    MessageBox.Show("Export Cancelled");
}

any ideas


Answer this question

getting error "value does not fall within the expected range" on pocket PC 2003 emu

  • fwyattblake

    I have, it errors on the line I outlined. You can setp into the ShowDialog() method can you

  • GlennGraham

    Im running VS2005, from what I gather, when I was setting the properties up for the form, I told the form that it is a parent of the calling form, when it in fact is not. So I deleted the line as mentioned in one of my above posts, and it worked fine.

    I thought that I was telling the form the its parent was the calling form, not the other way around, hope this makes sense

  • Binnerup

    No, no. That's not what I'm asking. The reason for the error itself is rather clear. < xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

    The question is: you though the problematic line was the next one as indicated in your first post:

    ----------------

    ui.Parent = this;

    if (ui.ShowDialog() == DialogResult.OK) <-- ERROR HERE

    ---------------

    In fact, error was in the line above it. Why did you believe the problem was in a wrong line VS should pop up a big box stating the problem on the line what caused it. Was this error box pointing to the line your initially indicated and not to the problematic line above it

     



  • dundask

    ahh sorry, I get ya. The reason it errors at that point is becuase up until you run the ShowDialog method, the properties of the form do not get invoked, so you can set any valid properties of the form up, in my case I set the parent to be the main form, this is valid because the property expects a property of type Form. But when it tries to run it all, it sees that the form heirarchy is set up wrong.
    Thats my understanding

  • ZoranPecenovic

    No, you can not step into ShowDialog(), but you can set up break points in events in your form. < xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

    By the way, what's the reason you believed problem happened in the next line, not in the line with actual issue Which version if VS are you using, 2003 or 2005

     



  • Muhammad Rizwan

    Most likely it's something you do in this form. Consider stepping into with debugger.< xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />



  • YnottonY

    I got it, I had to remove the ui.Parent = this; line, I miss understood what this did.

  • getting error "value does not fall within the expected range" on pocket PC 2003 emu