OK after
MUCH trial and error I've finally been able to determine the actions which reliably allow me to compile and run my app under Mono (using MonoDevelop but I'm sure command line would work also) after initially creating the .licenses file on Windows.
So for posterity sake here is some detailed info.
Assumptions / notes:
- I am creating an ASP.NET MVC app, which gets compiled into a single DLL (MyMvcApp.Web.dll);
- I have a second assembly, MyMvcApp.Data.dll, which contains the data access logic.
- MyMvcApp.Data.dll contains references to both Devart.MySql.dll and Devart.MySql.Linq.dll (it also contains references to Devart.Data.dll and Devart.Data.Linq.dll but these seem to be "common" DLLs which are not licensed).
- MyMvcApp.Web.dll does NOT contain any references to any Devart DLLs, but contains a project reference to MyMvcApp.Data.dll.
So
Step 1 is to create the .licenses file. Like many Microsoft products (sorry) Lc.exe will give terrible error messages or silently do the wrong thing with no indication it didn't work right. Here is the correct command line for my scenario above.
NOTE: this must be run on the machine on which DotConnect is installed.
Code: Select all
lc.exe /target:MyMvcApp.Web.dll /complist:licenses.licx /i:[Path_to_assembly]\Devart.Data.MySql.dll /i:[Path_to_assembly]\Devart.Data.MySql.Linq.dll /v
So because none of the examples on this site or Microsoft's site actually
explain what all of this means, here's the breakdown:
/target: This is the name of the DLL or EXE that will "host" the application,
NOT NECESSARILY the DLL that has the references to the licensed components. Thus StanislavK's example above is NOT correct because it specifies /target as the Data.dll. For the MVC app this should be the MyMvcApp.Web.dll instead. Also note that, unlike /i, this is
NOT A PATH! It's just the name of the DLL that will contain the running the app.
/complist: The licenses.licx file. This is a plain text file of the licensed components which need to be used. And
since no example on this entire site got this one right, here's what it must contain:
Code: Select all
Devart.Data.MySql.Linq.Provider.MySqlDataProvider, Devart.Data.MySql.Linq
Devart.Data.MySql.MySqlConnection, Devart.Data.MySql
Because these are both licensed components, they both need to be in there, one per line (each line contains the name of a class that is licensed, and the name of the assembly which that class is in, without the .dll). Trust me on this one (unless for some reason you're only using one of them; I assume Devart.Data.MySql is always required and Devart.Data.MySql.Linq is if you use LINQ to MySql)
/i: Again, because there are two licensed components, you need two /i parameters, one for each. These must be actual paths to the DLLs being used (can be relative to the current directory) so that Lc.exe can actually load them up and call the licensing routines.
/v: To specify Verbose mode. This will let you see that the Lc.exe tool actually picks up both licensed components and includes them.
OK so after all this you have a .licenses file. THIS is the file that needs to be embedded as a resource in the root of the Web project. I just copied the file over to the root of my MVC project, right-clicked on the project in MonoDevelop, clicked "Add" then "Add Files", and added the .licenses file.
Then right-click on the added file in the project, choose Properties, and then change Build Action to "Embed as resource".
Now here's the part I'm not sure of... I swear that one time it didn't work correctly if I didn't fix the Resource ID on the Properties tab also. You'll see that it probably "doubled up" the namespace, like "MyMvcApp.Web.mymvcapp.web.dll.licenses" (yeah the Lc.exe tool creates the file in all lowercase but that shouldn't matter). Anyway I changed that Resource ID to the correct full name (just "MyMvcApp.Web.dll.licenses"), but now I'm not sure whether that actually matters.
Note that, in my case, it was NOT necessary to do ANYTHING to the MyMvcApp.Data.dll project! Even though it has the references to the components, it's not the assembly that runs. So in that sense it's much like the precompiled ASP.NET examples on the Licensing page, although that page gets the examples all wrong and yes those details matter (for example you don't need to embed the .licx file, just the .licenses file).
Anyway, if all of this works out you should be able to simply Debug or Run your application in MonoDevelop (or using xsp2 or mod_mono) and have it work without those annoying KeyHandler errors!
Hopefully this info saves the next person from having to endure three days of trial and error using bad and/or incomplete command line examples; I'm sure all of this is obvious to someone who works with these tools all the time but for those of us who never deal with component licensing each day it's not very easy at all!