8. The real coefficient quadratic equation in one variable
$$
x^{2}+(a+1) x+a+b+1=0
$$

has two real roots $x_{1}, x_{2}$. If $0<x_{1}<1$ and $x_{2}>1$, then the range of $\frac{a}{b}$ is ( ).
(A) $\left(-2,-\frac{1}{2}\right)$
(B) $\left(-2, \frac{1}{2}\right)$
(C) $\left(-1,-\frac{1}{2}\right)$
(D) $\left(-1, \frac{1}{2}\right)$
8. A.

Let $f(x)=x^{2}+(a+1) x+a+b+1$. Then
$$
\left\{\begin{array} { l } 
{ 0  1 }
\end{array} \Leftrightarrow \left\{\begin{array} { l } 
{ f ( 0 ) > 0 , } \\
{ f ( 1 ) < 0, } \\
{ 2 a+b+3 < 0 . }
\end{array}\right.\right.\right.
$$

Draw the feasible region, the line $a+b+1=0$ and $2 a+b+3=0$ intersect at point $A(-2,1)$ (as shown in Figure 3), the feasible region for $(a, b)$ is the shaded area in the figure (excluding the boundaries).
The value of $\frac{b}{a}$ is the slope of the line connecting the point $(a, b)$ in the feasible region to the origin. Clearly, it is less than the slope of line $O A$, which is $-\frac{1}{2}$, and greater than the slope of the line $2 a + b + 3 = 0$, which is -2 (the range indicated by the dashed lines in Figure 3), i.e., $-2 < \frac{b}{a} < -\frac{1}{2}$.