This week I have worked to try to host a licensed Windows Forms control in a Web site, loaded using Internet Explorer.
I had a BaseControl.dll with a BaseControl control class that required licensing (using a .lic file), and created myself a DerivedControl.dll with a DerivedControl class that inherited from BaseControl class.
I used this article to learn how to host the control, using HTML object tag, and tried to compile the licenses using LC.exe, then to store the generated .licenses file on the same Web site.
Everything went great except that the licensed control still complained that I didn’t provide the license.
I did a lot of research and tests and found that for some reason there was a security exception generated by the license provider class of the BaseControl, i.e. the control that checked for its license. In fact the exception occured because the .licenses file hasn’t been downloaded by IEHost (1) and/or it was not stored in memory for some unknown reason (2) and/or it was a corrupt .licenses file (3). Or (4) Microsoft’s license retreival mechanism didn’t work in security contexts such as that of a control loaded from the Web.
I have also contacted Microsoft on the newsgroups about the issue and they (Lucy Liu [MSFT]) gave some good advice, such as checking that in IIS I have added the appropriate ‘application/octet-stream’ MIME type for .licenses extension of the file. That was part of the solution. However it didn’t solve it completely, as now I was sure the .licenses file is downloaded (sot it’s not (1)) but still the control didn’t want to accept the license.
I was about sure that the problem is (1). Then after investigation and some other brainstorming I found the reason:
When I used LC.exe to compile the .licx file I prepared for my control, I didn’t give both assemblies (BaseControl.dll and DerivedControl.dll) as /i: switches. Instead, I considered it’s enough to give only BaseControl.dll to LC.exe as BaseControl was the one that required a license.
However, after I run the LC.exe again, providing two /i: arguments, one for each dll, everything was successfull and the control is now licensed!
Hope it helps someone else too, later. I wish I could find this on Google this week!