Hi,
Could you post the errors that you are getting?
1) Make sure the url that you use while creating a layer, has the fully qualified path name to your server e.g myserver.esri.com or the ip address
2) If you have a service thats on arcgis.com, if its a secure service then the credentials must be supplied.
Please take a look at the helloworld sample from the sdk, it will help you get started. You could replace the url there with your service url.
Thanks
Archana