All in one simple page: Windows 8 UAC self-elevation (CSUACSelfElevation) sample in C#, XML for Visual Studio 2008.
The secret is to load using:
xml = XDocument.Load(file, LoadOptions.SetLineInfo);
It can be interesting to test speed/memory size impact on really big xml documents.
I did not know it could work.
Settings LARGEADDRESSAWARE on your exe gives you 4GB minus 64KB on 64 bits Windows (found on How can I detect programmatically whether the /3GB switch is enabled? – The Old New Thing – Site Home – MSDN Blogs).
This must be set using command line or Post Build event in VS:
editbin /LARGEADDRESSAWARE Apps.exe