Tuesday 15 January 2013

debugging - Error message in C# software debug question -


While I try to run a program in creating this error, how I repeated the error message, the macro runs just fine For many loops, but then it is broken by mistake, it is giving the error.

  ************* exception text ************************************ The value of '-1' is not valid on 'Blue' System.Drawing.Color.FromArgb on System.Drawing.Color.CheckByte (Int32 value, string name) (int32 alpha, int32 red, equal to or greater than 0 And should be equal to or less than 255 green, int 32 blue) on the system. Drawing Caller.phomArgb (int 32 red, int 32 green, int 32 blue) on dispatcher. Caller check Gatepxal Atcurs () Dispatcher. Dispatcher. Caller check.getpixel () on Dispatcher. Caller check Dispatcher_Tool.main_normal.checkColor () on Dispatcher_Tool.main_normal.startMacro (text box valX) on Dispatcher_Tool.main_normal.button5_Click on CheckColorBlack (Inter 32 Blackcards X, int 32 blackCordsY) System.Windows.Forms.Control.OnClick (Object Sender, EventArgs E) (on EventArgs e) on the system. On Windows.Forms.Button.OnClick (EventArgs e) System.Windows.Forms.Button.OnMouseUp (MouseEventArgs mevent) System.Windows.Forms.Control.WmMouseUp (Message in & amp; M, MouseButtons Button, Int32 Clicking ) On System.Windows. Control Andropy (Message and M) ystem.Windows.Forms.ButtonBase.WndProc (Message in & System.Windows.Forms.Control.ControlNativeWindow.WndProc in Me) (Message & System.Windows.Forms.Control ControlNativeWindow.OnMessage in m) (Message & System.Windows.Forms.Button.WandProc (meter on message & meter) System.Windows.Forms.NativeWindow.Callback (IntPtr hWnd, Int32 Message, IntPtr wParam, IntPtr The code around this point is  
  [DllImport ("gdi32")] Private static extern c GetPixel (IntPtr hdc, int x , Int y); [DllImport ("User32")] Private static extern IntPtr GetWindowDC (IntPtr hwnd); #region Pixel Color Testing for Private Stable Reading Only IntPtr DesktopDC = GetWindowDC (IntPtr.Zero); Public Static System Drawing Caller GetPixelAtCursor () {System.Drawing.Point p = Cursor.Position; Int color = Gate pixel (DesktopDC, PX, P.Y.); Return system Dropping Colour. Foam ARGB (Color and 0x FF, Color> 8 & amp; 0xFF, Color> gt;> 16); } Error message is quite clear - you are calling, but you do it - 1 give "blue" value, which is invalid Docs:  

blue
type: System.Int32
blue component to the new color value valid values ​​are 255 to 0 Are up to

How can you decide that it will depend on your code which is trying to code your code.

Edit: Okay, now you have the code is returned I strongly suspect that he CLR_INVALID is that I thought estimated -1 bit patterns (I.e. all bit sets). You are just moving that signal being expanded, so you're still getting -1.

It is very easy to avoid creating an exception - just the same way the blue face "others are masking:

  Color.FromArgb return (; 0xFF, (Color> Color & amp; 8) & amp; 0xFF, (Color> & gt; 16) & amp; 0xFF);  

However, this is really going to hide the problem - you will end up with white where you do not actually have a valid value, you should probably check if the color == -1 and work appropriately. Then, that exact behavior will depend on your application.


No comments:

Post a Comment