How Tos
Last reviewed: 3/4/2013
Article ID: H031306
HOW: Developing .NET WPF applications that manage conversations
The information in this article applies to:
- VoiceXMLKit
Summary
You can develop .NET WPF applications that manage conversations using your favorite .NET WPF development tools. This includes development environments such as Microsoft Visual C# .NET, Microsoft Visual Basic .NET, and Embarcadero Delphi Prism.
More Information
VoiceXMLKit includes WPF compatible .NET assemblies compiled with .NET Framework V4 and V4.5 to support your application's target framework.
To access the VoiceXMLKit .NET classes within your application, add them to your project References:
- Within your .NET project, right click on the References folder in C# or Open MyProject in VB and select the References tab.
-
For .NET V4 applications, add references to the VoiceXMLKit .NET assemblies:
- Program Files\Chant\VoiceXMLKit\Win32\NET\libv4\Chant.VoiceXMLKit.dll and
- Program Files\Chant\VoiceXMLKit\Win32\NET\libv4\Chant.Shared.dll.
-
For .NET V4.5 applications, add references to the VoiceXMLKit .NET assemblies:
- Program Files\Chant\VoiceXMLKit\Win32\NET\libv45\Chant.VoiceXMLKit.dll and
- Program Files\Chant\VoiceXMLKit\Win32\NET\libv45\Chant.Shared.dll.
To access the VoiceXMLKit .NET classes within your application, add references to the VoiceXMLKit assemblies in your code:
using System; ... using Chant.VoiceXMLKit; using Chant.Shared;
Platform Target
Set the project Platform target to either x86 for 32-bit application or x64 for 64-bit application as follows:
Within your C# project
- Select the Build tab under project properties.
- Select x86 or x64 in the Platform target dropdown list.
Object Instantiation
Declare a global variable for the ChantXM class, instantiate an instance, add the event handler, and set the license and serial properties.
private Chant.VoiceXMLKit.NChantXM NChantXM1; public MainWindow() { InitializeComponent(); // Instantiate NChantXM object NChantXM1 = new NChantXM(); // Setup event callback handler NChantXM1.HasEvent += this.NChantXM1_HasEvent; // Set license properties NChantXM1.SetStringProperty(ChantStringProperty.CSPLicense, "LicenseRegistrationNumber"); NChantXM1.SetStringProperty(ChantStringProperty.CSPSerials, "LicenseSerialNumber"); }
Event Callbacks
Event callbacks are the mechanism in which the component library communications information back to the application such as compilation is complete or there was an error.
private void NChantXM1_HasEvent(object sender, HasEventArgs e) { // Get the number of events int numberOfEvents = NChantXM1.GetResourceCount(ChantSpeechResource.CSREvent, 0, 0); for (int i = 0; i < numberOfEvents; i++) { // Get the event from the event queue NChantXMEvent nChantXMEvent = NChantXM1.GetChantXMEvent(0); switch (nChantXMEvent.ChantCallback) { case ChantCallback.CCXMCompileDone: { ... break; } case ChantCallback.CCXMCompileError: { ... break; } default: break; } // Remove the event from the event queue NChantXM1.RemoveResource(ChantSpeechResource.CSREvent, 0); } }
Deployment Checklist
When you are ready to deploy your application, you need to ensure you have a valid license, bundle the correct Chant component libraries, and configure your installation properly on the target system.
Review the following checklist before deploying your applications:
- You may deploy your .NET application to any system with a valid license from the Chant.
- Copy Chant.VoiceXMLKit.dll and Chant.Shared.dll assemblies to the target system or merge them with your application using an obfuscator like .NET Reactor by Eziriz.
- Copy NVoiceXMLKit.dll to the target system.
- Register NVoiceXMLKit.dll as a COM library on the target system.
Sample Projects
.NET WPF sample projects are installed at the following location:
- My Documents\Chant VoiceXMLKit\Win32\NET WPF\VS 2010\CSharp,
- My Documents\Chant VoiceXMLKit\Win32\NET WPF\VS 2010\Visual Basic,
- My Documents\Chant VoiceXMLKit\Win32\NET WPF\VS 2012\CSharp, and
- My Documents\Chant VoiceXMLKit\Win32\NET WPF\VS 2012\Visual Basic.
For additional help with VoiceXMLKit, contact Chant Support via or web.