Analyze Task doesn't work

Hello everybody,

I'm trying to write a C# program to create new projects.

I'm using: 

I have installed the Studio Assembly Resolver, but I still have to run my programs from the Studio4 Directory.

When I try to run my program from Visual Studio I get the message:

Managed Debugging Assistant 'PInvokeStackImbalance' has detected a problem in 'C:\Program Files (x86)\SDL\SDL Trados Studio\Studio4\ConsoleApplication1.vshost.exe'.Additional information: A call to PInvoke function 'SentinelRMSCore!SentinelRMSCore.Interface.LSAPI::VLSsetFileName' has unbalanced the stack. This is likely because the managed PInvoke signature does not match the unmanaged target signature. Check that the calling convention and parameters of the PInvoke signature match the target unmanaged signature.

 

EDIT:
Here is my Code:

private String projectName = "test";
        private String projectDir = @"C:\Users\vincenzog\_Studio\";
        private String folderDir = @"C:\Users\vincenzog\Folder";
        private String tmPath = @"C:\Users\vincenzog\CA_en-US_de-DE.sdltm";


        private void button1_Click(object sender, EventArgs e)
        {
            FileBasedProject project = new FileBasedProject(GetProjectInfo(projectName, projectDir, "en-US", "de-DE"));
            project.Save();
            AddFiles(project, folderDir);
            AddTm(project, tmPath);
            ConvertFiles(project);
            RunFileAnalysis(project, "de-DE"); 
           


            project.Save();
        }


        #region Get Info

        public ProjectInfo GetProjectInfo(String projectName, String projectDir, String srcLocale, String trgLocale)
        {
            #region "InfoObject"
            ProjectInfo info = new ProjectInfo();
            #endregion

            #region "GeneralInfo"
            info.Name = projectName; 
            #endregion

            #region "ProjectFolder"
            string localProjectFolder = projectDir + info.Name;
            info.LocalProjectFolder = localProjectFolder;
            #endregion

            #region "SourceLanguage"
            Language srcLang = new Language(CultureInfo.GetCultureInfo(srcLocale));
            info.SourceLanguage = srcLang;
            #endregion

            #region "TargetLanguages"
            Language[] trgLangs = new Language[] { new Language(CultureInfo.GetCultureInfo(trgLocale)) };
            info.TargetLanguages = trgLangs;
            #endregion

            #region "ReturnInfo"
            return info;
            #endregion
        }
        #endregion
        
        #region Add Files
        private void AddFiles(FileBasedProject project, string folderDir)    
        {
            #region "AddFolderWithFiles"
            project.AddFolderWithFiles(folderDir, true);
            #endregion

            #region "GetSourceLanguageFiles"
            ProjectFile[] projectFiles = project.GetSourceLanguageFiles();
            AutomaticTask scan = project.RunAutomaticTask(projectFiles.GetIds(), AutomaticTaskTemplateIds.Scan);
            #endregion
        }
        #endregion

        #region "AddTmFunction"

        private void AddTm(FileBasedProject project, String tmPath) 
        {
            #region "TranslationProviderConfiguration"
            TranslationProviderConfiguration config = project.GetTranslationProviderConfiguration();
            #endregion

            #region "TranslationProviderCascadeEntry"
            TranslationProviderCascadeEntry tm = new TranslationProviderCascadeEntry(tmPath, true, true, false);
            config.Entries.Add(tm);
            project.UpdateTranslationProviderConfiguration(config);
            #endregion
        }
        #endregion

        #region Convert Files 

        private void ConvertFiles(FileBasedProject project)
        {
            #region "GetFilesForProcessing"
            ProjectFile[] files = project.GetSourceLanguageFiles();
            #endregion

            #region "RunConversion"
            for (int i = 0; i < project.GetSourceLanguageFiles().Length; i++)
            {
                Guid[] currentFileId = { files[i].Id };
                if (files[i].Role == FileRole.Translatable)
                {
                   AutomaticTask convertTask = project.RunAutomaticTask(currentFileId, AutomaticTaskTemplateIds.ConvertToTranslatableFormat);
                }

                #region "CopyToTarget"
                AutomaticTask copyTask = project.RunAutomaticTask(currentFileId, AutomaticTaskTemplateIds.CopyToTargetLanguages);
                #endregion
            }
            #endregion
        }
        #endregion

        #region Analyze
        private void RunFileAnalysis(FileBasedProject project, String trgLocale)
        {
            ProjectFile[] targetFiles = project.GetTargetLanguageFiles(new Language(CultureInfo.GetCultureInfo(trgLocale)));
            AutomaticTask analyzeTask = project.RunAutomaticTask(targetFiles.GetIds(), AutomaticTaskTemplateIds.AnalyzeFiles);     
        }
        #endregion







If I try to save the analyze reports I get "IndexOutOfRangeException".

I have no idea where the problem is.


Parents Reply Children