Welcome Guest!
Create Account | Login
Locator+ Code:

Search:
FTPOnline Channels Conferences Resources Hot Topics Partner Sites Magazines About FTP RSS 2.0 Feed

Free Trial Issue of Visual Studio Magazine

email article
printer friendly
get the code
more resources

Implement .NET Component Licensing
Prevent unauthorized use of your WinForms components by other developers.
by Fabio Claudio Ferracchiati

March 2003 Issue

Technology Toolbox: C#

Third-party components can give Windows applications a wide range of functionality, such as report design and viewing, charts, and spreadsheets. If you've developed third-party components with Visual Basic, you're probably familiar with the licensing issues they involve. Other developers who install an application that uses your VB component can then use the component in their projects by selecting the VBX, OCX, or DLL file from the Components menu and adding it to the component toolbox. The solution to unauthorized component use has been for the VB component developer to include a file (usually an LIC file) containing licensing information that must be present in the same directory as the component. Anyone who tries to use a component without a valid license file can't insert the component in a project or receives an unregistered error message from the control during application run time. The license file is necessary only at design time.

Figure 1. Add Licensing to a Component.

The .NET Framework's component-licensing features are also based on a license file. You employ licensing classes the Framework provides in your components to manage the license file automatically—to specify which file the license file is, check its validity, read its contents, and much more. I'll show you how to add licensing features to your .NET components. You'll start by working with the LicFileLicenseProvider class, which lets you implement a license for your component easily; then you'll progress to more advanced licensing mechanisms.

A simple licensing solution uses the prebuilt LicFileLicenseProvider class in your component to raise an exception if the user's development platform doesn't find a valid license file. As an exercise, add a license to the FolderBrowser component (download the source code here). This component is useful for displaying the Browse For Folder system dialog box (see Figure 1). Details of how the control works are out of this article's scope; all you need to know is that it uses Platform Invocation Services to call the SHBrowseForFolder Windows API within the Shell32.dll library. You can display and retrieve information from the system dialog box passing a prefilled structure to this function.

Back to top














Java Pro | Visual Studio Magazine | Windows Server System Magazine
.NET Magazine | Enterprise Architect | XML & Web Services Magazine
VSLive! | Thunder Lizard Events | Discussions | Newsletters | FTP Home