none
Error CS0246: The type or namespace name 'AVSpeechSynthesizer' could not be found RRS feed

  • Question

  • Hello.

    I am writing a new iOS application using Visual Studio Community. New project / iOS / Application.

    This application needs to "speak". I have written

    var speechSynthesizer = new AVSpeechSynthesizer();

    However I get an error CS0246. 

    I have tried to add a using statement :

    using Xamarin.iOS;

    But this generates also an error : Error CS0246: The type or namespace name 'Xamarin' could not be found.

    On the left side of the screen, the References entry lists System, System.Core, System.Xml and Xamarin.iOS.

    What have I to do, and how ?

    Regards,

    Gilbert

    using System;
    using UIKit;
    using Xamarin.iOS;
    
    namespace SpeechSynthesizer
    {
        public partial class ViewController : UIViewController
        {
            protected ViewController(IntPtr handle) : base(handle)
            {
                // Note: this .ctor should not contain any initialization logic.
            }
    
            public override void ViewDidLoad()
            {
                base.ViewDidLoad();
                // Perform any additional setup after loading the view, typically from a nib.
    
                BtnParler.TouchUpInside += (object sender, EventArgs e) =>
                {
                    BtnParlerTouchUpInside();
                };
            }
    
            public override void DidReceiveMemoryWarning()
            {
                base.DidReceiveMemoryWarning();
                // Release any cached data, images, etc that aren't in use.
            }
    
            private void BtnParlerTouchUpInside()
            {
                /* var okAlertController
                    = UIAlertController.Create("Message"
                                               , "Le bouton Parler a été activé"
                                                   , UIAlertControllerStyle.Alert);
                okAlertController.AddAction(UIAlertAction.Create("OK", UIAlertActionStyle.Default, null));
                PresentViewController(okAlertController, true, null);*/
    
    
                var speechSynthesizer = new AVSpeechSynthesizer();
                var speechUtterance =
                  new AVSpeechUtterance("Shall we play a game?");
                speechSynthesizer.SpeakUtterance(speechUtterance);
            }
        }
    }


    Gilbert Tordeur

    Friday, March 16, 2018 6:52 PM

Answers

All replies

  • Maybe, you have a yellow exclamation sign on a project reference in References in Visual Studio  for the project, which means you don't  have a reference.
    Friday, March 16, 2018 9:29 PM
  • Solved ! I need to insert the following statement :

    using Foundation;
    Regards,

    Gilbert


    Gilbert Tordeur

    Friday, March 16, 2018 10:37 PM