Creating Licensed Web Controls
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:
- Create a new website
- Add a new “Class Library” project (File -> Add -> New Project -> C# Class Library) called LicensedControl
- Remove the Class1.cs and replace it with the sample file ( LicensedControl.cs ). Add references to:
- System.Design
- System.Configuration
- System.Web
- In the web project, add a reference to the class library project (right click on the Web Project -> Add Reference -> Projects -> LicensedControl)
- The Bin folder should be created, and LicensedControl.DLL and LicensedControl.PDB should be added to the folder
- Add the LicensedControl.WebCustomControl.LIC file to the Bin folder
- In source view, register the control in the ASPX page
- <%@ register TagPrefix="LicControl" Namespace="LicensedControl" Assembly="LicensedControl" %>
- Add an instance of the control to the page
- <LicControl:WebCustomControl runat="server" ID="LicControl"/>
- 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:
- 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