"Exception has been thrown by the target of an invocation." following the Sample Translation Service Provider Plug-in example

Hi all, 

I'm following the Sample Translation Service Provider Plug-in example and I got an "Exception has been thrown by the target of an invocation." error at MyTranslationProviderWinFormsUI.get_TypeName() when I create a new project, add a file and click on "Next".

I'm using SDL Trados 2017 with Visual Studio 2017.

I have no idea why, if someone can help me please.

Thanks, 

Matthieu

  • Hi Matthieu,

    I have come across this error usually when trying to update/access form controls from within an asynchronous method, i.e. from a non-UI thread.

    Please show the exact portion of code that throws the error.

    Best

    Andreas

  • Hi Andreas, 

    I'm a beginner in C# and SDL Trados API development so I am maybe wrong but it seems that this portion throws the error : 

    namespace SDL_Translation_Provider2
    {
    [TranslationProviderWinFormsUi(Id = "Translation_Provider_Plug_inWinFormsUI",
    Name = "Translation_Provider_Plug_inWinFormsUI",
    Description = "Translation_Provider_Plug_inWinFormsUI")]
    class MyTranslationProviderWinFormsUI : ITranslationProviderWinFormsUI
    {
    #region ITranslationProviderWinFormsUI Members

    public ITranslationProvider[] Browse(IWin32Window owner, LanguagePair[] languagePairs, ITranslationProviderCredentialStore credentialStore)
    {
    throw new NotImplementedException();
    }

    public bool Edit(IWin32Window owner, ITranslationProvider translationProvider, LanguagePair[] languagePairs, ITranslationProviderCredentialStore credentialStore)
    {
    throw new NotImplementedException();
    }

    public bool GetCredentialsFromUser(IWin32Window owner, Uri translationProviderUri, string translationProviderState, ITranslationProviderCredentialStore credentialStore)
    {
    throw new NotImplementedException();
    }

    public TranslationProviderDisplayInfo GetDisplayInfo(Uri translationProviderUri, string translationProviderState)
    {
    throw new NotImplementedException();
    }

    public bool SupportsEditing
    {
    get { throw new NotImplementedException(); }
    }

    public bool SupportsTranslationProviderUri(Uri translationProviderUri)
    {
    throw new NotImplementedException();
    }

    public string TypeDescription
    {
    get { throw new NotImplementedException(); }
    }

    public string TypeName
    {
    get { throw new NotImplementedException(); }
    }

    #endregion
    }
    }

  • Hi Matthieu,

    probably not. So far, this portion does basically nothing but throw an error "I have not been implemented yet".

    It is probably some portion with a condition like this:
    "if(abc.getType() == (typeof(xyz))"

    ...or similar.

  • Hi ,

    Can you please take a look at the following code sample for DeepL Translation provider? This a complete  sample on how you can build a Translation Provider.

    Kind regards,

    Andrea Ghisa

  • Hi Andrea-Melinda, 

    I saw this repo yesterday but I have an error while I tried to build the plug in. This is the link of my issue.

    Best, 

    Matthieu