Nevron Open Vision Documentation
Hosting NOV in Silverlight
The hosting of NOV in your application is by default performed by NOV project templates. If you are using project templates you can skip this documentation topic.

1. Create a new Silverlight project in Visual Studio

You need to target Silverlight 5.
This step is not mandatory, because you can integrate NOV in an already existing Silverlight project. It is performed just for the purpose of making a complete installation scenario.

2. Reference the NOV Assemblies

Ensure that your application references the following NOV dlls:

3. Initialize the NOV Application

Open the App.xaml.cs file and ensure that it it has the following code:

Installing NOV for Silverlight
Copy Code
using System;
using System.Windows;
using Nevron.Nov.Windows;
using Nevron.Nov;
namespace SilverlightApplication1
{
 public partial class App : Application
 {
  public App()
  {
   this.Startup += this.Application_Startup;
   this.Exit += this.Application_Exit;
   this.UnhandledException += this.Application_UnhandledException;
   InitializeComponent();
  }
  private void Application_Startup(object sender, StartupEventArgs e)
  {
   // Apply license to the application here. 
   NLicenseManager.Instance.SetLicense(new NLicense("LICENSE KEY"));

   NModule[] modules = new NModule[] { 
      // TODO: Create modules here
   };

   // install Nevron Open Vision for Silverlight
   NNovApplicationInstaller.Install(modules);
   // the installation of Nevron Open Vision for Silverlight,
   // replaces the RootVisual of the application, so you need
   // to place your default main page as content of the user layer
   NSLDesktop.Instance.UserLayer.Content = new MainPage();
  }
  private void Application_Exit(object sender, EventArgs e)
  {
  }
  private void Application_UnhandledException(object sender, ApplicationUnhandledExceptionEventArgs e)
  {
   // If the app is running outside of the debugger then report the exception using
   // the browser's exception mechanism. On IE this will display it a yellow alert
   // icon in the status bar and Firefox will display a script error.
   if (!System.Diagnostics.Debugger.IsAttached)
   {
    // NOTE: This will allow the application to continue running after an exception has been thrown
    // but not handled.
    // For production applications this error handling should be replaced with something that will
    // report the error to the website and stop the application.
    e.Handled = true;
    Deployment.Current.Dispatcher.BeginInvoke(delegate { ReportErrorToDOM(e); });
   }
  }
  private void ReportErrorToDOM(ApplicationUnhandledExceptionEventArgs e)
  {
   try
   {
    string errorMsg = e.ExceptionObject.Message + e.ExceptionObject.StackTrace;
    errorMsg = errorMsg.Replace('"', '\'').Replace("\r\n", @"\n");
    System.Windows.Browser.HtmlPage.Window.Eval("throw new Error(\"Unhandled Error in Silverlight Application " + errorMsg + "\");");
   }
   catch (Exception)
   {
   }
  }
 }
}
The important code here is in the Application_Startup event handler. It calls the Install method of the NOV Silverlight application installer. NOV for Silverlight requires to have control over the RootVisual of your Silverlight application, to implement a custom windowing system, that very much resembles Microsoft Windows. That is why the installation sets the RootVisual of the application to be the NSLDesktop.Instance Silverlight element. The NSLDesktop is having a UserControl that is intended to host any Silverlight content - in this example we place the MainPage as content of this user control, but it can be any other Silverlight content.
The installation will automatically generate an evaluation license key, which you can obtain from the Silverlight examples shipped with NOV or from the License Key manager.
See Hosting NOV in your Application for more information about modules.

4. Say Hello from NOV

Open the MainWindow.xaml.cs file and replace its content with the following code:

Example Title
Copy Code
using System.Windows.Controls;
using Nevron.Nov.UI;
using Nevron.Nov.Windows;
namespace SilverlightApplication1
{
    public partial class MainPage : UserControl
    {
        public MainPage()
        {
            InitializeComponent();
            // Add a NOV widget inside the form
            NLabel sayHelloWorld = new NLabel("Hello World from Nevron Open Vision");
            Content = new NNovWidgetHost<NLabel>(sayHelloWorld);
        }
    }
}

Run the application - it should display a simple form with a "Hello World from Nevron Open Vision" label inside.

This is as much as is required to host some NOV content in Silverlight. From now on you can forget everything you know about Silverlight, since you will not need it when developing with NOV.

The sample just makes a simple label, as content of the NNovWidgetHost Silverlight Control, but this control actually contain any NOV widget. See the UI Overview topic for an overview of the User Interface that comes along with NOV.

Send Feedback