Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

MSAgent Help

Status
Not open for further replies.

rbri

Programmer
Jun 27, 2002
84
US
Hello Everyone,

I am trying to use msagent in an application. I have all think I have all the msagent stuff installed at least it works with VBScript. I found a web site telling how to make it work in C# but when I do what it says and code it the way it says it does not work. Here is what the web article says to do.

At a command prompt type:
aximp %systemroot%\msagent\agentctl.dll
The article says it creates two dll's AxAgentObjects.dll &
AgentObjects.dll and it does, it put those two files in C:\winnt\msagent. Then in the code it says to code "using AgentObjects;" place this code in the section with using system; but when I compile the code it says:
The type namespace name AgentObjects could not be found.

I must have missed something in the article because I can't seem to get it to work. I downloaded there code and it runs fine, but if I paste there code into my program or code my own I still get the same error here is the url of the article.


Thanks for any help I can get.
Randy
 
Did you set a reference to the MSAgent COM library?

Right-click on "references" in your project view, and click "Add Reference". Go to the COM tab, and if it isn't already in the list, you'll have to browse for it.

Chip H.
 
By referencing the 2 dll files did remove the above error, but with my luck brought me a new error. Here is the code I downloaded from the the web I am trying to get it to compile
and here is where I get the new error. The error is:
The type or namespace name can not be found. Character

I thought that it could not find the msagent merlin.acs
so I put the entire path in I get different errors. I thought possiblely that Character needed to be initialized as a string but no that's not it either. So I am not sure what Character is. Is it something I define or is it an object of msagent? I am lost again. Thank you for your help

Randy

Here is the code:

// project created on 3/25/2003 at 12:47 PM
namespace Techinox.AgentHelloWorld
{

using System;
using System.Drawing;
using System.Windows.Forms;
using AgentObjects;

public class AgentHelloWorldForm : Form
{
private TextBox TextToSpeak;
private Button SpeakButton;
private Label StatusLabel;
private AxAgentObjects.AxAgent AxAgent;
private Button ShowButton;

// private IAgentCtlCharacterEx Character;

public AgentHelloWorldForm()
{
InitializeComponent();
}

[STAThread]
public static void Main(string[] args)
{
Application.Run(new AgentHelloWorldForm());
}

private void InitializeComponent()
{
this.SpeakButton = new Button();
this.TextToSpeak = new TextBox();
this.StatusLabel = new Label();
this.AxAgent = new AxAgentObjects.AxAgent();
this.ShowButton = new Button();

AxAgent.BeginInit();

SpeakButton.Location = new System.Drawing.Point(192, 48);
SpeakButton.Size = new System.Drawing.Size(88, 24);
SpeakButton.TabIndex = 3;
SpeakButton.Enabled = false;
SpeakButton.Text = "Speak";
SpeakButton.Click += new System.EventHandler(SpeakButton_Click);

TextToSpeak.Location = new System.Drawing.Point(8, 48);
TextToSpeak.Text = "Enter some text to be spoken.";
TextToSpeak.Enabled = false;
TextToSpeak.TabIndex = 4;
TextToSpeak.Size = new System.Drawing.Size(176, 20);

StatusLabel.Location = new System.Drawing.Point(8, 8);
StatusLabel.Text = "Click the Show Merlin button to display Merlin.";
StatusLabel.Size = new System.Drawing.Size(176, 32);
StatusLabel.TabIndex = 2;

AxAgent.Size = new System.Drawing.Size(32, 32);
AxAgent.TabIndex = 1;
AxAgent.Location = new System.Drawing.Point(8, 8);

ShowButton.Location = new System.Drawing.Point(192, 8);
ShowButton.Size = new System.Drawing.Size(88, 24);
ShowButton.TabIndex = 0;
ShowButton.Text = "Show Merlin";
ShowButton.Click += new System.EventHandler(ShowButton_Click);

this.Text = "Agent HelloWorld";
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(288, 77);
this.FormBorderStyle = FormBorderStyle.FixedDialog;
this.MaximizeBox = false;
this.AcceptButton = ShowButton;

this.Controls.Add(TextToSpeak);
this.Controls.Add(SpeakButton);
this.Controls.Add(StatusLabel);
this.Controls.Add(AxAgent);
this.Controls.Add(ShowButton);

AxAgent.EndInit();
}

protected void SpeakButton_Click(object sender, System.EventArgs e)
{
if(TextToSpeak.Text.Length == 0) // Don't speak a zero-length
return; // string.

//The word Character locatered between this line***********

//Make the character speak.
Character.Speak(TextToSpeak.Text, null);
}
protected void ShowButton_Click(object sender, System.EventArgs e)
{
// Load the Merlin character.
AxAgent.Characters.Load("Merlin", "MERLIN.ACS");
Character = AxAgent.Characters["Merlin"];
StatusLabel.Text = Character.Name + " loaded.";
// Set the language to US English.
Character.LanguageID = 0x409;

// Display the character.
Character.Show(null);

// And this line*******************************************


ShowButton.Enabled = false;
SpeakButton.Enabled = true;
TextToSpeak.Enabled = true;

this.AcceptButton = SpeakButton;
}

}
}
 
I haven't done anything with the MSAgent stuff in .NET (but I did play with it about 3 years ago in VB6).

What it looks like the compiler is complaining about is you've got a Character variable, but it wasn't declared as being of any particular type. You do have a declaration in the class, but you've got it commented out:
Code:
//    private IAgentCtlCharacterEx Character;
I would guess that "IAgentCtlCharacterEx" is an interface provided with the MSAgent library.

Further on, when you're retrieving the character:
Code:
Character = AxAgent.Characters["Merlin"];
Check the online help to see what datatype the Characters array returns. I suspect it's of type "IAgentCtlCharacterEx", so you need to have a variable of that type.

Chip H.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top