That's very puzzling... it seems that in your program you can't even load PNGs! Something's very wrong. I don't quite understand how the test program can work while your program doesn't though... are you linking to the same libraries and have the same DLLs in the same place? Clearly, al_init_image_addon does something, since that error message only comes up if it was at least partly successful (as it managed to register the .png handler).
Sorry about this... the debugability of the IO routines has always been a pain point.
How big is your project? Is it an option for you to share the source?