if the error is in the debugging... i would first try it straight from AutoCAD (not thru the debugger in VS)... open up a session of AutoCAD and netload your dll file in, if it works here then your code is fine and it's probably a setting or 2 wrong in the debugging mode.
one thing with the debugging mode, is you have to set the 'working directory' to be the same as the acad.exe file your executing thru the debugger... if you go to the project properties -> debugging tab you'll find the 'working directory' there... put in the folder path to the acad.exe (for me its c:\program files\autocad 2006\)
Just had the same problem and fixed with the suggestion from one of the earlier posts. Don't know if you overlooked it.
Goto the Project menu and click on ... Properties at the bottom. Then make sure that in the Debug tab you've got 'Start external program' selected and it points to your acad.exe file then make sure that the 'working directory' box points to the folder that holds acad.exe. Should work fine then through debug mode.