Page 1 of 1

Load licence data without having to Open() a connection

Posted: Wed 26 Jun 2019 11:29
by pergardebrink
When using the Devart.Data.MySql package from NuGet, is there any way other than doing a "fake" .Open() using a dummy connectionstring to provide a License key that works embedded without external dependencies like a separate license file?

The current approach, which works, but feels very ugly is doing like this (::0 is an invalid address which causes it to fail early and not to make an actual connection to localhost, which it would if no host is specified):

Code: Select all

try { 
	using (var dummy = new MySqlConnection(new MySqlConnectionStringBuilder {
		Host = "::0", LicenseKey = "LICENSEKEY_GOES_HERE"}.ToString())) {
		dummy.Open();
	}
} catch { }
Is there a better way to embed the license key and set it during application startup?

Re: Load licence data without having to Open() a connection

Posted: Thu 27 Jun 2019 13:27
by Shalex
conn.Open() with specified License Key is the only way to activate the license in a current application domain: https://www.devart.com/dotconnect/mysql ... ndard.html.

Re: Load licence data without having to Open() a connection

Posted: Tue 07 Apr 2020 22:01
by chris185
Hello,

I have a .NET Framework 4.8 project which fails on runtime with invalid license exception. I tried it with this dummy connection but i get an error that the method set_licensekey was not found. How is the correct way to register the license key? Thanks.

Best regards
christoph

Re: Load licence data without having to Open() a connection

Posted: Wed 08 Apr 2020 17:15
by Shalex
The current implementation of dotConnect for MySQL includes two sets of assemblies:

1) the .NET Framework Devart.* assemblies which are shipped with installation:
* assemblies are created in C:\Program Files (x86)\Devart\dotConnect\MySQL\
* licensing approach is described at https://www.devart.com/dotconnect/mysql ... nsing.html

2) the .NET Standard (.NET Core) Devart.* assemblies which are available via NuGet:
* you can download packages from https://www.nuget.org/packages/devart.data.mysql
* licensing approach is described at https://www.devart.com/dotconnect/mysql ... ndard.html
chris185 wrote:
Tue 07 Apr 2020 22:01
i get an error that the method set_licensekey was not found
The error means that you are trying to apply License Key with .NET Framework Devart.* assemblies. But in this case, a different approach should be used: run Tools > MySQL > License Information wizard to add the license resource automatically. Refer to https://www.devart.com/dotconnect/mysql ... nsing.html. If this doesn't help, specify the exact text of the error and its full stack trace.

Re: Load licence data without having to Open() a connection

Posted: Wed 08 Apr 2020 20:48
by chris185
I have found the License Wizard and fixed it successfully. Thank you very much!

Re: Load licence data without having to Open() a connection

Posted: Thu 16 Apr 2020 14:03
by pergardebrink
Just a note on this, if you want to use the NuGet packages (for example if you are multitargeting .NET Framework and .NET Core), make sure you have cleared the "Do not install assemblies in the GAC" during installation of dotConnect.
Otherwise your code will be compiled against the NuGet versions (where the Licence Key property is available), but when you start the application, the runtime will bind the .NET Framework assemblies from GAC (which does not have a Licence Key property).
chris185 wrote:
Tue 07 Apr 2020 22:01
Hello,

I have a .NET Framework 4.8 project which fails on runtime with invalid license exception. I tried it with this dummy connection but i get an error that the method set_licensekey was not found. How is the correct way to register the license key? Thanks.

Best regards
christoph