Are you saying that if you run the same .exe from the command line then mostly it runs correctly and sometimes it doesn't? This is very odd because there ought to be no difference between executions of the same binary other than external factors like clock times and the file system. I don't know about this, but I would imagine that even memory layout ought to be identical between runs, so far as user-space pointers are concerned.
I compiled your code and have run it 100+ times without problems. Therefore assuming there isn't something broken about your machine, then the differences ought to come down to environment: Javascript.Net source code, .Net framework version, v8 source code. I am using VS 2012 target .Net 4 x64. My v8 and Javascript.Net source code comes from https://github.com/oliverbock/Javascript.Net, which has the Javascript.Net fixes I have made in the last month, but excludes the upgraded v8 version and associated changes because I am having a separate problem with it (see http://code.google.com/p/v8/issues/detail?id=3332).
Have you tried configuring your debugger to stop when the exception is thrown? Where is that?
I compiled your code and have run it 100+ times without problems. Therefore assuming there isn't something broken about your machine, then the differences ought to come down to environment: Javascript.Net source code, .Net framework version, v8 source code. I am using VS 2012 target .Net 4 x64. My v8 and Javascript.Net source code comes from https://github.com/oliverbock/Javascript.Net, which has the Javascript.Net fixes I have made in the last month, but excludes the upgraded v8 version and associated changes because I am having a separate problem with it (see http://code.google.com/p/v8/issues/detail?id=3332).
Have you tried configuring your debugger to stop when the exception is thrown? Where is that?