The tangent bundles of closed hyperbolic surfaces have flat $PSL(2,\mathbb{R})$ connections showing that there can be no integral formula for the Euler class such connections. This contrasts the situation for the Orthogonal group where the Pfaffian applied to curvature integrates to the Euler class. Can anyone suggest a conceptual reason for the absence of a local formula in the case where the connection fails to preserve a metric? Is it related to the fact that the Euler class is unstable?

I think the point is the theorem, due to Cartan, that the universal ChernWeil homomorphism $$CW_G:Sym^{k} (\mathfrak{g})^G \to H^{2k}(BG; \mathbb{R})$$ from invariant forms on the Lie algebra to the cohomology of the classifying space is an isomorphism once $G$ is compact. If $G$ is complex reductive (such as $GL_n (\mathbb{C})$), then it follows by the unitary trick that $CW_G$ is an isomorphism as well. But if $G$ is neither compact nor reductive, there is no reason to expect an expression of a general characteristic class to have an expression in terms of the curvature. In fact, Milnor's example shows that $CW_G$ is not surjective for $G=PSL_2 (\mathbb{R})$. I vaguely remember that if $G$ is the $3$dimensional Heisenberg group (with center $S^1$), then $CW_G$ is the zero map in positive degrees, even though both source and target are nonzero. 

