This paper provides an analysis of the effect of corporate and personal taxes on the firm's optimal investment and financing decisions under uncertainty. It extends the DeAngelo and Masulis capital structure model by endogenizing the firm's investment decision. The authors' results indicate that, when investment is allowed to adjust optimally, the existing predictions about the relationship between investment-related and debt-related tax shields must be modified. In particular, the authors show that increases in investment-related tax shields due to changes in the corporate tax code are not necessarily associated with reductions in leverage at the individual firm level. In cross-sectional analysis, firms with higher investment-related tax shields (normalized by expected earnings) need not have lower debt-related tax shields (normalized by expected earnings) unless all firms utilize the same production technology. Differences in production technologies across firms may thus explain why the empirical results of recent cross-sectional studies have not conformed to the predictions of DeAngelo and Masulis.