You will need to provide a lot more information than this. 1000 lines of copy pasted code is not easy for us to debug.
You need to step through your code like this and see if you get any asserts. Most likely you are doing something wrong when you add the service and you will get an assert.