Cannot add more than one Termbase without getting exception

I am trying to add multiple Termbases to a project, but when I do, I get the following error as soon as I open a file within the project:

Here is the code I am currently using to add the termbases:

        private void AddTermbase(List<LocalTermbase> termbases, FileBasedProject project)
        {
            TermbaseConfiguration termbaseConfig = project.GetTermbaseConfiguration();
            Sdl.MultiTerm.TMO.Interop.Application mt = new Sdl.MultiTerm.TMO.Interop.Application();

            TermRecognitionOptions options = termbaseConfig.TermRecognitionOptions;
            options.MinimumMatchValue = 50;
            options.SearchDepth = 200;
            options.ShowWithNoAvailableTranslation = true;
            options.SearchOrder = TermbaseSearchOrder.Hierarchical;
            termbaseConfig.TermRecognitionOptions = options;

            TermbaseRepository localRep = mt.LocalRepository;
            localRep.Connect("", "");
            foreach (LocalTermbase tb in termbases)
            {
                termbaseConfig.Termbases.Add(tb);
            }

            foreach (LocalTermbase tb in termbases)
            {
                localRep.Termbases.Add(tb.FilePath, "", "");
            }

            Sdl.MultiTerm.TMO.Interop.Termbase termbase = localRep.Termbases[0];
            Sdl.MultiTerm.TMO.Interop.TermbaseDefinition def = termbase.Definition;
            Sdl.MultiTerm.TMO.Interop.Indexes indexes = def.Indexes;

            foreach (Sdl.MultiTerm.TMO.Interop.Index index in indexes)
            {
                termbaseConfig.LanguageIndexes.Add(new TermbaseLanguageIndex(new Language(CultureInfo.GetCultureInfo(index.Locale)), index.Label));
            }

            project.UpdateTermbaseConfiguration(termbaseConfig);
        }

Note I have tried many variations of the above code, and all my attempts result in the same error. However, the code works fine as long as I am only adding one Termbase (when the List<LocalTermbase> only contains one entry). Any help understanding why would be appreciated.