all groups > dotnet windows forms designtime > september 2004 >
You're in the

dotnet windows forms designtime

group:

GetSavedLicenseKey and SetSavedLicenseKey and differeing versions.


GetSavedLicenseKey and SetSavedLicenseKey and differeing versions. johndoe NO[at]SPAM driver.net
9/20/2004 1:56:40 AM
dotnet windows forms designtime: We have developed a Licx License Provider.
The problem is that whenever the build version of our Control changes
Applications that were use the control fail because the GetSavedLicenseKey
is retrieving a null value. From our understanding this is because the
Signature is changing due to the Build number increment even though nothing
actually changed. Everything i have tested backs this statement up.

What we are looking for, and I am sure that it is just because we have been
racking our brains for so long, is a way to work around this because when we
ship a new version of our component it will break their designers and their
applications because of the different version and thus not finding the
embedded license.



RE: GetSavedLicenseKey and SetSavedLicenseKey and differeing versions. v-jetan NO[at]SPAM online.microsoft.com (
9/20/2004 9:16:15 AM
Hi john,

Does your application fail at runtime or designtime because of build
version issue? Also, the GetSavedLicenseKey method means
DesigntimeLicenseContext.GetSavedLicenseKey or
LicenseContext.GetSavedLicenseKey?

More detailed information may help us reproduce this issue and find the
workaround.

Thank you for your patience and cooperation. If you have any questions or
concerns, please feel free to post it in the group. I am standing by to be
of assistance.

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
Re: GetSavedLicenseKey and SetSavedLicenseKey and differeing versions. johndoe NO[at]SPAM driver.net
9/20/2004 11:03:04 AM
The application is failing at runtime due to version issues.
and we are using LicenseContext.GetSavedLicenseKey


[quoted text, click to view]

Re: GetSavedLicenseKey and SetSavedLicenseKey and differeing versions. johndoe NO[at]SPAM driver.net
9/21/2004 9:38:55 AM
Anxiously awaiting and i appreciate it.


[quoted text, click to view]

Re: GetSavedLicenseKey and SetSavedLicenseKey and differeing versions. v-jetan NO[at]SPAM online.microsoft.com (
9/21/2004 10:44:04 AM
Hi john,

I have received your reply and will do some research on it, I will reply to
you ASAP. Thanks for your understanding.

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
Re: GetSavedLicenseKey and SetSavedLicenseKey and differeing versions. v-jetan NO[at]SPAM online.microsoft.com (
9/23/2004 7:19:12 AM
Hi john,

I am currently looking for some other people to help you on this issue. We
will update you ASAP. Thanks for your understanding.

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
Re: GetSavedLicenseKey and SetSavedLicenseKey and differeing versions. broder NO[at]SPAM online.microsoft.com
9/24/2004 10:16:10 PM
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.

Re: GetSavedLicenseKey and SetSavedLicenseKey and differeing versions. johndoe NO[at]SPAM driver.net
9/25/2004 10:46:07 AM
One extremely fatal flaw with that is, what happens if the user users
multiple Custom Controls, be it multiple of our controls (not in a suite) or
one of our controls and another company's custom control who happens to do
the same thing.

Going down another wild tangent that I had been thinking about, the other
alternative would be to override SetSavedLicenseKey and getSavedLicense Key
method and embedding our own resource.

Excusing the inability to understand anything a word said in the
presentation around Slide 27 code snippets are shown for what seems to be a
non-real world usage. Ar However it appears to be the closest to
documetnation and samples for this. Are there fully C#/vb.net code samples
to go with it as the code shown appears to be badly taken out of context.

http://support.microsoft.com/servicedesks/webcasts/seminar/shared/asp/view.asp?url=/servicedesks/webcasts/en/WC072403/manifest.xml


[quoted text, click to view]

Re: GetSavedLicenseKey and SetSavedLicenseKey and differeing versions. broder NO[at]SPAM online.microsoft.com
9/28/2004 10:07:49 PM
Yes very good point. I am checking internal resources but I think this is
going to be the designed behavior (changing assembly version breaks runtime
license). I should have more information to post tomorrow.

-Brian
Re: GetSavedLicenseKey and SetSavedLicenseKey and differeing versions. johndoe NO[at]SPAM driver.net
9/29/2004 9:22:17 AM
Going down another wild tangent that I had been thinking about, the other
alternative would be to override SetSavedLicenseKey and getSavedLicense Key
method and embedding our own resource.

Excusing the inability to understand anything a word said in the
presentation around Slide 27 code snippets are shown for what seems to be a
non-real world usage. Ar However it appears to be the closest to
documetnation and samples for this. Are there fully C#/vb.net code samples
to go with it as the code shown appears to be badly taken out of context.

http://support.microsoft.com/servicedesks/webcasts/seminar/shared/asp/view.asp?url=/servicedesks/webcasts/en/WC072403/manifest.xml

Is there more information and code samples that go with that slideshow.


[quoted text, click to view]

Re: GetSavedLicenseKey and SetSavedLicenseKey and differeing versions. broder NO[at]SPAM online.microsoft.com
9/29/2004 1:53:24 PM
Our Product Group has confirmed that this is expected behavior. For
security reasons we need to match versions so if the version changes the
runtime license will be invalidated. The EXE with the embedded runtime
license will have to be re-compiled if you increment the version number of
your licensed control. There is no way around this without compromising
the license security.

Brian Roder [MSFT]
This posting is provided 'AS IS' with no warranties, and confers no rights.
<http://www.microsoft.com/info/terms.htm>

Please do not send email directly to this alias. This is our online account
name for newsgroup participation only.

Re: GetSavedLicenseKey and SetSavedLicenseKey and differeing versions. broder NO[at]SPAM online.microsoft.com
9/29/2004 6:21:53 PM
I don't believe there is a sample associated with the presentation that
will help you, but here is a sample of a custom license context:

http://www.windowsforms.net/Default.aspx?tabindex=4&tabid=49#Licensing

It demonstrates how to override these two methods. The sample is in C#.

Brian Roder [MSFT]
This posting is provided 'AS IS' with no warranties, and confers no rights.
<http://www.microsoft.com/info/terms.htm>

Please do not send email directly to this alias. This is our online account
name for newsgroup participation only.

Re: GetSavedLicenseKey and SetSavedLicenseKey and differeing versions. johndoe NO[at]SPAM driver.net
10/1/2004 11:26:57 AM
That does not have any code for SetSavedLicenseKey which is what I am
looking for. I need to be able to embed my own resource in the executable
file.


[quoted text, click to view]

Re: GetSavedLicenseKey and SetSavedLicenseKey and differeing versions. broder NO[at]SPAM online.microsoft.com
10/1/2004 10:43:06 PM
Unfortunately I cannot find any samples that override SetSavedLicenseKey.

Brian Roder [MSFT]
This posting is provided 'AS IS' with no warranties, and confers no rights.
<http://www.microsoft.com/info/terms.htm>

Please do not send email directly to this alias. This is our online account
name for newsgroup participation only.

Re: GetSavedLicenseKey and SetSavedLicenseKey and differeing versions. broder NO[at]SPAM online.microsoft.com
10/5/2004 1:50:26 PM
I have more information I would like to share with you. The reason you
won't find a sample of overriding the SetSavedLicenseKey method is because
this method is overridden by DesignTimeLicenseContext already. It is
DesignTimeLicenseContext which gets instantiated when the License Compiler
is run.

Brian Roder [MSFT]
This posting is provided 'AS IS' with no warranties, and confers no rights.
<http://www.microsoft.com/info/terms.htm>

Please do not send email directly to this alias. This is our online account
name for newsgroup participation only.

Re: GetSavedLicenseKey and SetSavedLicenseKey and differeing versions. johndoe NO[at]SPAM driver.net
10/6/2004 2:45:14 AM
Is there any way of serializing my own object and reliably stuffing it and
retrieving it from the assembly to emulate our own Set/Get Saved License

[quoted text, click to view]

Re: GetSavedLicenseKey and SetSavedLicenseKey and differeing versions. broder NO[at]SPAM online.microsoft.com
10/6/2004 9:08:11 PM
Yes you can serialize your own object but the point I was trying to make is
that it doesn't matter if you do. The runtime license gets stored at
compile time as a result of the license compiler calling
DesignTimeLicenseContext.SetSavedLicenseKey. You can't change this.

However, I think you might be able to accomplish what you need to by using
the ComponentWithCustomContext sample I referred you to. This sample
overrides creates a customer license context, replaces the existing context
with yours which causes the runtime to call your GetSavedLicenseKey method
(which has been overriden). In the GetSavedLicenseKey code it already does
a version independent check. I tested this sample and it appears to let me
update the control version without breaking an existing embedded runtime
license.

Here is the part of the code where it ignores the version:

/BEGIN CODE SNIPPET
// The DesignTimeLicenseContext used by the designers uses the versioned
// AssemblyQualifiedType as a key to the hash table. The codee locates
// a license key without checking the version.
//

// Generate the version free type name for the current licensed type
//
String currentType = StripVersionField(type.AssemblyQualifiedName);

// Store the original versioned type name in case we fail to find a match
//
String keyType = type.AssemblyQualifiedName;

// Loop over each key in the hash table and do a version free check for
// the presence of the type as a key
//
foreach (Object o in savedLicenseKeys.Keys)
{
String s = o as String;
if (s != null)
{
s = StripVersionField(s);
if (s.Equals(currentType))
{
keyType = o as String;
break;
}
}
}

return(string)savedLicenseKeys[keyType];
//END CODE SNIPPET

Brian Roder [MSFT]
This posting is provided 'AS IS' with no warranties, and confers no rights.
<http://www.microsoft.com/info/terms.htm>

Please do not send email directly to this alias. This is our online account
name for newsgroup participation only.

AddThis Social Bookmark Button