Hi

I'm wondering if anyone can think of a generic reason why visual studio 2010 would act in the following mannor.

If I run my code using ctrl + F5 (run without debugging option) it works fine and as expected.

However if I run it in debug mode it acts oddly, sometimes just not returning results as expected, and other time reporting this exception ...

... "Exception of type 'System.ExecutionEngineException' was thrown."

The line that seems to be causeing the problem is a method imported from a custom win32 library.

I'm asking in this fashion in case this is a known problem with visual studio, before I start trying to reproduce a snippet which causes the problem.

Cant find much about the exception in a search, at least within my understanding. I'd appreciate any insights offered.

Sounds like there is an issue with the win32 library probably manipulating the stack. Since the debugger makes changes to the stack (it's how it tracks things) anything else doing so can cause problems. When you run without the debugger you don't have this issue since only one process is manipulating things.

The win32 library is not well behaved. If you have the source I'd consider rewriting it so it's not causing problems.

I forgot about this thread, I do apologise, I did not mean to seem ignorant. I got fed up with it and just stopped using debug mode (awful behaviour I know).

I do not have the source of the dl library, but I have a feeling I'm just not importing it correctly.

My last investigations led me to a MarshallAs attribute (where I crumbled, not knowing anything about it)

Here is the Import I used (by trial and error) and the call to it.

struct MyStruct
{
public uint x;
public uint y;
}

[DllImport("psim.dll")]
static extern void GetHandState(string mystring, ref MyStruct mystruct);

static void ghs(}
{
string sh = "MyString";
MyStruct ms = new MyStruct();
GetHandState(sh, ref ms);
}

Like I say, it works fine and freaks out about 50 50 but only in Debug mode :(

I found the source

is this what you need EXPORT void GetHandState(const char* hand, PostFlopState* results); The stuct is in the code above, just 2x unsigned ints.

This article has been dead for over six months. Start a new discussion instead.