Author Topic: Source Code Doesn't Run in Debug Mode  (Read 6799 times)

Offline Alrecenk

  • *
  • Posts: 10
  • Karma: +0/-0
    • View Profile
on: January 10, 2008, 12:04:20 AM
I downloaded the C# source code from this board, and when I attempt to run the program in debug mode I get this error:

A call to PInvoke function 'WiimoteWhiteboard!WiimoteWhiteboard.Form1::mouse_event' has unbalanced the stack. This is likely because the managed PInvoke signature does not match the unmanaged target signature. Check that the calling convention and parameters of the PInvoke signature match the target unmanaged signature.

on this line:

mouse_event(MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0);

the first time I attempt to click with the ir pen when calibrating.

and if I uncheck the cursor option, and try it I get:

cross-thread operation not valid: Control 'CalibrationForm' accessed from a thread other than the thread it was created on.

on this line:

base.Dispose(disposing);

immediately after the last calibration point. I'm using visual c# 2005 express edition on a windows xp home machine. I can run the precompiled application, and my wiimote connects fine etc. Is there a certain configuration I need to be compiling in to get this to work or any additional files I need? I haven't put very much time into researching this problem, so it may be trivial to fix, but I figured it was worth posting anyways for anyone who might be as surprised as I was when the original source did not compile. Any help would be appreciated.
« Last Edit: January 14, 2008, 01:06:05 PM by Alrecenk »



Offline nigel_ht

  • *
  • Posts: 2
  • Karma: +0/-0
    • View Profile
Reply #1 on: January 11, 2008, 11:39:44 AM
The current version of the code (on sourceforge) should fix the cross thread issue.

The unbalanced stack I have no clue.  I checked the parameters and they look correct so I simply turned it off in the debugger.  When I get time I'll look at it again.

I'll make a binary version and a zip of the latest but I hesitate to do that before the code is tested on something other than my Mac using the mac drivers.



Offline Alrecenk

  • *
  • Posts: 10
  • Karma: +0/-0
    • View Profile
Reply #2 on: January 12, 2008, 07:12:44 PM
I updated the source, and it seems that if I run the built exe it works like I would expect. I didn't do anything to fix that other error, and I wouldn't really know where to start as my c# experience is limited. It still throws when I run in debug mode, but at least now I can get something done....well, maybe not right now...*plays video games*



Offline atomriot

  • *
  • Posts: 177
  • Karma: +16/-0
    • View Profile
Reply #3 on: January 12, 2008, 07:30:14 PM
in your main forms constructor put this code

Code: [Select]
CheckForIllegalCrossThreadCalls = false;

Details, details. Things to do. Things to get done. Don't bother me with details, just tell me when they're done.
--
James Lionel Price



Offline Alrecenk

  • *
  • Posts: 10
  • Karma: +0/-0
    • View Profile
Reply #4 on: January 13, 2008, 09:30:57 AM
That takes care of the cross thread issue, but now I get another PInvoke stack imbalance in it's place on the mouse button up call, and though I can compile and run the program and move the mouse without it crashing I am, not surprisingly, unable to click anything.

edit: Changed title of the thread. The errors are and have been runtime errors.    My apologies if I misled anyone.

« Last Edit: January 14, 2008, 01:05:19 PM by Alrecenk »



Offline DerTürke86

  • *
  • Posts: 20
  • Karma: +1/-0
    • View Profile
Reply #5 on: May 29, 2008, 07:35:15 AM
Yes man i have the same Problems like you! ITs Horrible many people dont have this problem! May be a configuration Problem!! :( :( :( :( :( :( :( :( :( :( :'( :'( :'( :'( :'(



Offline DerTürke86

  • *
  • Posts: 20
  • Karma: +1/-0
    • View Profile
Reply #6 on: May 29, 2008, 08:19:50 AM
OK and found it ! wiimote.cs Search for Mutex and add

CheckForIllegalCrossThreadCalls = false;


public Form1()
        {
            screenWidth = Screen.GetBounds(this).Width;
            screenHeight = Screen.GetBounds(this).Height;
            CheckForIllegalCrossThreadCalls = false;
            InitializeComponent();
        }


thanks for the help !!!