On Sunday, 14 March 2021 at 09:35:40 UTC, frame wrote:
// this returns null in the program (but works in a debugger
watch):
MyExceptionObj imported = cast(MyExceptionObj)e;
// this actually works:
MyExceptionObj imported = cast(MyExceptionObj) cast(void*)e;
Is there are way to copy the exception data in a new Throwable
instance that can be thrown from the current context? Or can
the runtime be tricked by overwriting the TypeInfo in memory?
(I don't know exactly what the actual problem is.)
As a workaround maybe you could introduce special
DLLWrapperException with reference to original exception using
cast hack?
The problem is that TypeInfo is not shared on Windows, which is
actually roots deeper in the other problems with "sharing".
Unfortunately I cannot provide you with details, but this
situation is well known long standing issue.
From what I understand it is such a mess because D
compiler/linker doesn't merge multiple symbols in running program
which is how it basically works in C++ where DLL's works "as
expected".