I've never written a white paper before, and well, I want to at some point, so this is the start to a white paper I want to write.  Creating Licensed Web Controls.  I'm getting a few questions on my blog about how to do this, so I'm going to start with some basics, a sample, and I'll build from there.

Sample Licensed Web Control:

  1. Create a new website
  2. Add a new “Class Library” project (File -> Add -> New Project -> C# Class Library) called LicensedControl
  3. Remove the Class1.cs and replace it with the sample file (LicensedControl.cs).  Add references to:
    • System.Design
    • System.Configuration
    • System.Web
  4. In the web project, add a reference to the class library project (right click on the Web Project -> Add Reference -> Projects -> LicensedControl)
  5. The Bin folder should be created, and LicensedControl.DLL and LicensedControl.PDB should be added to the folder
  6. Add the LicensedControl.WebCustomControl.LIC file to the Bin folder
  7. In source view, register the control in the ASPX page
    • <%@ register TagPrefix="LicControl" Namespace="LicensedControl" Assembly="LicensedControl" %>
  8. Add an instance of the control to the page
    • <LicControl:WebCustomControl runat="server" ID="LicControl"/>
  9. Switch to Design View.  A LICENSES.LICX file should have been created in the web root folder, and an APP_LICENSES.DLL built in the Bin folder.  The control should render as shown:
  10. Running this application will run it with the Run-Time license

Additional Notes:

  • You can pre-compile websites and roll them out.  In this case, the APP_LICENSES.DLL is created and placed in the bin folder, but no .LIC files or LICENSES.LICX files are copied over to the pre-compiled web folder.
  • If at any time APP_LICENSES.DLL is not auto-generated, it can be manually generated by right clicking on the LICENSES.LICX and choosing “Build Runtime Licenses”
  • Licensed Custom Controls in the APP_Code folder do not work