Dear All

I am using the API calls to ReadFile and WriteFile to access data coming in on serial ports and sending commands out to devices on Serial ports.

Everything works fine in the VB6 developer.

When I compile the programme I can compile to P-Code and everything works fine.

If I compile to Native Code with no optimisation the Read part works OK but the Write Section terminates the application with no error trapping functioning working. It just bombs out.

If I compile to Native Code and apply opptimisation for small code then neither the Read nor the Write works.

I cannot work out what is going on. I am not changing the code in any way, merely compiling with different options.

Please can anyone help to explain why this should happen. ( I have been pulling my hair out over it for several days now !)

Thanks in advance

John K
John Kelly

1/ check if you have service pack 6 for vb installed, if not install and try again

2/ ok, still bad? now you can either use an external debugger and find the line where program crash,

or

insert a trace code (there are ways how to do it automatically e.g. awk can be helpful) and write any single op into log

3/ check the log and find last op before crash

Many thanks for the reply. I finally cracked it this morning. The example I had for the the WriteFile call I was using send a Byte Array. I found another example that send a string and had the parameter in the declare for the string as 'Any'. This works. Interesting though in the developer UI it would accept the Byte Array but in the .EXE it would crash.

Oh well we live and learn ....

1/ check if you have service pack 6 for vb installed, if not install and try again

2/ ok, still bad? now you can either use an external debugger and find the line where program crash,

or

insert a trace code (there are ways how to do it automatically e.g. awk can be helpful) and write any single op into log

3/ check the log and find last op before crash

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