No, nothing in the code that prohibits this per se, as far as I see it.
If the buildings are on different properties or service meters the AHJ might have a problem with it (whether it's AC or DC). I would get approval in advance. And grounding could be complicated or problematic if the buildings' current grounding electrode systems are not already connected.
I would recommend a DC disconnect at the building with the array, regardless of whether the conductors enter the building. Just from the point of view of general safety and AHJ issues that have been discussed here. I don't think it's a code requirement per se.
I'll assume you're not seeking input on the advantages or disadvantages of making the underground run AC instead of DC.