Let $A$ be a closed self-adjoint operator on a Hilbert space $H$, possibly unbounded and hence defined on a dense domain $D(A) \subset H$. It is well known that integrating the resolvent $R_z = (z I - A)^{-1}$ on a positively oriented simple closed $z$-contour $C$ (which is contained in the resolvent set of $A$) against a function $f(z)$ that is holomorphic on a neighborhood of $C$ and its interior gives $$ f(P_C A) = \frac{1}{2\pi i} \oint_C f(z) R_z \, dz , \tag{*}$$ where $P_C$ is the projection onto the $A$-invariant subspace of $H$ corresponding to the part of the spectrum of $A$ that is contained within $C$. This is the (Dunford-Schwartz) holomorphic functional calculus.

Is there a way to make sense of the integral in $(*)$ if $C$ intersects the spectrum of $A$? In particular, what if $C$ transversely intersects the real line across the absolutely continuous spectrum of $A$?

I know that $\|R_z\|$ diverges as $z$ approaches the spectrum, so the integral will at the very least be improper. However, perhaps there is a way to make sense of it with some kind of regularization, distributional interpretation or restriction of the domain on which the integrand is considered. If possible, it would be a particularly convenient way to express the spectral projection onto a sub-interval $[a,b]$ of the absolutely continuous spectrum as $P_{[a,b]} = \frac{1}{2\pi i} \oint_C R_z \, dz$, where $C$ is a closed curve that intersects the real line at $a$ and $b$.