How do I develop Silverlight applications that manage profiles?
Last reviewed: 1/14/2012
HOW Article ID: H071123
The information in this article applies to:
- ProfileKit 4
Summary
You can develop Silverlight applications that manage speaker profiles using your favorite Silverlight development tools such as Microsoft Visual csharp .NET and Microsoft Visual Basic .NET.
More Information
To access the ProfileKit Silverlight classes within your application, add them to your project References:
- Within your Silverlight project, right click on the References folder in csharp or Open MyProject in VB and select the References tab.
-
For Silverlight V4 applications, add references to the ProfileKit Silverlight assemblies:
- Program Files\Chant\ProfileKit 4\Win32\Silverlight\libv4\Chant.ProfileKit.Silverlight.dll and
- Program Files\Chant\ProfileKit 4\Win32\Silverlight\libv4\Chant.Shared.Silverlight.dll.
-
For Silverlight V5 applications, add references to the ProfileKit Silverlight assemblies:
- Program Files\Chant\ProfileKit 4\Win32\Silverlight\libv5\Chant.ProfileKit.Silverlight.dll and
- Program Files\Chant\ProfileKit 4\Win32\Silverlight\libv5\Chant.Shared.Silverlight.dll.
- Within your Silverlight project, right click on the References folder in csharp or Open MyProject in VB and select the References tab.
-
For Silverlight V5 applications, add references to the ProfileKit Silverlight assemblies:
- Program Files\Chant\ProfileKit 4\Win64\Silverlight\libv5\Chant.ProfileKit.Silverlight.dll and
- Program Files\Chant\ProfileKit 4\Win64\Silverlight\libv5\Chant.Shared.Silverlight.dll.
To access the ProfileKit Silverlight classes within your application, add references to the ProfileKit assemblies in your code:
using System;
...
using Chant.ProfileKit.Silverlight;
using Chant.Shared.Silverlight;
Imports Chant.ProfileKit.Silverlight
Imports Chant.Shared.Silverlight
Class MainWindow
...
Out-of-Browser Settings
To run your Silverlight app out-of-browser, set the properties as follows:
- Within your Silverlight project, select the Silverlight tab under project properties.
- Select the checkbox: Enable application running out of the browser.
- Deselect the checkbox: Require elevated trust when running in-browser.
- Press the Out-of-Browser Settings... button.
- Select the checkbox: Required elevated trust when running outside the browser.
In-Browser Settings
To run your Silverlight app in-browser, set the properties as follows:
- Within your Silverlight project, select the Silverlight tab under project properties.
- Select the checkbox: Require elevated trust when running in-browser.
- Deselect the checkbox: Enable application running out of the browser.
- Select the Signing tab under project properties.
- Select the checkbox: Sign the Xap File.
-
Press one of the three buttons to select a signing certificate:
- Select from Store... if you have installed a signing certificate on your system;
- Select from File... if you have a signing certificate file your system; or
- Create test certificate... if you do not have signing certificate on your system.
-
Press the More Details... button to ensure you have installed Trusted Root and Publisher certificiates:
- Press the Install Certificate... button;
- Select Automatically ... option if you have Certificate installed in your store or Select Place ... option if you created a temp certificate for testing and press the Browse button;
- Select Trusted Root Certification Authorities and press the OK button; and
- Press the Next button.
- Repeat the process by Pressing the Install Certificate... button;
- Select Place ... option and press the Browse button;
- Select Trusted Publishers and press the OK button; and
- Press the Next button.
-
Run regedit to add a Silverlight registery property AllowElevatedTrustAppsInBrowser with value of 1:
- Select the Start menu and enter regedit to launch the Registry Editor;
- For Win32 systems, navigate to HKEY_LOCAL_MACHINE\Software\Microsoft\Silverlight\;
- For Win64 systems, navigate to HKEY_LOCAL_MACHINE\Software\Wow6432Node\Microsoft\Silverlight\;
- Right click and select New->DWORD (32-bit) Value;
- Set the value name to AllowElevatedTrustAppsInBrowser;
- Set th value data to 1;
- Press the OK button; and
- Close the Registry Editor.
Object Instantiation
Declare a global variable for the ChantPM class, instantiate an instance, add the event handler, and set the license and serial properties.
private Chant.ProfileKit.Silverlight.NChantPM NChantPM1;
public MainPage()
{
InitializeComponent();
// Instantiate NChantPM object
NChantPM1 = new NChantPM(this);
// Setup event callback handler
NChantPM1.HasEvent += new Chant.ProfileKit.Silverlight.NChantPM.HasEventHandler(this.NChantPM1_HasEvent);
// Set license properties
NChantPM1.SetStringProperty(ChantStringProperty.CSPLicense, "LicenseRegistrationNumber");
NChantPM1.SetStringProperty(ChantStringProperty.CSPSerials, "LicenseSerialNumber");
}
Dim WithEvents NChantPM1 As NChantPM
Private Sub UserControl_Loaded(ByVal sender As System.Object, ByVal e As System.Windows.RoutedEventArgs) Handles MyBase.Loaded
NChantPM1 = New NChantPM(Me)
' Set license properties
NChantPM1.SetStringProperty(ChantStringProperty.CSPLicense, "LicenseRegistrationNumber")
NChantPM1.SetStringProperty(ChantStringProperty.CSPSerials, "LicenseSerialNumber")
...
End Sub
Event Callbacks
Event callbacks are the mechanism in which the component library sends information back to the application such as import/export operation state, training state, or there was an error.
private void NChantPM1_HasEvent(object sender, HasEventArgs e)
{
// Get the number of events
int numberOfEvents = NChantPM1.GetResourceCount(ChantSpeechResource.CSREvent, 0, 0);
for (int i = 0; i < numberOfEvents; i++)
{
// Get the event from the event queue
NChantPMEvent nChantPMEvent = NChantPM1.GetChantPMEvent(0);
switch (nChantPMEvent.ChantCallback)
{
case ChantCallback.CCSRProgress:
{
...
break;
}
default:
break;
}
// Remove the event from the event queue
NChantPM1.RemoveResource(ChantSpeechResource.CSREvent, 0, 0, "");
}
}
Private Sub NChantPM1_HasEvent(ByVal sender As System.Object, ByVal e As HasEventArgs) Handles NChantPM1.HasEvent
Dim I As Integer
Dim numberOfEvents As Integer
Dim nChantPMEvent As NChantPMEvent
' Get the number of events
numberOfEvents = NChantPM1.GetResourceCount(ChantSpeechResource.CSREvent, 0, 0)
For I = 0 To numberOfEvents - 1
' Get the event from the event queue
nChantPMEvent = NChantPM1.GetChantPMEvent(0)
Select Case nChantPMEvent.ChantCallback
Case ChantCallback.CCSRProgress
...
End Select
' Remove the event from the event queue
NChantPM1.RemoveResource(ChantSpeechResource.CSREvent, 0, 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 Silverlight application to any system with a valid license from the Chant.
- Copy Chant.ProfileKit.Silverlight.dll and Chant.Shared.Silverlight.dll libraries to the target system or merge them with your application using an obfuscator like .NET Reactor by Eziriz.
- Copy NProfileKit.dll to the target system.
- Register NProfileKit.dll as a COM library on the target system.
- You may deploy your Silverlight application to any system with a valid license from the Chant.
- Copy Chant.ProfileKit.Silverlight.dll and Chant.Shared.Silverlight.dll libraries to the target system or merge them with your application using an obfuscator like .NET Reactor by Eziriz.
- Copy NProfileKitX64.dll to the target system.
- Register NProfileKitX64.dll as a COM library on the target system.
Sample Projects
Silverlight sample projects are installed at the following location:
- My Documents\Chant ProfileKit 4\Win32\Silveright\VS 2010\CSharp and
- My Documents\Chant ProfileKit 4\Win32\Silveright\VS 2010\Visual Basic.
- My Documents\Chant ProfileKit 4\Win64\Silveright\VS 2010\CSharp and
- My Documents\Chant ProfileKit 4\Win64\Silveright\VS 2010\Visual Basic.