In order to solve the problem of channeling in the process of CO2 displacement,a technique of the in-situ generating foam system carried by CO2 for formation flow and foam plugging was studied. The law of channeling plugging with in-situ generating foam was discussed under supercritical conditions. Firstly,the dispersibility of the foam system in CO2,the salt resistance performance of the system,and the temperature and pressure resistance ability of the enhanced foam were evaluated to ensure that the system had good foam performance under reservoir conditions. Then,through microfluidic simulation and core displacement experiment,the distribution of residual oil under microscopic conditions and the mobilization of residual oil under different displacement methods were observed,and the ability of in-situ generating foam to block channeling flow and enhance oil recovery was tested. The experimental results show that the in-situ generating foam system has good foaming and foam stability. The system can achieve in-situ foam generation,effectively reduce the residual oil content in column,film,and cluster patterns,and significantly improve the effect of CO2 displacement after CO2 injection. The swept volume is 41.16% higher than that achieved by water flooding and 28.25% higher than that achieved by CO2 displacement. The recovery is 36.56% higher than that achieved by water flooding and 24.78% higher than that achieved by CO2 displacement. The displacement pressure difference in the late stage of in-situ generating foam flooding can reach 1.4 MPa,which is 140 times that of water flooding in the core displacement experiment.After subsequent water flooding,the final recovery reaches 59.20%,which is 40.00% higher than water flooding and 34.90% higher than CO2 displacement.