Which of these sentences is more correct?
ABC should not be referenced from file X.
ABC should not be referenced in file X.
They're both correct and the meaning is essentially the same. I'd say that the preposition choice depends on how you intend to communicate the message.
If you think of the reference as an arrow in a diagram coming from file X to ABC, then from works better as the preposition, as it indicates movement and direction:
If you think of the reference to ABC within the boundaries of file X, then it is in that works better as the preposition, as it indicates inclusion within a space:
I would probably write the sentence with from in a technical document, as I usually think of arrows and direction when I'm thinking of references between files or objects.
Both usages are completely correct, and there's no difference in meaning between them that I can perceive. Use whichever one you feel more comfortable with.
Even though other answers say your two sentences mean the same thing, they sound different to me.
Sounds to me like file X should not contain any references to ABC.
Sounds to be like file X contains an ABC that nothing else should reference. If that's the intended meaning, then I would use:
There might be an ABC in a different file that could be referenced, but the one in file X should not be referenced.