How do I develop .NET Windows Forms applications that manage conversations?

Last reviewed: 3/4/2013

HOW Article ID: H031305

The information in this article applies to:

  • VoiceXMLKit

Summary

You can develop .NET Windows Forms applications that manage conversations using your favorite .NET Windows Forms development tools. This includes development environments such as Microsoft Visual C# .NET, Microsoft Visual Basic .NET, and Embarcadero Delphi Prism.

More Information

VoiceXMLKit includes Windows Forms 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:

  1. Within your .NET project, right click on the References folder in C# or Open MyProject in VB and select the References tab.
  2. For .NET V4 applications, add references to the VoiceXMLKit .NET assemblies:
    1. Program Files\Chant\VoiceXMLKit\Win32\NET\libv4\Chant.VoiceXMLKit.dll and
    2. Program Files\Chant\VoiceXMLKit\Win32\NET\libv4\Chant.Shared.dll.
  3. For .NET V4.5 applications, add references to the VoiceXMLKit .NET assemblies:
    1. Program Files\Chant\VoiceXMLKit\Win32\NET\libv45\Chant.VoiceXMLKit.dll and
    2. Program Files\Chant\VoiceXMLKit\Win32\NET\libv45\Chant.Shared.dll.
  1. Within your .NET project, right click on the References folder in C# or Open MyProject in VB and select the References tab.
  2. For .NET V4 applications, add references to the VoiceXMLKit .NET assemblies:
    1. Program Files\Chant\VoiceXMLKit\Win64\NET\libv4\Chant.VoiceXMLKit.dll and
    2. Program Files\Chant\VoiceXMLKit\Win64\NET\libv4\Chant.Shared.dll.
  3. For .NET V4.5 applications, add references to the VoiceXMLKit .NET assemblies:
    1. Program Files\Chant\VoiceXMLKit\Win64\NET\libv45\Chant.VoiceXMLKit.dll and
    2. Program Files\Chant\VoiceXMLKit\Win64\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;
    

uses
    Chant.Shared,
    Chant.VoiceXMLKit,
    ...
    

Imports Chant.VoiceXMLKit
Imports Chant.Shared
Class MainWindow
...
    

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

  1. Select the Build tab under project properties.
  2. Select x86 or x64 in the Platform target dropdown list.

Within your Delphi Prism project

  1. Select the Build tab under project properties.
  2. Select x86 or x64 in the Platform target dropdown list.

Within your VB .NET Project

  1. Select the Compile tab under project properties.
  2. Press the Advanced Compile Options... button.
  3. Select x86 or x64 in the Target CPU 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");
}
    

Window1 = public partial class(System.Windows.Window)
private
NChantXM1: NChantXM;

public
constructor;
method NChantXM1_HasEvent(sender: System.Object; e: HasEventArgs);
end;

implementation

constructor Window1;
begin
    InitializeComponent();
    NChantXM1 := new NChantXM();
    NChantXM1.HasEvent += NChantXM1_HasEvent;
    // Set license properties
    NChantXM1.SetStringProperty(ChantStringProperty.CSPLicense,'LicenseRegistrationNumber');
    NChantXM1.SetStringProperty(ChantStringProperty.CSPSerials,'LicenseSerialNumber');
end;
    

Dim WithEvents NChantXM1 As NChantXM

Private Sub Window_Loaded(ByVal sender As System.Object, ByVal e As System.Windows.RoutedEventArgs) Handles MyBase.Loaded
    NChantXM1 = New NChantXM()

    ' Set license properties
    NChantXM1.SetStringProperty(ChantStringProperty.CSPLicense, "LicenseRegistrationNumber")
    NChantXM1.SetStringProperty(ChantStringProperty.CSPSerials, "LicenseSerialNumber")

    ...

End Sub
    

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, 0);
    }
}
    

method Window1.NChantXM1_HasEvent(sender: System.Object; e: HasEventArgs);
var
    i: integer;
    numberOfEvents: integer;
    oChantXMEvent: NChantXMEvent;
begin
    numberOfEvents := NChantXM1.GetResourceCount(ChantSpeechResource.CSREvent,0,0);
    for i := 0 To numberOfEvents - 1 do
    begin
        // Get the event from the event queue
        oChantXMEvent := NChantXM1.GetChantXMEvent(0);
        case oChantXMEvent.ChantCallback of
        ChantCallback.CCXMCompileDone:
        begin
            ...
        end;
        ChantCallback.CCXMCompileError:
        begin
            ...
        end;
        end;
        // Remove the event from the event queue
        NChantXM1.RemoveResource(ChantSpeechResource.CSREvent, 0);
        end;
end;
    

Private Sub NChantXM1_HasEvent(ByVal sender As System.Object, ByVal e As HasEventArgs) Handles NChantXM1.HasEvent
    Dim I As Integer
    Dim numberOfEvents As Integer
    Dim nChantXMEvent As NChantXMEvent
    ' Get the number of events
    numberOfEvents = NChantXM1.GetResourceCount(ChantSpeechResource.CSREvent, 0, 0)
    For I = 0 To numberOfEvents - 1
        ' Get the event from the event queue
        nChantXMEvent = NChantXM1.GetChantXMEvent(0)
        Select Case nChantXMEvent.ChantCallback
            Case ChantCallback.CCXMCompileDone
                ...
            Case ChantCallback.CCXMCompileError
                ...
        End Select
        ' Remove the event from the event queue
        NChantXM1.RemoveResource(ChantSpeechResource.CSREvent, 0)
    Next
End Sub
    

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.
  • 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 NVoiceXMLKitX64.dll to the target system.
  • Register NVoiceXMLKitX64.DLL as a COM library on the target system.

Sample Projects

.NET Windows Forms sample projects are installed at the following location:

  • My Documents\Chant VoiceXMLKit\Win32\NET WinForms\VS 2010\CSharp,
  • My Documents\Chant VoiceXMLKit\Win32\NET WinForms\VS 2010\Visual Basic,
  • My Documents\Chant VoiceXMLKit\Win32\NET WinForms\VS 2012\CSharp, and
  • My Documents\Chant VoiceXMLKit\Win32\NET WinForms\VS 2012\Visual Basic.
  • My Documents\Chant VoiceXMLKit\Win64\NET WinForms\VS 2010\CSharp,
  • My Documents\Chant VoiceXMLKit\Win64\NET WinForms\VS 2010\Visual Basic,
  • My Documents\Chant VoiceXMLKit\Win64\NET WinForms\VS 2012\CSharp, and
  • My Documents\Chant VoiceXMLKit\Win64\NET WinForms\VS 2012\Visual Basic.

For additional help with VoiceXMLKit, contact Chant Support via Chant Support Contacts or web.