I recently had a problem (see subject) in a multithread app hosting a
VBScript engine. The problem occurred only on a Win2K machine, not NT4/XP.
In my case I instantiated a script engine per thread since the scriptengine
is not multi-threaded. I keep the threads in a list of threadid's. If a
script method has to be called on an unknown script I cloned the engine, and
administrated it in the threadlist. So far no problem. But now a thread
dies, and another thread is re-created and unfortuanlly it has THE SAME
threadid, so I reused the already administrated clone of the script engine.
The problem was the IDispatch interface: it uses thread-local-storage, which
is not yet initialised for the new thread, causing the access violation.
I simply fixed it by using CoGetCurrentProcess instead of GetCurrentThreadId
while administrating the threads.
Regards,
Peter
(for email: use medialab for the domain)