FIX: Cannot Dynamically Add a Non-Licensed MFC Control (193025)
The information in this article applies to:
- Microsoft Visual Basic Learning Edition for Windows 6.0
- Microsoft Visual Basic Professional Edition for Windows 6.0
- Microsoft Visual Basic Enterprise Edition for Windows 6.0
This article was previously published under Q193025 SYMPTOMS
When attempting to dynamically add an MFC ActiveX control to a Visual Basic
project, you may receive the following error message in the compiled
project:
Run-time error '747':
No design-time license information is found for control 'XX.YY'. Contact
the vendor for control 'XX.YY' to obtain a design-time license.
The error occurs even though the control does not require a license.
CAUSE
When adding a new control to a Form or UserControl dynamically at run-time,
Visual Basic queries the control for the IClassFactory2 interface. This
interface is generally used by controls that require licensing. If the
control supports this interface, Visual Basic will then attempt to create
an instance of the control using the IClassFactory2::CreateInstanceLic
method, passing the developer-provided license string as a parameter. If no
license is required, an empty string is passed.
By default, all MFC ActiveX controls support the IClassFactory2 interface,
even if the control does not require a design-time license. When Visual
Basic makes the call to CreateInstanceLic, passing an empty string for the
license, MFC returns the error CLASS_E_NOTLICENSED, indicating that the
string passed is not a valid license key for this control. Visual Basic
reports the error as an invalid or missing design-time license.
RESOLUTION
There are currently two workarounds for this problem:
- If you add the MFC control to the Visual Basic IDE toolbox at
design-time, and then uncheck the "Remove information about unused
ActiveX controls" option on the Make tab of the Project|Properties
dialog, Visual Basic will compile the licensing information of the
control into your project. At run-time, Visual Basic will know that the
control does not require a license, and therefore will call
CreateInstance rather than CreateInstanceLic. This will avoid the error.
- You can site the MFC control on a Visual Basic ActiveX control, expose
its properties and methods, and then dynamically add the Visual Basic
control at run-time.
REFERENCES
For additional information, please see the following articles in the
Microsoft Knowledge Base:
190670 HOWTO: Dynamically Add Controls to a Form with Visual Basic 6.0
188577 HOWTO: What is the Licenses Collection Used For?
Modification Type: | Minor | Last Reviewed: | 3/3/2005 |
---|
Keywords: | kbBug kbCtrlCreate kbfix kbVS600sp3fix KB193025 |
---|
|