I finally found a solution to the “CreateRiaClientFilesTask task failed unexpectedly. — Attempted to access an unloaded AppDomain” problem in Visual Studio which had been affecting me for many weeks on my current project.
Googling it seems many people are struggling with it; it seems like this is a catch all error, not necessarily related to unloaded domains.
What worked for me was to close ALL xaml editor windows in visual studio, and close all browser windows that have silverlight open.
Then try the build and see if it works. Sometimes it may take 30-60 seconds before it works. The key seems to be making sure there are no WPF or Silverlight classes loaded at ALL in the system, then try the build.
Let me know if that works for you,