Home > Software engineering >  HALCON encapsulated into the MFC DLL export code, call FreeLibrary application no response
HALCON encapsulated into the MFC DLL export code, call FreeLibrary application no response

Time:09-16

From HALCON exporting A C + + code (function is to realize the window shown in the picture), encapsulated into the MFC extension DLL (C, derivation of the corresponding function so as to realize the image display function), application A load the DLL, A function of B calls A DLL, functions can be normal (image can be shown in the window), when after call the exported functions C, B in B FreeLibray, application A become no response, to quit, don't know is what reason, how to solve,

CodePudding user response:

First MFC procedures should always use AfxLoadLibrary/AfxLoadLibraryEx AfxFreeLibrary eliminate possible associated with MFC problem

Location problem can:
Try to encapsulate your code in the DLL are replaced with an empty function,
No problem can determine the normal loading unloading after
That this part of the export code may require special usage (such as specific initialization, releasing action)

CodePudding user response:

Thank you for reply!
AfxLoadLibrary/AfxLoadLibraryEx AfxFreeLibrary are tried, such as there is no difference,
In addition, I also do before a has nothing to do with HALCON export function, the DLL loading and releasing is very normal, no problem,
The problem is just a call HALCON operator, cannot normal release,

CodePudding user response:

Before FreeLibray set breakpoints and see if there are other threads
Do I have to end first thread or buy event/exit sign request?

CodePudding user response:

This DLL without calling in the thread, is directly in the application's main thread calls,
Set breakpoints followed, FreeLibrary execution, after several times to call the DLLMAIN function, then, don't know where is the operation, the application no response,

CodePudding user response:

Debug tracking DLL loading and unloading process, found that after loading the DLL, once the HALCON operator, will automatically start multiple threads, when the image display, to exit the dialog in a DLL, HALCON operator before the start of the thread, has not terminated, all of the DLL use count is zero, not cause the DLL cannot uninstall,
Don't know which prawn in the MFC DLL encapsulation HALCON operator's experience, ever solve this problem, also hope to give directions, I was using a HALCON 12. Thank you!

CodePudding user response:

Change a train of thought that starting from the encapsulated code, the code is encapsulated in the main program first run not to walk in the DLL can see normal exit?

CodePudding user response:

reference 5 floor jerrywky reply:
debug tracking DLL loading and unloading process, found that after loading the DLL, once the HALCON operator, will automatically start multiple threads, when the image display, to exit the dialog in a DLL, HALCON operator before the start of the thread, has not terminated, all of the DLL use count is zero, not cause the DLL cannot uninstall,
Don't know which prawn in the MFC DLL encapsulation HALCON operator's experience, ever solve this problem, also hope to give directions, I was using a HALCON 12. Thank you!
may need to have some kind of call release resources, depending on your familiar of halcon, this did not get, if just want to simple display images, other than over the library, the D2D system at directly with GDI +, etc
  • Related