The paper deals with the problem of minimizing a real-valued smooth function fcolon X to Bbb R over the set D={x in X,|,F(x) in Q}, where Fcolon X to Y is a smooth mapping, X and Y are Banach spaces, and Q is a closed convex set of Y. The authors say that the mapping Fcolon X to Y is 2-regular at a point overline{x} with respect to the set Q in a direction h in X if 0 in {rm int}(F(overline{x}) + {rm Im}F'(overline{x})+F"(overline{x})[h,,(F'(overline{x}))^{-1}(Q -F(overline{x}))] - Q). When h = 0 the 2-regularity coincides with the well-known Robinson regularity condition [S. M. Robinson, Math. Oper. Res. {bf 1} (1976), no.~2, 130--143; [msn] MR0430181 (55 #3188) [/msn]]. Moreover Robinson's regularity condition implies that F is 2-regular at overline{x} with respect to Q in any direction h in X (including h=0). However, the mapping F may be 2-regular at overline{x} in some nonvanishing directions h in X,,h ne 0, and not satisfy Robinson's regularity condition. The authors show that in the case when the 2-regularity condition holds one can obtain representations both for the contingent cone and for the set of second-order tangent vectors to the constraint set D at overline{x} in the terms of local approximations of the set Q and Fréchet derivatives of F. Using these representations the authors derive first- and second-order necessary conditions for local optimal solutions of the optimization problem being considered.