View previous topic :: View next topic |
Author |
Message |
rune
Joined: 05 Dec 2006 Posts: 7
|
Posted: Tue Dec 12, 2006 12:40 pm Post subject: Component license embedding |
|
|
Hi,
I've created a class that is licensed, and (after getting help here) got the "Enter license key" dialog to appear and work when the class was used at design time in VS2005.
Now, a <Componentname>.lic file appears in the installation directory for the assembly as expected. However, if I create a project that uses my licensed assembly the final application still displays the "Unlicensed application" dialog when run. I've been reading about including the "licenses.licx" file, but first I cannot find that file anywhere, and second I cannot force my users to do this manually to use my class.
Any ideas?
Thank you in advance,
Rune |
|
Back to top |
|
|
Infralution
Joined: 28 Feb 2005 Posts: 5027
|
Posted: Tue Dec 12, 2006 10:01 pm Post subject: |
|
|
The licenses.licx file is Microsofts mechanism for specifying license keys to embed in the resources of an application. If your licensed class is a component or control and the user adds it using the Visual Studio designer then Visual Studio will automatically create a licenses.licx file for the project (if it doesn't already exist) and add an entry for the licensed control. If your class is not added using the designer then the user must add the entry manually (creating the licenses.licx file if it doesn't exist).
The licenses.licx file must be included in the customers project with the build action set to "Embedded Resource". The entry should be the assembly qualified name of your licensed class eg:
MyNameSpace.MyClass, MyAssemblyName
This is the only mechanism Microsoft provide for embedding license keys in an application. If a user is computer literate enough to be developing using Visual Studio then creating a file and copying some text into it should not pose a major problem. You could provide a licenses.licx file that they could simply copy. If you are really concerned then you could either develop a tool to create the entry/file for a selected project or alternatively derive your class from Component and allow the user to add it from the Visual Studio designer. _________________ Infralution Support |
|
Back to top |
|
|
rune
Joined: 05 Dec 2006 Posts: 7
|
Posted: Tue Dec 19, 2006 12:45 pm Post subject: |
|
|
I've tried everything I can think of, but no luck. If I create a standard component I have no problems, but with my class, which is also generic, I get an "Unable to resolve type '<String from licenses.licx>'" error when building.
Could it be that the generic class requires some strange descriptor? I had to do some changes to the license file name at design time because of this, so I'm suspecting that this is caused by the same problem but I have no idea what to put and where to put it.
All the best,
Rune |
|
Back to top |
|
|
Infralution
Joined: 28 Feb 2005 Posts: 5027
|
Posted: Tue Dec 19, 2006 10:27 pm Post subject: |
|
|
The problem is that Microsofts component licensing framework was built before they introduced the concept of generics. The component licensing framework depends on finding the license for a class based on its type. The problem is that generics don't have a type until they are instantiated (See http://en.csharp-online.net/CSharp_Generics_Recipes%E2%80%94Getting_the_Type_of_a_Generic_Type for more info).
I think the best way of handling this would be to create a base (non-generic) class which you then derive your generic class from. You can then license the base class in the normal way. _________________ Infralution Support |
|
Back to top |
|
|
rune
Joined: 05 Dec 2006 Posts: 7
|
Posted: Wed Dec 20, 2006 8:33 am Post subject: |
|
|
That sounds like a good idea. I'll try that and get back to you if I'm still stuck.
Thank you very much again for your excellent and timely service.
All the best,
Rune |
|
Back to top |
|
|
|