title: System.XML.Linq assembly: The type 'System.Xml.Linq.XDocument' is defined in an assembly that is not referenced
body: <p>I have some strange error in my project:</p>
  
  <pre><code>Error   1   The type 'System.Xml.Linq.XDocument' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Xml.Linq, Version=2.0.5.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'.
  </code></pre>
  
  <p>BUT I did add a reference to "System.Xml.Linq" assembly. Also I have it in "using" section.</p>
  
  <p>Code example:</p>
  
  <pre><code>using System;
  using System.Collections.Generic;
  using System.Xml.Linq;
  
  //...........
  
  APIConnection VK;
  
  public override Collection MakeCollection(
          CollectionRequestContext context)
      {
  
  //............
          Dictionary&lt;string, string&gt; q = new Dictionary&lt;string,string&gt;();
          foreach (string item in context.Query.AllKeys)
          {
              q.Add(item,context.Query.Get(item));
          }
  
          ///Here I have 3 errors
          VK= new APIConnection("", q, ErrorHandler, true);
  
  
          //Error 1: The type 'System.Xml.Linq.XDocument' 
          //is defined in an assembly that is not referenced. 
          //You must add a reference to assembly 'System.Xml.Linq...
          // 
          //Error 2: The best overloaded method match for 
          //'APIConnection.APIConnection(string, 
          // System.Collections.Generic.Dictionary&lt;string,string&gt;,
          // ApiCallBackHandler&lt;System.Xml.Linq.XDocument&gt;, bool)' 
          //has some invalid arguments
          //
          //Error 3: Argument 3: cannot convert from 'method group' to 
          //'ApiCallBackHandler&lt;System.Xml.Linq.XDocument&gt;'   
  
  //............
      }
  
  
      void ErrorHandler(XDocument result)
      {
          if (result == null)
          {
              throw new Exception("Something wrong...");
          }
      }
  </code></pre>
  
  <p>Just in case: 
  1. I have similar project with exactly the same part of code and it's work!
  2. Project with error is WebProject and project that's work is a Silverlight Class Library</p>
  
  <p>Why I have this error?</p>
  
  <h1>UPD</h1>
  
  <p>APIConnection constructor:</p>
  
  <pre><code>public APIConnection(string secret, Dictionary&lt;string,string&gt; query, ApiCallBackHandler&lt;XDocument&gt; errorCalback, bool testmode=false)
      {
          startInfo = new StartInfo();
  
          if (query != null)
          {
              string tmp;
              bool isRequiredSet = true;
              isRequiredSet = query.TryGetValue("api_url", out startInfo.api_url) || isRequiredSet;
              isRequiredSet = query.TryGetValue("api_id", out startInfo.api_id) || isRequiredSet;
              isRequiredSet = query.TryGetValue("api_settings", out startInfo.api_settings) || isRequiredSet;
              if (!isRequiredSet)
                  throw new ArgumentNullException("Missing required values.");
  
          }
  
          startInfo.server_secret = secret;
  
          dataProvider = new DataProvider(startInfo,errorCalback);
      }
  </code></pre>
  
  <p>And DataProviders constructor is:</p>
  
  <pre><code>    public DataProvider(StartInfo info, Delegate globalErrorCallback=null)
      {
          startInfo = info;
          _globalErrorCallback = globalErrorCallback;
      }
  </code></pre>