I have always seen it explained that:
Ampere's Law (in integral form) works whenever B is constant around a path, so that you can pull it out of the integral.
Similarly, if you can draw a surface over which E is constant, you can pull E out of the integral.
In the Gauss's Law case, it seems like I should (for a finite wire) be able to draw a surface of infinitesimal thickness and get the exact result. (The contributions through the sides of the cylinder cancel by symmetry).
In the Ampere's Law case, I know that it has to do with the current distribution not being a loop, but I don't know the mathematics behind it.
Could someone explain, in as mathematically rigorous way as possible why these things do not work?