Bizarre DLL problem
Posted: Thu Aug 21, 2003 5:19 pm
Ok, I've got two different DLLs with the same set of exported functions, and I'm having a weird problem. Because of the nature of the program, I have gone with LoadLibrary to link the DLL rather than using the .lib file that Visual C++ exports.
It is convenient in using the program to be able to change which DLL is being used at run-time by "disconnecting" from one and "connecting" to the other, which means I need to call FreeLibrary and leave the user application running.
When the application uses one of the DLLs, there are no problems. When it uses the other, the program exits without warning and with no error message at some point soon after the call to FreeLibrary (but not during or immediately after). The problem definitely relates to FreeLibrary because commenting that line out makes the problem not occur (but obviously the DLL doesn't get unloaded when it's no longer needed).
When I run the debugger, I do get an error message -- an access violation (at a seemingly random point after the FreeLibrary call). But the point where the error occurs is a bunch of assembly language, and when I look at the call stack, all I see is a bunch of NTDLL! entries with hexadecimal numbers beside them. There are no entries for any of the functions in either the DLL or the application.
Any ideas what might be happening?
It is convenient in using the program to be able to change which DLL is being used at run-time by "disconnecting" from one and "connecting" to the other, which means I need to call FreeLibrary and leave the user application running.
When the application uses one of the DLLs, there are no problems. When it uses the other, the program exits without warning and with no error message at some point soon after the call to FreeLibrary (but not during or immediately after). The problem definitely relates to FreeLibrary because commenting that line out makes the problem not occur (but obviously the DLL doesn't get unloaded when it's no longer needed).
When I run the debugger, I do get an error message -- an access violation (at a seemingly random point after the FreeLibrary call). But the point where the error occurs is a bunch of assembly language, and when I look at the call stack, all I see is a bunch of NTDLL! entries with hexadecimal numbers beside them. There are no entries for any of the functions in either the DLL or the application.
Any ideas what might be happening?