I am trying to use the SMO for Sql Server 2008 R2 Standard, but I am running into an issue whenever I try to Dump
an object.
The relevant code:
void Main()
{
var connectionString = @"Server=(local);Trusted_Connection=True;";
Server server = new Server(new ServerConnection(new SqlConnection(connectionString)));
server.ConnectionContext.Connect();
server.Dump(); //Error
Database database = new Database(server, "master");
database.Refresh();
database.Dump(); // Error
IEnumerable<Table> tables = database.Tables.Cast<Table>();
tables.Dump(); //Error
}
Edit:
A work around that I found is to use the Dump
method with a fixed recursion depth e.g. Dump(1)
, but the exception is at a different level for each object.