Click here to Skip to main content
15,888,454 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi Dear Friends,

I am using Microsoft agent to create user interfaces that display characters, but when i run it give me the following exception.
Exception of type 'System.Windows.Forms.AxHost+InvalidActiveXStateException' was thrown.

activeXagent.Characters.Load("Genie", (object)"D:\\WINDOWS\\msagent\\chars\\Genie.acs"); // THIS PART I AM GETTING EXCEPTION.

COMPLETE CODE:
C#
using AgentObjects;
namespace speechRecognizerTest1
{
    public partial class Form1 : Form
    {
        private AxAgentObjects.AxAgent activeXagent = new AxAgentObjects.AxAgent();
        private IAgentCtlCharacterEx Character;
        
        public Form1()
        {
            InitializeComponent();
            
        }
        protected void AxAgent_Command(object sender, AxAgentObjects._AgentEvents_CommandEvent e)
        {
            IAgentCtlUserInput ui;
            ui = (IAgentCtlUserInput)e.userInput;
            if (ui.Name == "Hello")
            {
                Character.Speak((object)"Hello. My name is Robby." +
                  " Pleased to meet you.", null);
                }
            if (ui.Name == "Goodbye")
            {
                Character.Speak((object)"It was nice talking to" +
                  " you. Goodbye.", null);

                Character.Play("Wave");
                Character.Play("Hide");
            }
        }
        private void button1_Click(object sender, EventArgs e)
        {

            activeXagent.Characters.Load("Genie", (object)"D:\\WINDOWS\\msagent\\chars\\Genie.acs"); // THIS PART I AM GETTING EXCEPTION
              Character = activeXagent.Characters["Genie"];
            
              Character.LanguageID = 0x409;
              Character.Show(null);
              Character.Speak ("Welcome you sir VISIT www.onlinecsharpteach.netfirms.com", null);
              button1.Enabled = false;
              Character.Commands.Caption="helloword";
              Character.Commands.Add("Hello",
             (object)"Say Hello",  

             (object)"([say](hello | hi) | good (day | morning | evening))", 

             (object)true,  
             (object)true);

        }
    }
}

I used this link tutorial:
Creating Cool Agent User Interfaces[^]
Any help :Thank u
Posted
Updated 12-Feb-11 19:31pm
v3
Comments
TweakBird 12-Feb-11 5:58am    
Please Use <pre> tag for code blocks.

private AxAgentObjects.AxAgent activeXagent = new AxAgentObjects.AxAgent();

in the intialization part i add the this.controls.add(control value)

C#
public Form1()
       {
           InitializeComponent();
           this.Controls.Add(activeXagent);
       }
 
Share this answer
 
Try posting this in the forum under that article, and the author may be able to help you.

The most likely cause of this problem is that the ActiveX control has not been properly created/initialized yet.
 
Share this answer
 
VB
Abdullahomaid477

Thanks Abdulla , It worked like magic on my 64 bit Windows 2008 RC2 system
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900