Automation for Update TM

Hello,

I'm developing a tool with translation memory API for a regulary offline TM import task with the help of Laurent Pierret(see previous topic at: https://community.sdl.com/phase_2_groups/sdl_openexchange_developers/f/57/t/2758.aspx)

I'm using TranslationMemoryImporter now and met some trouble now:

the sample from sdk is like:
FileBasedTranslationMemory tm = new FileBasedTranslationMemory(tmPath);
TranslationMemoryImporter importer = new TranslationMemoryImporter(tm.LanguageDirection);
importer.ImportSettings = GetimportSetting();
importer.BatchImported += new EventHandler<BatchImportedEventArgs>(this.importer_BatchImported);
importer.Import(importFilePath);

First question is Do I need open this tm before imporing, if not how importer knows which tm to be imported, importer only gets a LanguageDirection from tm.

API sample is about import tmx and from API I guess is also supports SDLXLIFF/TTX/ITD if attribute IsDocumentImport=true and when running test I got some error:
Thanks your for looking into below error message and please suggest what to do next, if more code need I can upload, it is actually quite simple, read config> loop import> log statics

tmx test, seems requires "language resource file"
-----------------------------------------------
Sdl.LanguagePlatform.Core.LanguagePlatformException was unhandled
  HResult=-2146233088
  Message=The language resource file could not be located.
  Source=Sdl.LanguagePlatform.TranslationMemoryApi
  StackTrace:
       at Sdl.LanguagePlatform.TranslationMemoryApi.FileBasedTranslationMemoryLanguageDirection.AddTranslationUnits(TranslationUnit[] translationUnits, ImportSettings settings)
       at Sdl.LanguagePlatform.TranslationMemoryApi.TranslationMemoryImporter.ProcessBufferedTUs(ImportStatistics stats)
       at Sdl.LanguagePlatform.TranslationMemoryApi.TranslationMemoryImporter.ImportTranslationUnit(TranslationUnit translationUnit, ImportStatistics stats)
       at Sdl.LanguagePlatform.TranslationMemoryApi.TranslationMemoryImporter.ImportTMXFile(TMXReader reader)
       at Sdl.LanguagePlatform.TranslationMemoryApi.TranslationMemoryImporter.ImportTMXFile(String fileName)
       at Sdl.LanguagePlatform.TranslationMemoryApi.TranslationMemoryImporter.Import(String fileName)
       at ImportStudioTM.TMImporter.ImportFile(String tmPath, String importFilePath, ImportSettings importSetting) in D:\PS\DEV\ImportStudioTM\ImportStudioTM\ImportStudioTM\TMImporter.cs:line 30
       at ImportStudioTM.Program.Main(String[] args) in D:\PS\DEV\ImportStudioTM\ImportStudioTM\ImportStudioTM\Program.cs:line 71
       at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
       at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
       at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
       at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
       at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
       at System.Threading.ThreadHelper.ThreadStart()
  InnerException:
-----------------------------------------------
sdlxliff test, seems it tries to get plug-in directory, but this is a console app, not from plugin template
-----------------------------------------------
System.Reflection.TargetInvocationException was unhandled
  HResult=-2146232828
  Message=Exception has been thrown by the target of an invocation.
  Source=mscorlib
  StackTrace:
       at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor)
       at System.Reflection.RuntimeConstructorInfo.Invoke(BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
       at System.RuntimeType.CreateInstanceImpl(BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes, StackCrawlMark& stackMark)
       at System.Activator.CreateInstance(Type type, BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes)
       at System.Reflection.Assembly.CreateInstance(String typeName, Boolean ignoreCase, BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes)
       at Sdl.FileTypeSupport.Framework.Core.Utilities.IntegrationApi.DefaultFileTypeManager.CreateInstance(Boolean autoLoadFileTypes)
       at Sdl.LanguagePlatform.TranslationMemoryApi.TranslationMemoryImporter.GetDefaultFileTypeManager()
       at Sdl.LanguagePlatform.TranslationMemoryApi.TranslationMemoryImporter.ImportBilingualFile(String fileName)
       at Sdl.LanguagePlatform.TranslationMemoryApi.TranslationMemoryImporter.Import(String fileName)
       at ImportStudioTM.TMImporter.ImportFile(String tmPath, String importFilePath, ImportSettings importSetting) in D:\PS\DEV\ImportStudioTM\ImportStudioTM\ImportStudioTM\TMImporter.cs:line 30
       at ImportStudioTM.Program.Main(String[] args) in D:\PS\DEV\ImportStudioTM\ImportStudioTM\ImportStudioTM\Program.cs:line 71
       at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
       at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
       at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
       at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
       at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
       at System.Threading.ThreadHelper.ThreadStart()
  InnerException: Sdl.Core.PluginFramework.PluginFrameworkException
       HResult=-2146233088
       Message=No Application specific plug-in directory found.
       Source=Sdl.Core.PluginFramework
       StackTrace:
            at Sdl.Core.PluginFramework.DefaultPluginLocator..ctor()
            at Sdl.Core.PluginFramework.PluginManager.get_DefaultPluginRegistry()
            at Sdl.FileTypeSupport.Framework.Integration.PocoFilterManager.LoadAllDefaultFileTypeDefinitions()
            at Sdl.FileTypeSupport.Framework.Integration.PocoFilterManager..ctor(Boolean autoLoadFileTypes)
       InnerException:
-----------------------------------------------

Thanks,
Harry