I will tell you how I know that the code is correct, and what is not working.
I used to program the PIC18 using USB module using a bootloader of 20MHz, and I download the program using PICDEM ES USB demo tool. This way the program works, but with some problem with the start up of the PIC18, I need to try 3 - 4 times to make it start.
Now I am trying to download the same program using PICkit2, I download it and put the PIC18 in the test, but nothing happens.