  Considering the $B$-branes over a complex manifold $Y$ as objects of the
bounded derived category $D^b(Y)$, we define holomorphic gauge fields on
$B$-branes and the Yang-Mills functional for these fields.These definitions are
a generalization to $B$-branes of concepts that are well known in the context
of vector bundles. Given ${\mathscr F}^{\bullet}\in D^b(Y)$, we show that the
Atiyah class $a({\mathscr F}^{\bullet})\in{\rm Ext}^1({\mathscr
F}^{\bullet},\,\Omega^1({\mathscr F}^{\bullet}))$ is the obstruction to the
existence of gauge fields on ${\mathscr F}^{\bullet}$. We determine the
$B$-branes over $\mathbb{ CP}^n$ that admit holomorphic gauge fields. We prove
that the set of Yang-Mills fields on the $B$-brane ${\mathscr F}^{\bullet} $,
if it is nonempty, is in bijective correspondence with the points of an
algebraic subset of ${\mathbb C}^m$ defined by $m\cdot s$ polynomial equations
of degree $\leq 3$, where $m={\rm dim}\,{\rm Hom}({\mathscr
F}^{\bullet},\,\Omega^1({\mathscr F}^{\bullet}))$ and $s$ is the number of
non-zero cohomology sheaves ${\mathscr H}^i({\mathscr F}^{\bullet})$. We show
sufficient conditions under them any Yang-Mills field on a reflexive sheaf of
rank $1$ is flat.
