I had the same exact problem when referencing System.Xml.Linq. Switching to a compiled task does solve your solution, but to implement the original code as an Inline Task, simply drop the file extension from the references then your inline task so that you reference the root namespace rather than the file name.
Change this:
<Reference Include="System.Xml.dll" />
<Reference Include="System.Xml.Linq.dll"/>
To read:
<Reference Include="System.Xml" />
<Reference Include="System.Xml.Linq"/>