Note that MFC has its own way to handle exceptions :
https://learn.microsoft.com/en-us/cpp/mfc/reference/exception-processing?view=msvc-170#try
May be you just experienced a conflict bewteen standard library and MFC.
Exception are tricky in Win32 so you will probably have to make some try before solving the problem.