N
~~~ .NET Ed ~~~
I have a problem trying out the "simple" component/control licensing scheme
in
VS.NET 2003 (I use C#). I have read several articles, most of them with
differing
information, read the MS documentation on MSDN and with VS.NET but can't get
the bloody thing working. Here are the steps I followed in hope somebody can
bring some light into the subject:
1. Information about my "licensed" component:
Namespace: Test.Common.Controls
Project name: CtMyControl
Class Name: MyControl
Assembly Name: Test.CtMyControl.dll
Directory: E:\Develop\Common\CtMyControl\obj\Release\
Build Type: Release
2. I added the Licensed attribute to my licensed control specifying for
now the simple provider which I would expect works out of the box.
Also added the private license member, its validation in the constructor
and the disposing of the license.
namespace Test.Common.Controls
{
[LicenseProvider(typeof(LicFileLicenseProvider))]
public sealed class MyControl
{
private License validatedLicense = null;
public MyControl()
{
InitializeComponent();
this.validatedLicense = LicenseManager.Validate(typeof(MyControl),
this);
} // Constructor
protected override void Dispose( bool disposing )
{
if( disposing )
{
if(components != null)
{
components.Dispose();
}
// Liberate the license, don't let it linger in memory
if (this.validatedLicense != null)
{
this.validatedLicense.Dispose();
this.validatedLicense = null;
}
}
base.Dispose( disposing );
} // Dispose
} // MyControl
} // namespace
So far this part works because when I try to add the licensed component to a
form
I get an exception in design mode. (more on that later).
3. The test application where I am trying to put the control is a Release
type
of build as well.
It has a reference to the DLL that contains the license control, the
properties of this reference show:
Name: Test.CtMyControl
Copy Local: True
Identity: Test.CtMyControl
Path: E:\Develop\common\CtMyControl\obj\Release\Test.CtMyControl.dll
4. Following the instructions (which differ from article to article found on
the web, even MS docs seem to be slightly inconsistent) I placed a
License
file in the same directory that Path of the above named Reference is
located:
Directory: E:\Develop\Common\CtMyControl\obj\Release\
Filename: Test.Common.Controls.MyControl.lic
notice that the filename is the fully qualified name (namespace+class) of
the control to be licensed. The contents of this "license" file are:
Test.Common.Controls.MyControl is a licensed component.
exactly as shown above without leading or trailing spaces. Some articles
say
that the trailing dot is necessary, some simply omit the article. I tried
both things to no avail.
Also some articles seem to suggest that the ",Assembly" has to be
appended
but it is not clear if that is for the .LIC file or the .LICX file.
Ok, so far so good. Now I rebuilt the whole solution and proceeded to add
the
"licensed" component to a form and BOOM:
"An exception occurred while trying to create and instance
of Test.Common.Controls.MyControl. The exception was "an instance
of type 'Test.Common.Controls.MyControl' was being created, and a valid
license could not be granted for the type
'Test.Common.Controls.MyControl'
Please contact the manufacturer of the component for more information."
This is the exception pop up I would expect if there was no license for the
component. So what am I missing here? I am
- Using the simple LicFileLicenseProvider provided by .NET as start point
- Added the attribute to the class that implements the control
- Added the license container in the control class
- Validated the license in the constructor (obviosly here the
exception is thrown for a reason I don't know)
- Disposed of the license in the Dispose method
- Created a .LIC file with the full name of the class and placed it
in the same directory shown in the assembly reference of the project
where I am attempting to use the component.
So, what else??? any help would be greatly appreciated.
Thx,
E.
in
VS.NET 2003 (I use C#). I have read several articles, most of them with
differing
information, read the MS documentation on MSDN and with VS.NET but can't get
the bloody thing working. Here are the steps I followed in hope somebody can
bring some light into the subject:
1. Information about my "licensed" component:
Namespace: Test.Common.Controls
Project name: CtMyControl
Class Name: MyControl
Assembly Name: Test.CtMyControl.dll
Directory: E:\Develop\Common\CtMyControl\obj\Release\
Build Type: Release
2. I added the Licensed attribute to my licensed control specifying for
now the simple provider which I would expect works out of the box.
Also added the private license member, its validation in the constructor
and the disposing of the license.
namespace Test.Common.Controls
{
[LicenseProvider(typeof(LicFileLicenseProvider))]
public sealed class MyControl
{
private License validatedLicense = null;
public MyControl()
{
InitializeComponent();
this.validatedLicense = LicenseManager.Validate(typeof(MyControl),
this);
} // Constructor
protected override void Dispose( bool disposing )
{
if( disposing )
{
if(components != null)
{
components.Dispose();
}
// Liberate the license, don't let it linger in memory
if (this.validatedLicense != null)
{
this.validatedLicense.Dispose();
this.validatedLicense = null;
}
}
base.Dispose( disposing );
} // Dispose
} // MyControl
} // namespace
So far this part works because when I try to add the licensed component to a
form
I get an exception in design mode. (more on that later).
3. The test application where I am trying to put the control is a Release
type
of build as well.
It has a reference to the DLL that contains the license control, the
properties of this reference show:
Name: Test.CtMyControl
Copy Local: True
Identity: Test.CtMyControl
Path: E:\Develop\common\CtMyControl\obj\Release\Test.CtMyControl.dll
4. Following the instructions (which differ from article to article found on
the web, even MS docs seem to be slightly inconsistent) I placed a
License
file in the same directory that Path of the above named Reference is
located:
Directory: E:\Develop\Common\CtMyControl\obj\Release\
Filename: Test.Common.Controls.MyControl.lic
notice that the filename is the fully qualified name (namespace+class) of
the control to be licensed. The contents of this "license" file are:
Test.Common.Controls.MyControl is a licensed component.
exactly as shown above without leading or trailing spaces. Some articles
say
that the trailing dot is necessary, some simply omit the article. I tried
both things to no avail.
Also some articles seem to suggest that the ",Assembly" has to be
appended
but it is not clear if that is for the .LIC file or the .LICX file.
Ok, so far so good. Now I rebuilt the whole solution and proceeded to add
the
"licensed" component to a form and BOOM:
"An exception occurred while trying to create and instance
of Test.Common.Controls.MyControl. The exception was "an instance
of type 'Test.Common.Controls.MyControl' was being created, and a valid
license could not be granted for the type
'Test.Common.Controls.MyControl'
Please contact the manufacturer of the component for more information."
This is the exception pop up I would expect if there was no license for the
component. So what am I missing here? I am
- Using the simple LicFileLicenseProvider provided by .NET as start point
- Added the attribute to the class that implements the control
- Added the license container in the control class
- Validated the license in the constructor (obviosly here the
exception is thrown for a reason I don't know)
- Disposed of the license in the Dispose method
- Created a .LIC file with the full name of the class and placed it
in the same directory shown in the assembly reference of the project
where I am attempting to use the component.
So, what else??? any help would be greatly appreciated.
Thx,
E.