Copy Page Setup from other file

Hello, I'm trying to copy a page setup from another file, based on this blog post:
https://adndevblog.typepad.com/autocad/2012/04/copying-a-plotting-setting-from-one-drawing-to-another.html

But, using Bricscad I'm getting an error on the method: "newSettings.AddToPlotSettingsDictionary(_db);".

The error message that Bricscad shows is:
"Message: eWrongDatabase
StackTrace: em Teigha.DatabaseServices.PlotSettings.AddToPlotSettingsDictionary(Database
toWhichDatabase)"

Here is the code used:

internal static void Copy(string referenceFileName, string referencePageSetupName)
{
Document doc = Application.DocumentManager.MdiActiveDocument;
Database _db = doc.Database;

using (Database _srDb = new Database(false, true))
{
_srDb.ReadDwgFile(referenceFileName, System.IO.FileShare.Read, true, null);

using (Transaction _templateTr = _srDb.TransactionManager.StartTransaction())
{
using (Transaction _tr = _db.TransactionManager.StartTransaction())
{
DBDictionary dbDict = _templateTr.GetObject(_srDb.PlotSettingsDictionaryId, OpenMode.ForRead) as DBDictionary;

if (dbDict != null)
{
ObjectId settingsId = dbDict.GetAt(referencePageSetupName);
PlotSettings settings = _templateTr.GetObject(settingsId, OpenMode.ForRead) as PlotSettings;

PlotSettings newSettings = new PlotSettings(true);
newSettings.CopyFrom(settings);

//ERROR ON THE FOLLOWING LINE
newSettings.AddToPlotSettingsDictionary(_db);

_tr.AddNewlyCreatedDBObject(newSettings, true);
}
_tr.Commit();
}
_templateTr.Commit();
}
}
}

I'm sure the "referenceFileName" is a valid DWG and contains a page setup called "referencePageSetupName". It works copy the page setup using mannualy the command PSETUPIN.

Any ideia how can I proceed to copy programatelly a page setup from other file?