you can not use object model code form client forms, a workaround might be to create web services and invoke them in your code.
to debug the code, you need to open your template , in the file -> preview-> preview settings
specify the file location of the form you want to debug.
then go to your managed code and press F5(run the application).