[Tex/LaTex] Keep getting “aux file” error with the lastpage package

lastpageresume

Keep getting "aux file" error with the lastpage package. The same code is working in another file but not in this one (code furnished here). Please help! Thank you!

\documentclass[margin, 11pt]{res}
\setlength{\textwidth}{5.1in}
\usepackage{helvet}                  % Default font is the helvetica postscript font
\usepackage{lastpage}

\usepackage{fancyhdr}                % http://ctan.org/pkg/fancyhdr
  \pagestyle{fancy}                  % Set default page style to fancy
  \renewcommand{\headrulewidth}{0pt} % Remove header rule
  \fancyhead{}                       % Remove all header contents
  \cfoot{Parul Gupta\\ Page \thepage\ of \pageref{LastPage}}
                                     % Page X of Y in the footer (centered)

\begin{document}
%----------------------------------------------------------------------------------------
%   NAME AND ADDRESS SECTION
%----------------------------------------------------------------------------------------
%\cfoot{\thepage\ of \pageref{LastPage}}
\moveleft.5\hoffset\centerline{\large\bf Parul Gupta} % Your name at the top

\moveleft\hoffset\vbox{\hrule width\resumewidth height 0.25pt}\smallskip % Horizontal line after name; adjust line thickness by changing the '1pt'

\moveleft.5\hoffset\centerline{add line 1 } % Your address
\moveleft.5\hoffset\centerline{add line 2}
%\moveleft.5\hoffset\centerline{}
%----------------------------------------------------------------------------------------
\begin{resume}

\end{resume}
\end{document}

Best Answer

As part of the res.cls document class, it executes:

\nofiles         % resume's don't need .aux files

This avoid the creation of auxiliary files, needed when using references (which lastpage requires). So, add

\let\nofiles\relax

before loading the document class.