I am working on a customization for a client and while making some changes to the Ticket Detail quick form and compiling I was getting a velocity exception as pictured here
I had been adding controls, and a new form load action when I got this issue so my first suspect was around the load action given the description. I systematically removed the script, and all of the newly added controls. To my dismay the exception continued to occur. I then copied a fresh version of the TicketDetails smartpart/resx file back into the model and refreshed the project and the error went away.
It was then when I was re-cleaning the smart part when I found out what had happened. You see there is a contract lookup on the detail smart part. For this customization I had to remove it as it was not needed. When I removed it I was unaware that there was a reference to the control in a load action validation method. Since this reference still existed NVelocity could not resolve to the control hence the exception (though the error is not that descriptive). Once I removed the reference I was then able to recompile again.
So the Rule is: If you are removing a control from a smart part, ensure that there are no validation/property set actions referencing the control or you will see the above error.