tags:

views:

398

answers:

2

Hi,

I need to implement licensing in my windows application i downloaded this open source project code called the OpenLicenseBuilder which generates an xml file with ll the product code and certain constraints How do i use it in my .Net windows application I just dont know how to use the gereated xml file whihc is of the extension LIC .?

REgards Fran

A: 

Have you looked on their website at the help or documentation sections?

http://www.spextreme.com/osp/open_license/

280Z28
Yes but does not work ! There is nothing mentioned i have the User documentation as well it only talks about creating a lic file but no where mentions how to use this created file ?
A: 

Reading the source code indicates the Licensprovider first looks in an internal cache, secondly in the isolated storage.

At the same time it tries to fetch the license from the filesystem as follows (depending if it's a webapp or a windows app:

Obtains a license from a preset set of paths. The paths are defined as:

  • The Application Bin directory
  • Application start path

In code:

HttpContext.Current.Server.MapPath( "~" + Path.DirectorySeparatorChar );
HttpContext.Current.Server.MapPath( "." + Path.DirectorySeparatorChar );
HttpContext.Current.Server.MapPath( "~" + Path.DirectorySeparatorChar ) + "bin";

or for a windows app:

System.Windows.Forms.Application.StartupPath + Path.DirectorySeparatorChar
System.Windows.Forms.Application.StartupPath + Path.DirectorySeparatorChar + "bin" + Path.DirectorySeparatorChar;

if the license in the filesystem is newer then the license in the isolated storage, a copy of your alternative license is stored.

And concerning the usage in code. The example shows that you need to use the library as follows:

use an Attribute at the Class declaration to indicate that you will use the OpenLicenseProvider as the license provider:

using System.ComponentModel;
...

enter code here
[LicenseProvider( typeof( OpenLicense.OpenLicenseProvider ) )]
public class MyClass
{ 
    ...

Then in code use the LicenseManager to validate the license with OpenLicenseProvider:

    private License license = null;

    LicenseManager.IsValid( typeof( MyClass ), this, out license );
Vincent
Hi Thanks for your reply i understand that it takes the default as shown above . My problem is i have a .lc file generated with OpenLicenseBuilder and saved on to my desktop , Now i to use this .lic file into my application. This lic file contains certain constraints etc.
Sorry that is .Lic file
sorry for the multiple edits. I haven't tried generating a file yet. I just tried to understand how a license file is used.
Vincent