Oscillator settings shouldn't have anything to do with in-circuit programming.

Can you program the 819 in your programmers socket, but it fails when attempting to program in-circuit?

A couple of things to check would be;

Make sure you have solid connections with short wires from your programmers clock, data, Vpp, and ground connections to the 819 being programmed in-circuit. I keep mine under 5 inches.

Power your circuit separately without attempting to supply power from your programmer to the board/circuit being programmed.

Make sure you isolate, I,E, you have no circuit connections to your 819 programming clock & data pins like LED's, sensors, etc, during ic-circuit programming. Loads on PGC & PGD will definitely cause problems during ICSP attempts.

I use a small switch to flip between ICSP & normal run modes on my 819 dev board, and I can program it all day long with the EPIC attached via a "short" 10-pin header/flat-ribbon cable.

If you still have problems, write a simple LED blink routine, and be sure to set LVP "off", drop the 819 into your programmer socket, and burn it.

@ DEVICE LVP_OFF, MCLR_OFF

Make sure the LED blink routine is running as expected first, then see if you can program it in-circuit.

You might want to also check your programmers software after loading your .HEX file before programming the 819 to make sure it's not over-ridding whatever embedded config fuse settings you have. Some programmer software uses the config fuse settings shown on-screen, and may ignore whatever you have embedded in your .hex file.

Also, you might want to check to see if your programmer does an erase before programming.

If I turn off the "Erase Before Programming" option in my EPIC software, then try ICSP on the 819, it fails every single time. I turn this option back on, and presto, works every time.