locked
Using Bing Translator's SOAP API in a WPF application throws Exception RRS feed

  • Question

  • I am making a WPF application with two text boxes and one button. One text box for the original text and the other text box for the translated text.

    I've completed the "Add Service Reference" pointing to address  http://api.microsofttranslator.com/V2/Soap.svc and named the Namespace property to TranslatorService as mentioned here - http://msdn.microsoft.com/en-us/library/ff512435.aspx.

    My code in the button click event (Visual Studio 2010) is:

    	    string textToTranslate = textBox1.Text;
                string sourceLanguage = "en";
                string targetLanguage = "de";
                string translatedText = "";
     
                try
                    {
                        TranslatorService.LanguageServiceClient client = new TranslatorService.LanguageServiceClient();
                        translatedText = client.Translate("MY-APP-ID", textToTranslate, sourceLanguage, targetLanguage);
                        textBox2.Text= translatedText;
                    }
                catch (Exception ex)
                    {
                        MessageBox.Show(ex.ToString(), "Error");
                    }

    I also have an Application ID (status: enabled) that replaces "MY-APP-ID" in the code above. But, I get this error on debugging the application:

    Runtime Exception

    How do I go about it? I'm am a beginner when it comes to development (this is my first application). So I would be glad if you could explain me the problem and the solution in simple words. Thanks in advance! :)


    Kunal D Mehta - a Windows Server Enthusiast | I'm on facebook.com/serverbaba



    • Changed type Server Baba Wednesday, February 8, 2012 11:06 AM By mistake I set it to discussion, sorry.
    • Edited by Server Baba Wednesday, February 8, 2012 11:12 AM
    Wednesday, February 8, 2012 11:03 AM

All replies

  • Take a look at you app.config (or *.config) file for duplicated entries for "TranslatorService.LanguageService". Try to clean it up a recompile.

    Monday, February 20, 2012 8:48 PM