Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C#
  4. ArgumentOutOfRangeException

ArgumentOutOfRangeException

Scheduled Pinned Locked Moved C#
helpcsharpquestion
4 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    Mertli Ozgur Nevres
    wrote on last edited by
    #1

    Hi all i have a c# windows application project. When i press the "close" box, i receive the error below. Does anyone know what should i do to fix this error? An unhandled exception of type 'System.ArgumentOutOfRangeException' occurred in system.windows.forms.dll Additional information: Specified argument was out of the range of valid values. thanks Ozgur Nevres

    H 1 Reply Last reply
    0
    • M Mertli Ozgur Nevres

      Hi all i have a c# windows application project. When i press the "close" box, i receive the error below. Does anyone know what should i do to fix this error? An unhandled exception of type 'System.ArgumentOutOfRangeException' occurred in system.windows.forms.dll Additional information: Specified argument was out of the range of valid values. thanks Ozgur Nevres

      H Offline
      H Offline
      Heath Stewart
      wrote on last edited by
      #2

      Does your form override OnClosing or OnClosed, or does anything else (including your form) handle the Closing and Closed events? If so, something is invoking (either directly calling or invoking via reflection) a method that isn't getting passed the right arguments. If this isn't the case, something somewhere is calling a method with an argument that is not acceptable (for instance, passing a value that doesn't represent a single enum member or a flagged enum). The best way to find this out is to actually read the documentation for the classes, methods, properties, et. al. that you're using. Almost every member in the .NET base class library (BCL) gives at least directly-thrown exceptions that could be thrown and why they would be thrown, including what values are allowed for a particular parameter.

      -----BEGIN GEEK CODE BLOCK----- Version: 3.21 GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++ -----END GEEK CODE BLOCK-----

      M 1 Reply Last reply
      0
      • H Heath Stewart

        Does your form override OnClosing or OnClosed, or does anything else (including your form) handle the Closing and Closed events? If so, something is invoking (either directly calling or invoking via reflection) a method that isn't getting passed the right arguments. If this isn't the case, something somewhere is calling a method with an argument that is not acceptable (for instance, passing a value that doesn't represent a single enum member or a flagged enum). The best way to find this out is to actually read the documentation for the classes, methods, properties, et. al. that you're using. Almost every member in the .NET base class library (BCL) gives at least directly-thrown exceptions that could be thrown and why they would be thrown, including what values are allowed for a particular parameter.

        -----BEGIN GEEK CODE BLOCK----- Version: 3.21 GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++ -----END GEEK CODE BLOCK-----

        M Offline
        M Offline
        Mertli Ozgur Nevres
        wrote on last edited by
        #3

        Thanks for your care. Yes, i handle the Closing event. My eventhandler is below: (Note: the error does not occur always, it occurs sometimes ( 1 in 10, average ) private void Server_Closing(object sender, System.ComponentModel.CancelEventArgs e) { if ( !CheckOnlines() ) e.Cancel = true; }//End of Private Method Server_Closing. and my CheckOnlines method: private Boolean CheckOnlines() { int i = this.m_iNumOfOnlineOperators + this.m_iNumOfOnlineVisitors; if ( i > 0 ) { TextObject objTO = ( TextObject ) this.m_htTexts["Server_CheckOnlines_Msg2"]; String strMsg = objTO.TextValue; strMsg = strMsg.Replace( "@", this.m_iNumOfOnlineOperators.ToString() ); strMsg = strMsg.Replace( "$", this.m_iNumOfOnlineVisitors.ToString() ); objTO = ( TextObject ) this.m_htTexts["Server_CheckOnlines_Msg1"]; DialogResult dr = MessageBox.Show( this, strMsg, objTO.TextValue, MessageBoxButtons.YesNo, MessageBoxIcon.Information ); if ( dr == DialogResult.Yes ) { return true; }//End of if ( dr == DialogResult.Yes ). else { return false; }//End of else. }//End of if ( i > 0 ). else { return true; }//End of else. }//End of Private Method CheckOnlines.

        H 1 Reply Last reply
        0
        • M Mertli Ozgur Nevres

          Thanks for your care. Yes, i handle the Closing event. My eventhandler is below: (Note: the error does not occur always, it occurs sometimes ( 1 in 10, average ) private void Server_Closing(object sender, System.ComponentModel.CancelEventArgs e) { if ( !CheckOnlines() ) e.Cancel = true; }//End of Private Method Server_Closing. and my CheckOnlines method: private Boolean CheckOnlines() { int i = this.m_iNumOfOnlineOperators + this.m_iNumOfOnlineVisitors; if ( i > 0 ) { TextObject objTO = ( TextObject ) this.m_htTexts["Server_CheckOnlines_Msg2"]; String strMsg = objTO.TextValue; strMsg = strMsg.Replace( "@", this.m_iNumOfOnlineOperators.ToString() ); strMsg = strMsg.Replace( "$", this.m_iNumOfOnlineVisitors.ToString() ); objTO = ( TextObject ) this.m_htTexts["Server_CheckOnlines_Msg1"]; DialogResult dr = MessageBox.Show( this, strMsg, objTO.TextValue, MessageBoxButtons.YesNo, MessageBoxIcon.Information ); if ( dr == DialogResult.Yes ) { return true; }//End of if ( dr == DialogResult.Yes ). else { return false; }//End of else. }//End of if ( i > 0 ). else { return true; }//End of else. }//End of Private Method CheckOnlines.

          H Offline
          H Offline
          Heath Stewart
          wrote on last edited by
          #4

          It's hard to see where an error might occur, so you should try debugging that method and seeing on which line the exception is thrown. You should also try stepping through the code (put a breakpoint on the first line of your Closing handler and step into each line. The low reproducability rate might make that a little tedious, but that's the world of software development. You could also use Debug.Assert which may speed up the process a little. Good luck!

          -----BEGIN GEEK CODE BLOCK----- Version: 3.21 GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++ -----END GEEK CODE BLOCK-----

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups