Re: GetSavedLicenseKey and SetSavedLicenseKey and differeing versions.
From: Brian Roder [MSFT] (broder_at_online.microsoft.com)
Date: 09/24/04
- Previous message: TusharP: "How to add ListBox as Row of DataGrid"
- In reply to: johndoe_at_driver.net: "Re: GetSavedLicenseKey and SetSavedLicenseKey and differeing versions."
- Next in thread: johndoe_at_driver.net: "Re: GetSavedLicenseKey and SetSavedLicenseKey and differeing versions."
- Reply: johndoe_at_driver.net: "Re: GetSavedLicenseKey and SetSavedLicenseKey and differeing versions."
- Messages sorted by: [ date ] [ thread ]
Date: Fri, 24 Sep 2004 22:16:10 GMT
I am researching other possible solutions but I have one that I verified
will work. When you call SetSavedLicenseKey/GetSavedLicenseKey/IsKeyValid
you need to pass the type of the component that is licensed. This is
passed into the GetLicense when it is called by the Framework. Instead of
just passing to these 3 methods what is passed in by the Framework you can
instead pass its base type using type.BaseType. For example, here is
snippet of GetLicense code using type.BaseType:
'BEGIN CODE
Dim lic As RegLicense = Nothing
Dim key As String
If context.UsageMode = LicenseUsageMode.Designtime Then
MessageBox.Show("Designtime mode")
key = GetRegKey()
If key <> "" And IsKeyValid(key, type.BaseType) Then
lic = New RegLicense(Me, key)
context.SetSavedLicenseKey(type.BaseType, lic.LicenseKey)
End If
ElseIf context.UsageMode = LicenseUsageMode.Runtime Then
MessageBox.Show("Runtime mode")
key = context.GetSavedLicenseKey(type.BaseType, Nothing)
If (key <> Nothing And IsKeyValid(key, type.BaseType)) Then
lic = New RegLicense(Me, key)
End If
End If
Return lic
'END CODE
Now, assuming your base type is System.Windows.Forms.UserControl then the
build number will not change. If the base type is another one of your
types, and the build number changes, I suspect you will run into the same
issue. Can you test this to see if it works for you? I tested this by
just recompiling the assembly containing the licensed control after
incrementing the revision number. I did not recompile the EXE. If I just
use 'type' in GetLicense it fails but if I use 'type.BaseType' it doesn't
fail.
- Previous message: TusharP: "How to add ListBox as Row of DataGrid"
- In reply to: johndoe_at_driver.net: "Re: GetSavedLicenseKey and SetSavedLicenseKey and differeing versions."
- Next in thread: johndoe_at_driver.net: "Re: GetSavedLicenseKey and SetSavedLicenseKey and differeing versions."
- Reply: johndoe_at_driver.net: "Re: GetSavedLicenseKey and SetSavedLicenseKey and differeing versions."
- Messages sorted by: [ date ] [ thread ]