Residue of the canonical sheaf along subvariety Let $S$ be a smooth projective surface over an
algebraically closed field $k$ and $C \subset S$ a singular curve. Let us denote by $K_S$ the class of canonical divisor of $S$ and $\mathcal{O}(K_S)$ the canonical sheaf. If $\Omega_{S/k}$ is the sheaf of Kähler differentials, then smoothness of $S$ and $\mathcal{O}(K_S)=\Omega_{S/k}^2$ imply that $\mathcal{O}(K_S)$ is generated locally by an the element $\frac{1}{f} dx \wedge dy$ where $dx, dy$ are local basis elements of $\Omega_{S/k}$ and certain $f \in K(S)$. 
I found recently a statement (I forgot the source, I think it was Kollar's Resolutions of Singularities) that locally the residue of $\frac{1}{f} dx \wedge dy$ gives a generator $r \vert _C$ of restriction $\mathcal{O}_S(C+K_S) \vert _C$.
The residue $r$ is characterized by equation 
$$f^{-1}dx \wedge dy= \frac{df}{f} \wedge r $$
My questions are quite general: 
I'm looking for sources dealing with this residue construction and it's properties in detail. How far can this constrution be generalized? ie is it possible to construct for instead of a smooth surface for an arbitrary smooth projective variety $V$ of algeb closed field from the local generator of it's canonical sheaf $O_V(K_V)$ a residue along a codimension one subscheme $D$? And why gives this residue a local generator of $O_V(D +K_V) \vert _D$?
It looks like a far generalization of the concept of residues from basic complex analysis but since I still have nowhere found any books treating this construction in detail I don't know which interesting properties the residue by this constructions obtains and why the construction can be considered as a generalization of the story from complex analysis.
 A: I believe that what you wrote is not entirely correct and that might be the reason that it does not seem to work out. As a response to one of your comments, $K_C$ actually makes sense in this case, because it is a Cartier divisor in $S$ and hence Gorenstein. I'll elaborate on this below. 
So, I don't think $\frac{1}{f} dx \wedge dy$ generates $\mathscr O(K_S)$ (locally). If you think about it, essentially by definition $dx \wedge dy$ generates that sheaf (locally), so the additional $\frac 1f$ gives it a twist. My guess is that what you saw said that $f$ should be a local equation for $C$ and if it is that then $\frac{1}{f} dx \wedge dy$ generates $\mathscr O(K_S+C)$ locally. If this is OK with you, then it is no surprise that its restriction to $C$ generates the restricted sheaf. 
And, indeed, there is a more general framework for this. Using your notation, let $V$ be a Cohen-Macaulay (CM) scheme (or variety, or complex analytic space) and let $D\subseteq V$ be an effective Cartier divisor (this can be weakened to $D$ being a pure codimension $1$ subscheme/subvariety, but in that case you have to be a bit more careful about the sheaves that appear, so I'll stick to this case for simplicity).
I will use the notation $\omega_X=\mathscr O_X(K_X)$ for any $X$ for which this makes sense.
Then we have a short exact sequence:
$$
0\to \mathscr O_V(-D)\to \mathscr O_V\to \mathscr O_D \to 0
$$
The long exact $\mathscr Ext$ sequence associated to the functor $\mathscr Hom_V(\__, \omega_V)$ (and the fact that $V$ is CM) gives the 
short exact sequence:
$$
0\to \omega_V\to \omega_V(D)\to \omega_D \to 0
$$
The map $\omega_V(D)\to \omega_D$ is essentially what you are looking for and can be interpreted so that $\omega_V(D)|_D\simeq \omega_D$. 
If $V$ is Gorenstein and $D$ is a Cartier divisor (then $D$ is also Gorenstein), then all of these sheaves are locally free of rank $1$ on their support, so you can find local generators that look pretty much the ones you wrote down. If $V$ is smooth, then it is Gorenstein and then every codimension $1$ subvariety is a Cartier divisor, so this covers the case you were wondering about. 

A few explanations, mainly sparked by the questions in the comments:
The canonical sheaf, Hom long exact sequence, and all that jazz: I wasn't entirely sure how much to include and what generality to go to. The formula involving Ext and projective space and the codimension of V in that projective space is a special case of Grothendieck duality and it holds any time a Gorenstein scheme is contained in another. (The proper way to write this would be writing out the "usual" (total) derived functor format and then take cohomology of that). In any case, this implies that $\omega_D\simeq \mathscr Ext^1_V(\mathscr O_D, \omega_V)$ if you start writing out the Hom-Ext sequence, the first Hom will be zero, then you have two terms (the first two terms of that ses) and then this Ext. All other terms are zero, because if the first term is locally free, then all higher Exts are zero. This is how you get that short exact sequence. 
As far as using the Ext formula vis-a-vis the projective space, you can do that, you'll get the same thing. Grothendieck duality is nice in this regard, it is natural, so you can apply it consecutively for a composition. This is actually a nice exercise if you have never done it. 
Being Gorenstein is equivalent to being CM and the canonical sheaf being locally free of rank 1. The definition of CM implies that (local) hypersurfaces inherit being CM (essentially the definition of depth does this). And the above short exact sequence implies the local freeness of the canonical sheaf. 
