You say the code is for AutoCAD 2012, yet you listed reference to "accoremgd.dll", which is only available to AutoCAD2013 or later. Considering the error you get, I suspect that you somehow used the set of references (acdbmgd.dll/accoremgd.dll, acmgd.dll and the COM PIAs) from AutoCAD2013 or later, maybe downloaded from ObjectARX SDK for AutoCAD2013 or later.
Make sure you use these DLLs from ObjectARX SDK for AutoCAD2012 and try it again.