Licensing in .NET
By Myk Willis, October 01, 2003
The Microsoft.NET licensing model works well for the kind of redistributable components that developers buy and redistribute as a part of an application. In this article, we'll enable licensing support for a simple redistributable component, and see how Visual Studio .NET automates much of the licensing process for components.
Licensing in .NET
Listing 3 A simple license provider derived from LicFileLicenseProvider
using System;
using System.ComponentModel;
public class DerivedLicenseProvider : LicFileLicenseProvider
{
protected override bool IsKeyValid(string key, System.Type type)
{
return key.Equals( GetValidLicenseKey(type) );
}
protected override string GetKey(System.Type type)
{
return GetValidLicenseKey(type);
}
private string GetValidLicenseKey(Type type)
{
int hashCode = (type.FullName + "Secret").GetHashCode();
return String.Format( "{0}:{1,8:X}", type.FullName, hashCode );
}
}