title: Unable to delete Realm database in Realm dotnet 2.1.0
body: <p>Using Realm dotnet 2.1.0 in a Xamarin Forms project, I'm unable to delete the database due to the "Unable to delete Realm because it is still open" message.</p>
  
  <p>This has only been an issue since upgrading to 2.1.0, previously we were using Realm 0.80.</p>
  
  <p>Here's our full database removal method:</p>
  
  <pre><code>public void RemoveDatabase()
  {
    // Remove all content.
    try
    {
      ClearCachedDataItems();
    }
    catch (Exception ex)
    {
      //Logging removed
    }
  
    try
    {
      // Close all connections
      using (var realm = GetRealmInstance())
      {
        if (realm != null)
        {
          realm.Dispose();
        }
      }
    }
    catch (Exception ex)
    {
      //Logging removed
    }
    try
    {
      // Drop the nuke.
      var config = GetRealmConfiguration();
      var delete = false;
  
      using (var realm = Realms.Realm.GetInstance(config))
      {
        if (config != null)
        {
          delete = true;
        }
        realm.Dispose();
  
      }
  
      if (delete)
      {
        Realms.Realm.DeleteRealm(config); // fails here
      }
  
    }
    catch (Exception ex)
    {
      //Logging removed
    }
  }
  
  public Realms.Realm GetRealmInstance()
  {
    var config = GetRealmConfiguration();
  
    if (config == null)
    {
      return null;
    }
  
    return Realms.Realm.GetInstance(config);
  }
  </code></pre>
  
  <p>I added the using statements based on this git post: <a href="https://github.com/realm/realm-dotnet/issues/1545" rel="nofollow noreferrer">https://github.com/realm/realm-dotnet/issues/1545</a></p>
  
  <p>Is there a way to get all running instances of local Realms? </p>
  
  <p>I'm also concerned that I'm creating a new instance of Realm in the final steps when I just want to check a local instance.</p>