You can use aperm and exploit the vectorization. You must indicate which are the "common" dimensions (i.e. the dimensions contained in both X and C), permute X and multiply. Something like:

#declare which are the dimensions in X common to C
commonDims<-c(3,4)
#the other dimensions are the "uncommon" ones
uncommonDims<-setdiff(seq_along(dims),commonDims)
#then you can get the sum
sum(as.vector(aperm(X,c(commonDims,uncommonDims)))*as.vector(C))