# Develop .NET Applications

This section describes how to create and deploy a .NET application by using the KeyView ActiveX Control. Although you can develop .NET applications in many different development environments, the instructions in this section refer to Microsoft Visual Studio 2005.

To create and deploy a .NET application

1. Install the KeyView Viewing SDK.

   The installation automatically registers the Viewing ActiveX control, "KeyView OLE Control module (v1.0)" and installs the COM dynamic library (`kvocx.ocx`) to the Viewing `\bin` directory. You can also use the `regsvr32` command to register the ActiveX COM module. For example:

       regsvr32.exe install\bin\kvocx.ocx

2. In Visual Studio 2005, select Tools from the main menu, and click Choose Toolbox Items….

3. In the Choose Toolbox Items dialog box, click the COM Components tab.

4. From the list of available COM components, select the KeyView Control check box, and then click OK.

   A Windows control named KeyView Control appears in the Toolbox. You can use this KeyView control in the same way as other controls in the Toolbox.

When the .NET application is built, Visual Studio creates the following dynamic libraries:

- `Interop.KEYVIEWLib.dll`
- `AxInterop.KEYVIEWLib.dll`

These libraries are wrappers for the KeyView ActiveX control, and are required to use the control in a .NET environment.

## Method and Property Naming Conventions

The .NET control class name for KeyView ActiveX control is `AxKEYVIEWLib.AxKEYview`, where the namespace `AxKEYVIEWLib` is the library name.

In J#, C#, and C++, all ActiveX control method names in the .NET class are the same as their COM counterparts. However, individual properties in .NET are defined using get and set methods of the following format:

    get_property_name

    set_property name

For example, `RegIniName` in COM has `get_RegIniName` and `set_RegIniName` methods in the .NET class.

IMPORTANT: In a Visual Basic .NET application, all properties and methods are used in the same way as in a Visual Basic COM application.

### Sample Code

The following code demonstrates how to use the .NET class in a J# Windows Form program:

    private void button1_Click(Object sender, System.EventArgs e)
    {
        this.axKEYview1.set_RegIniMode((short)1);
        this.axKEYview1.set_RegIniName("c:\windows\kvsdk.ini");
        this.axKEYview1.Open("c:\test.doc");
    }

The following code demonstrates how to use the .NET class in a Visual Basic Windows Form program:

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        AxKEYview1.RegIniMode = 1
        AxKEYview1.RegIniName = "c:\windows\kvsdk.ini"
        AxKEYview1.Open("c:\test.doc")
    End Sub

## Deploy .NET Applications

After you have built a .NET application using Viewing ActiveX control, follow these steps to deploy the application:

1. Install all required files to the `\bin` directory of your application's installation directory. List of Files Required for Redistribution lists the components that must be redistributed with your application. It also shows the Dynamic Link Library (DLL) associated with each component.

2. Review the `kvsdk.ini` file or the `install.reg.txt` file to make sure that the appropriate files are referenced.

3. Update the `HOME` entry in the initialization file or registry file with the complete path to where you are installing Viewing components.

4. Specify whether you are using an initialization file or registry settings. See View Initialization Information.

5. If you are using an initialization file, install the file to the location specified by `RegIniName` when the application is installed. See RegIniName.

6. If you are using the registry file, import the `install.reg` file into the Windows Registry when the application is installed.

7. Install the Viewing ActiveX control (`kvocx.ocx`) to the `\bin` directory of your application's installation directory. Register the control in the system registry by running the following command:

       regsvr32 C:\MyApp\bin\kvocx.ocx

   Add `-s` to suppress any dialog boxes when registering the OCX.

8. Install the wrapper files `Interop.KEYVIEWLib.dll` and `AxInterop.KEYVIEWLib.dll` to the `\bin` directory of your application's installation directory.

9. Install the Microsoft .NET Framework Version 2.0 Redistributable Package, which is available at

   http://msdn.microsoft.com/netframework/downloads/updates/default.aspx.

10. If the application is developed using J#, install the Microsoft Visual J# .NET Version 2.0 Redistributable Package, which is available at

    http://msdn.microsoft.com/netframework/downloads/updates/default.aspx.

_FT_HTML5_bannerTitle.htm