zzzprojects / Bulk-Operations

C# SQL Bulk Operations | High-performance C# bulk insert, update, delete and merge for SQL Server, SQL Azure, SQL Compact, MySQL, and SQLite.
https://bulk-operations.net
142 stars 34 forks source link

How to enable the Pro license? #27

Closed AndreaA86 closed 6 years ago

AndreaA86 commented 6 years ago

Hi. To add the license I added the license name and the key into the app.config in the appSettings section. After that, to enable the pro license I must call the ValidateLicense() method when the application runs before to use the library. It's right? It's a problem if I call this method each time the application runs?

Thanks. Andrea

JonathanMagnan commented 6 years ago

Hello @AndreaA86 ,

You don't have to call the method ValidateLicense at all. It's more a validation method on your side to make sure you added the license correctly. It's not needed to make the library work.

By default, the first time our library is used, it will register the license.

It will not be a problem if you call it multiple times but you should only do it once such as in the Global.asax if you have a web application.

Let me know if that answer correctly to your question.

Best Regards,

Jonathan

AndreaA86 commented 6 years ago

I tried to add the license in my app.config file (the trial was already expired). I'm using the library in a WinForm application.

When I run the application and I invoked BulkMerge(), an error was generated due to the expired trial. In theory, as you said, the PRO license should be activated after the first use. Therefore I invoked the ValidateLicense() method and after that the error no longer occurred.

JonathanMagnan commented 6 years ago

Do you think you could provide us with an example of the issue?

The ValidateLicense is optional but from I understand, on your case, it's required for an unknown reason.

AndreaA86 commented 6 years ago

I report all the steps done:

  1. Currently the trial was expired
  2. I added the key values into the app.config of the WinForm application's project.
  3. I run the application and I invoke the BulkMerge() method. After calling this method an error occurs "Trial expired...."
  4. I stopped the application and I added into the main() method of the Program.cs file a code to invoke the ValidateLicense().
  5. If I rerun the application, the ValidateLicense() is invoked and then when I call the BulkMerge() it works correctly.

Maybe depends by the trial expired?

JonathanMagnan commented 6 years ago

Hello @AndreaA86 ,

Here is a project that use an expired version. When adding the license, it works as expected without using the ValidateLicense.

We used your license to make the test.

Request_Expired.zip

To try it you will need to:

AndreaA86 commented 6 years ago

Yes I have seen that project works. In my case I have an application composed by several c# project. Could it depend on the fact that I have more projects that make up the application? and where I set the library keys?

I have a "Main" project (output type: win application) where I don't have the zBulkOperations reference. Then I have a "Core" project (loutput type: class library) where I have the zBulkOperations reference because I use it here. At the beginning I set the key license in the app.config file (at the bottom) of the Core project and the license it doesn't work when I used BulkMerge. At the end I resolved adding the key license into the Main project and into the Main() I used a static class of the Core project where I call ValidateLicense().

AndreaA86 commented 6 years ago

Ok. I verified just now editing your solution adding a new "class library" project called "Core" (to simulate my application). I moved bulklibrary reference and your code into the new "Core" project and I removed the bulk reference from the Request_Expired project. I only use it into the Core project.

Now if I add keys into the app.config of the Core project (that use zBUlk now) the pro license is not activated. Instead If I leave keys into the original app.config of the Request_Expired project, also if I use zBulk in the Core project, the license is activated without call ValidateLicense() method. I must leave license key into the main project app.config file.

However I called ValidateLicense() at the start to check if the commercial license is expired to log this info.

Thanks.

JonathanMagnan commented 6 years ago

Hello @AndreaA86 ,

If I understand well, that's an expected behavior.

By default, config from a referenced project is not copied to the output directory. So it's expected the license is adding to the main project config file.