  The main goal of this article is to construct some geometric invariants for
the topology of the set $\mathcal{F}$ of flat connections on a principal
$G$-bundle $P\,\longrightarrow\, M$. Although the characteristic classes of
principal bundles are trivial when $\mathcal{F}\neq \emptyset$, their classical
Chern-Weil construction can still be exploited to define a homomorphism from
the set of homology classes of maps $S\longrightarrow \mathcal{F}$ to the
cohomology group $H^{2r-k}(M,\mathbb{R})$, where $S$ is null-cobordant
$(k-1)$-manifold, once a $G$-invariant polynomial $p$ of degree $r$ on
$\text{Lie}(G)$ is fixed. For $S=S^{k-1}$, this gives a homomorphism
$\pi_{k-1}(\mathcal{F})\longrightarrow H^{2r-k}(M,\mathbb{R})$. The map is
shown to be globally gauge invariant and furthermore it descends to the moduli
space of flat connections $\mathcal{F}/\mathrm{Gau}P$, modulo cohomology with
integer coefficients. The construction is also adapted to complex manifolds. In
this case, one works with the set $\mathcal{F}^{0,2}$ of connections with
vanishing $(0,2)$-part of the curvature, and the Dolbeault cohomology. Some
examples and applications are presented.
