Reputation: 2080
I'm trying to save the license to a file like so:
File.WriteAllText(theSaveFileDialogBox.FileName, license.ToString(), Encoding.UTF8);
as suggested here:
http://dev.nauck-it.de/projects/portable-licensing/wiki/GettingStarted
But the contents of my save file always end up being just
Portable.Licensing.LicenseBuilder
As if the ToString()
method wasn't overridden. Also, the Save()
method doesn't even appear as a member of license
. Any ideas?
Update:
The problem was I was trying to build the license up by parts, as such:
var license = Portable.Licensing.License.New().WithUniqueIdentifier(Guid.NewGuid());
if (lic_type_box.Text == "Trial") license.As(LicenseType.Trial);
else if (lic_type_box.Text == "Full") license.As(LicenseType.Standard);
int days;
if (int.TryParse(lic_days.Text, out days)) license.ExpiresAt(DateTime.Now.AddDays(days));
if (lic_name.Text != "") license.LicensedTo("lic_name.Text", "");
license.CreateAndSignWithPrivateKey(privateKey, passPhrase);
when the last line should really have been
var createdLicense = license.CreateAndSignWithPrivateKey(privateKey, passPhrase);
and then
File.WriteAllText(theSaveFileDialogBox.FileName, createdLicense.ToString(), Encoding.UTF8);
Upvotes: 1
Views: 885
Reputation: 12683
I have never actually used this library however Portable.Licensing.LicenseBuilder
is (probably) what is the result of license.ToString()
.
Looking at their tutorial they are actually calling the method CreateAndSignWithPrivateKey(..,...)
which is a method that returns back an instance of License
not LicenseBuilder
.
This is key as the License
class overrides the ToString()
method and returns the xml data produced from the result of the license builder class.
Right so this seems a bit complex but basically License.New()
returns an ILicenseBuilder
. This does not have a Save
method but License
does.\
Now thats about as much as we can help you with as you will need to provide us some code as to what exactly license
is.
Upvotes: 1