  A general method of obtaining linear differential equations having polynomial
solutions is proposed. The method is based on an equivalence of the spectral
problem for an element of the universal enveloping algebra of some Lie algebra
in the "projectivized" representation possessing an invariant subspace and the
spectral problem for a certain linear differential operator with variable
coefficients. It is shown in general that polynomial solutions of partial
differential equations occur; in the case of Lie superalgebras there are
polynomial solutions of some matrix differential equations, quantum algebras
give rise to polynomial solutions of finite--difference equations.
Particularly, known classical orthogonal polynomials will appear when
considering $SL(2,{\bf R})$ acting on ${\bf RP_1}$. As examples, some
polynomials connected to projectivized representations of $sl_2 ({\bf R})$,
$sl_2 ({\bf R})_q$, $osp(2,2)$ and $so_3$ are briefly discussed.
