Infralution Support Forum Index Infralution Support
Support groups for Infralution products
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Error on registering license at design-time

 
Post new topic   Reply to topic    Infralution Support Forum Index -> Licensing Support
View previous topic :: View next topic  
Author Message
rune



Joined: 05 Dec 2006
Posts: 7

PostPosted: Tue Dec 05, 2006 2:05 pm    Post subject: Error on registering license at design-time Reply with quote

Hi,

I have a problem registering a license key for a licensed class I've made. When I get the "Install License" dialog and enter a license key, I get an error saying "An error occurred while installing the license. Ensure you have sufficient privileges to install the license."

The structure of the assembly is that I have a generic class (not Component/Control) which is licensed so the code from the "Component and Control Licensing" example has gone into that class. Then I have an example component that uses the licensed class. When that component is used at design-time in VS, the "Install License" dialog appears as expected, but I get the error mentioned above.

Do you have any ideas on how to solve this?

Thanks in advance,
Rune
Back to top
View user's profile Send private message
Infralution



Joined: 28 Feb 2005
Posts: 5027

PostPosted: Tue Dec 05, 2006 10:56 pm    Post subject: Reply with quote

The most likely cause is that you do not have the file permissions required to write the license file. What operating system are you using? Are you logged on as an Administrator or Power User?

Typically developers will have administrator privileges on their development machine - so it is OK to install the license in the same directory as the component assembly (which is the default).

An alternative worth considering is installing the license in the shared application data directory. To do this you need to derive a new class from EncryptedLicenseProvider and override the GetLicenseDirectory method eg

Code:
      protected override string GetLicenseDirectory(LicenseContext context, Type type)
        {
            string path = Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData);
            path += @"\MyCompany";
           Directory.CreateDirectory(path);
           return path;
        }


This creates a directory under the common app directory for your company where the license file will be installed.
You then need to replace all references to EncryptedLicenseProvider class in you code with a reference to the derived class.
_________________
Infralution Support
Back to top
View user's profile Send private message Visit poster's website
rune



Joined: 05 Dec 2006
Posts: 7

PostPosted: Wed Dec 06, 2006 6:37 am    Post subject: Reply with quote

Thank you for your reply.

I should have mentioned initially that I'm running XP SP2 and I do have administrator rights.

I also tried to install the dll on another development machine (still XP SP2 with admin rights) and enter the license key there, but I get the same issue.

Any more ideas?

Thank you in advance,
Rune
Back to top
View user's profile Send private message
rune



Joined: 05 Dec 2006
Posts: 7

PostPosted: Wed Dec 06, 2006 7:58 am    Post subject: Reply with quote

Hi again,

I just did a trace (debug) and I think I've found the problem. The method GetLicenseFilePath adds "type.FullName" as the filename and the return value is this (identifiable values modified):

"C:\\<Full path to project>\\bin\\Release\\<Namespace>.<ClassName>`3[[System.String, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=<Token>],[System.String, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=<Token>],[System.Int32, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=<Token>]].lic"

Is this filename correct?

Thanks again,
Rune
Back to top
View user's profile Send private message
Infralution



Joined: 28 Feb 2005
Posts: 5027

PostPosted: Wed Dec 06, 2006 9:44 pm    Post subject: Reply with quote

OK I see the issue. The class you are licensing is a generic class instantiation - and these have very strange typenames - which cannot be used as valid filenames. The solution is to override GetLicenseFilePath and construct your own filename for the license key eg

Code:
        protected virtual string GetLicenseFilePath(LicenseContext context, Type type)
        {
            string dir = GetLicenseDirectory(context, type);
            return String.Format(@"{0}\MyProduct.lic", dir);
        }

_________________
Infralution Support
Back to top
View user's profile Send private message Visit poster's website
rune



Joined: 05 Dec 2006
Posts: 7

PostPosted: Thu Dec 07, 2006 10:06 am    Post subject: Reply with quote

Hi again,

That did the trick, but I had to derive a new LicenseInstallForm as well and override the GetLicenseProvider method to return an instance of the new class derived from EncryptedLicenseProvider (i.e. MyLicenseProvider).

I noticed that the EncryptedLicenseProvider.SystemLicense property will create a new EncryptedLicenseProvider and not a derived class, but I'm assuming that will not cause any problems for the licensing of my class.

So, it seems the problem is solved! Thank you very much for your excellent and timely support.

All the best,
Rune
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Infralution Support Forum Index -> Licensing Support All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group