On the solution of ill-posed inverse electromagnetic problems