title: Object must implement IConvertible (InvalidCastException) while casting to interface
body: <p>I'm trying to cast an object of a certain type to an interface it implements using <code>Convert.ChangeType()</code>, however an <code>InvalidCastException</code> gets thrown because <em>the object must implement IConvertible</em>.</p>
  
  <p>The types:</p>
  
  <pre><code>public IDocumentSet : IQueryable {}
  
  public IDocumentSet&lt;TDocument&gt; : IDocumentSet, IQueryable&lt;TDocument&gt; {}
  
  public XmlDocumentSet&lt;TDocument&gt; : IDocumentSet&lt;TDocument&gt; {}
  </code></pre>
  
  <p>Excerpt from code where the error happens:</p>
  
  <pre><code>private readonly ConcurrentDictionary&lt;Type, IDocumentSet&gt; _openDocumentSets = new ConcurrentDictionary&lt;Type, IDocumentSet&gt;();
  
  public void Commit()
  {
      if (_isDisposed)
          throw new ObjectDisposedException(nameof(IDocumentStore));
  
      if (!_openDocumentSets.Any())
          return;
  
      foreach (var openDocumentSet in _openDocumentSets)
      {
          var documentType    = openDocumentSet.Key;
          var documentSet     = openDocumentSet.Value;
  
          var fileName        = GetDocumentSetFileName(documentType);
          var documentSetPath = Path.Combine(FolderPath, fileName);
  
          using (var stream = new FileStream(documentSetPath, FileMode.Create, FileAccess.Write))
          using (var writer = new StreamWriter(stream))
          {
              var documentSetType     = typeof (IDocumentSet&lt;&gt;).MakeGenericType(documentType);
              var writeMethod         = typeof (FileSystemDocumentStoreBase)
                                          .GetMethod(nameof(WriteDocumentSet), BindingFlags.Instance | BindingFlags.NonPublic)
                                          .MakeGenericMethod(documentSetType);
              var genericDocumentSet  = Convert.ChangeType(documentSet, documentSetType); &lt;-------
  
              writeMethod.Invoke(this, new[] {writer, genericDocumentSet});
          }
      }
  }
  </code></pre>
  
  <p>Now, I'm failing to understand why exactly this happens (as <code>XmlDocumentSet</code> is not a value type) and <code>XmlDocumentSet&lt;'1&gt;</code> implements <code>IDocumentSet&lt;'1&gt;</code>. Am I missing something? Or is there an easier way to achieve what I'm doing?</p>