Load licence data without having to Open() a connection

Discussion of open issues, suggestions and bugs regarding ADO.NET provider for MySQL
Post Reply
pergardebrink
Posts: 8
Joined: Mon 02 Jul 2018 08:26

Load licence data without having to Open() a connection

Post by pergardebrink » Wed 26 Jun 2019 11:29

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?

Shalex
Site Admin
Posts: 9543
Joined: Thu 14 Aug 2008 12:44

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

Post by Shalex » Thu 27 Jun 2019 13:27

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.

chris185
Posts: 3
Joined: Tue 07 Apr 2020 21:38

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

Post by chris185 » 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

Shalex
Site Admin
Posts: 9543
Joined: Thu 14 Aug 2008 12:44

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

Post by Shalex » Wed 08 Apr 2020 17:15

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:01i 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.

chris185
Posts: 3
Joined: Tue 07 Apr 2020 21:38

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

Post by chris185 » Wed 08 Apr 2020 20:48

I have found the License Wizard and fixed it successfully. Thank you very much!

pergardebrink
Posts: 8
Joined: Mon 02 Jul 2018 08:26

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

Post by pergardebrink » Thu 16 Apr 2020 14:03

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

Post Reply