Hi Brock,
I'm able to reproduce this issue, seems the LicenseContext was not set
correctly in copy & paste operation, I'll forward this issue to the product
group to let them know.
In the mean time, I think you may try way to workaround this issue:
1. If you put the license validation code in the constructor of the user
control, remove the License Validation code from the constructor
2. Define a customized LicenseContext class derive from
DesigntimeLicenseContext class like below:
<code>
class MyDesignTimeLicenseContext :
System.ComponentModel.Design.DesigntimeLicenseContext
{
IDesignerHost provider = null;
public MyDesignTimeLicenseContext ( IDesignerHost host)
{
provider = host;
}
public override object GetService(Type type)
{
return provider.GetService(type);
}
}
</code>
2. override OnLoad event for you user control , insert the code snippet
like below:
<code>
if ( DesignMode )
{
IDesignerHost host = (IDesignerHost) this.GetService(
typeof(IDesignerHost) );
LicenseManager.CurrentContext = new MyDesignTimeLicenseContext( host );
license = LicenseManager.Validate(typeof(UserControl1), this);
LicenseManager.CurrentContext = null;
}
else license = LicenseManager.Validate(typeof(UserControl1), this);
</code>
Then you should be able to copy & paste licensed user controls.
Does it resolve your problem?
Feel free to reply this thread if you still have problems on it.
Have a nice day!
Best regards,
Ying-Shen Yu [MSFT]
Microsoft Community Support
Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties and confers no rights.
This mail should not be replied directly, please remove the word "online"
before sending mail.
Brock Reeve - 21 Jun 2004 22:07 GMT
All or our custom controls derive from Control which doesn't have a Load
event. When it comes down to it, we don't want to move our
LicenseManager.Validate calls outside the constructor. The constructor will
always be called and we are guaranteed that the licensing code will get
called. Users could override the On* event and not call the base version and
get a free control. Also the controls could be dynamically created which
may or may not fire certain events and the Validate call could get skipped
altogether. Sure we could find some little hack to get it to work, but it
would be more work and a lot of testing we are not able to do right now.
Our hope is that this issue is fixed in Whitbey.
Thanks,
Brock
"Ying-Shen Yu[MSFT]" - 22 Jun 2004 02:58 GMT
Hi Brock,
Thanks for your reply!
The reason why I put the code snippet in OnLoad method is because, the
DesignMode property always return false, so we are unable to determine if
the control was instantiated in design-time or run-time environment.
I have forwarded this issue to product group to let them do further
investigation, thanks for your feedback!
Best regards,
Ying-Shen Yu [MSFT]
Microsoft Community Support
Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties and confers no rights.
This mail should not be replied directly, please remove the word "online"
before sending mail.