Emittance growth induced by space charge effect is very important, especially for CW DC-gun photoinjector. In this work, the linear space charge force and its effect on electron beam transverse emittance are studied, and the principle and properties of emittance compensation by solenoid are analyzed. The CAEP DC-gun photoinjector with a solenoid is also simulated by code Parmela. Simulated results indicate that the normalized transverse emittance of an 80 pC bunch at the 350 keV DC-gun exit is 5.14 mmmrad. And after compensated by a solenoid, it becomes 1.27 mmmrad. The emittance of beam is well compensated.