std.gc.setHandle causes Access Violation

Sjoerd van Leent svanleent at gmail.com
Wed May 17 11:44:50 PDT 2006


Using a shared DLL and a client Executable, both written in D, I'd like 
to be able to use std.gc.setGCHandle, as mentioned in the Win32 DLL 
example. However, I am getting an Access Violation Error, right when the 
call to std.gc.setHandle is made.

Does anyone know about this problem, and how to solve it?

This is the code setting the GC handler on the DLL side:

extern(C) export void libraryInit(void * gc) {
	MessageBoxA(null, "Library Initializing", "Library", MB_OK);
	std.gc.setGCHandle(gc);
	_minit();
	_moduleCtor();
}

This is the code, on the Executable side:

alias void function(void * gc) LibraryInitFP;

...

fp = GetProcAddress(mod.h, "libraryInit");
if(fp != null) {
     mod.libraryInitFP = cast(LibraryInitFP)(fp);
}

if(mod.libraryInitFP != null) {
     (*mod.libraryInitFP)(std.gc.getGCHandle());
}

Regards,
Sjoerd



More information about the Digitalmars-d mailing list