Loading or not loading a new project created through the automation APIs

I'm using the automation APIs to write a Trados plugin which creates projects (and optionally packages).

Here is a summary of the code I use to create the project.

var createdProject = new FileBasedProject(settings.ProjectInfo, new ProjectTemplateReference(settings.Template.FullName));

createdProject.AddFolderWithFiles(diFiles.FullName, true);

RunTasks(createdProject, settings);

createdProject.Save();

CreateProjectPackage(createdProject, settings);

Once created, the project is not listed on the Projects view. If I try to open the project in Trados I'm told...

Information dialog box in SDL Trados Studio 2017 stating 'This project has already been opened in SDL Trados Studio 2017 and added to the project list.' with an OK button.

The project is not listed in the ~\Documents\Studio 2017\Projects\projects.xml file. I get the same message if I try to open the package.

However, if I close and re-open Trados I can open the project without any problem.

So why does Trados think that the project has been loaded? Is there a way to only conditionally load the project? Ideally I'd like the plugin to present this as an option to the user (for internal business reasons the person creating the package may not be the person who works with the package).



Generated Image Alt-Text
[edited by: Trados AI at 1:05 PM (GMT 0) on 5 Mar 2024]
Parents Reply
  • Hi Andrea,

    Thanks for the tip. That code sample is pretty much exactly what my code does (I'm using code provided by Romulus). But there's one difference: I create the project in a different directory, not the default Trados Studio/Projects directory, and I was already thinking that this could be the cause of the problem. Does Trados assume that the project will be in the default directory?

    I've found that I can work around this problem by obtaining a reference to the ProjectsController, then closing the newly-created project (ProjectsController.Close(myProject);).

    I can then provide the user with an option to load and possibly activate the project.

    But I'm still left wondering/suspecting that if Trados 'sees' a project being created it will automatically attempt to load that project from the default projects directory.

Children
No Data