Say I've class A and sophistication B. B gets from class A, and implements a couple of virtual functions. The only issue is the fact that B is determined inside a .dll. At this time, I've got a function that returns a clear case of class A, however it retrieves that from the static function within the .dll that returns a clear case of class B. My plan's to call the produced object, and hopefully, possess the functions within the .dll performed rather than the functions defined at school A. For whatever reason, I keep getting restricted memory access errors. Can there be something I do not realize that could keep this plan of action from working?
C++ classes don't mix DLL limitations well. The DLL and also the EXE have to be constructed with the identical compiler and version -- ideally together. The reason being class implementation specifics, like
vtbl layout/order in addition to implementations of some standard library features (i.e.
std::string variations) are non portable. Different compilers' title-mangling schemes will also be non potable between compilers/versions. The only real interface you are able to dependably expose outdoors a DLL boundary is really a C interface.
Because I'm not sure the precise scenario here' can not be sure, but you're most likely invoking some form of undefined behavior over the DLL boundary.
EDIT: It is also entirely possible that the DLL got unloaded sooner or later bringing on a phone call to nonexistent code in B.
See my other extensive question&answer about this subject - will it help? http://stackoverflow.com/questions/1564802/how-to-work-portably-with-c-class-hierarchies-dynamic-linked-libraries
Have you try debugging it using the Visual Studio debugger?
Set the debugger to trap win32 exceptions by visiting Debug menu->Exceptions and mark the checkbox alongside
Win32 exceptions under
Now activate your exe using F5. The crash should alert the debugger and you ought to have the ability to begin to see the exact place from the access breach.