The error is pretty self explanatory, if you look at it.
Absolute path information is required
Is coming on this line:
FileIOPermission filePermission =
new FileIOPermission(FileIOPermissionAccess.AllAccess, "data.xml");
Because "data.xml" is a
relative path - and it's relative to wherever the current app is running at this precise moment. The DLL doesn't know where that is, or at the very least isn't sure that it knows, so it specifically tests for an absolute location when you specify the file name.
It's a bit like being in a library, and talking to someone on the phone. When you tell them you are reading "this book" that doesn't help them come and look at it because "this book" is a relative address: you need to say: "Floor 3, IT Section, Row 14, Shelf 3, 'Fundamentals of OOPs programming'" to provide them with an absolute address for them to walk up the stairs and find it.
So replace "data.xml" with it's absolute address: @"C:\I keep stuff here\XML files\data.xml" and it should get rid of the error.
By the way, have a look at this:
Where should I store my data?[
^] - it may be a little advanced for you, but it suggests some sensible places to keep data, and shows you how to get the path to them.