Gary Mackay-Steven hit the winner in the 35th minute after Dundee midfielder Jim McAlister had cancelled out Brian McLean's headed opener.
McNamara said: "It was quite an even match, we can play a lot better but Dundee made it hard for us.
"It was a typical cup tie and derby, not a lot of quality or passing. But credit to our lads, and Dundee as well, they put a lot of pressure on us and put extra men up front. I thought we coped with it really well.
"They were on top and we scored a fantastic goal, a great run from Stuart Armstrong and a great pass to Gary Mackay-Steven.
"Dundee had been on top and it was frustrating because they were getting the second balls. But we battled away and got there in the end."
