HI,
Are you trying to execute the code from Visual Studio, you need to start VS as Admin.
If you already add the Dll in the bin folder of the client and server AX, then the AOS services must has the same services account that you have setup in the business connector in AX.