dotConnect for PostgreSQL Documentation
In This Topic
    Licensing
    In This Topic

    This topic provides technical details on embedding license information into your applications. This is a special resource that must be present in every application that uses dotConnect for PostgreSQL.

    License information discussed in this topic is not same thing as license for using dotConnect for PostgreSQL. License purchased on our site allows you, your team, or your company to use dotConnect for PostgreSQL. For information on how to purchase license for using dotConnect for PostgreSQL please refer to topic Ordering.

    The article consists of following sections:

    General Information

    dotConnect for PostgreSQL uses .NET component licensing. To build an application dotConnect for PostgreSQL requires valid license. If no license is available, dotConnect for PostgreSQL does not work.

    License information is a specially formed embedded resource. Usually you do not have to care about embedding license in your application. When you install dotConnect for PostgreSQL, the system is configured so that licensing is done transparently. End-users of your software do not require any additional license.

    dotConnect for PostgreSQL includes License Wizard that helps you configure license information. The wizard analyzes the current project, informs you about problems found, and performs some actions needed to fix the problems.

    License Information dialog box

    To invoke the wizard choose PostgreSQL | License Information from the Visual Studio Tools menu. Then click the Fix buttons in the dialog and follow the wizard's instructions. In most cases this is enough to configure .NET component licensing.

    The following table helps get started quickly with dotConnect for PostgreSQL licensing. Find your type of application and follow links to corresponding sections of the article.

    Diagram Explanation
    licensing scheme - direct This is general case of licensed .NET Framework application. Whatever the type of application you develop, read carefully sections Adding License Automatically and Adding License Manually.
    licensing scheme - class libraries These two diagrams show how you can use dotConnect for PostgreSQL through a class library. In addition to Adding License Automatically and Adding License Manually please read section Class Libraries Support.
    licensing scheme - class libraries with license
    licensing scheme - ASP.NET direct These are two modes of accessing dotConnect for PostgreSQL within ASP.NET application. In addition to Adding License Automatically and Adding License Manually please read section Licensing ASP.NET Applications.
    licensing scheme - ASP.NET with separate file
    licensing scheme - provider installed Some applications that have no licensing information embedded, and use DbProviderFactory to operate dotConnect for PostgreSQL, require the product installed on the computer. Refer to section DbProviderFactory Notes for more information.

    Licensing .NET Standard (.NET Core) Projects

    .NET Standard compatible assemblies of the dotConnect for PostgreSQL use a different licensing mechanism. For .NET Standard (.NET Core) projects you must add the license key either as a connection string parameter or as a file to the C:\ProgramData\Devart\dotConnect\License\ folder. For more information read the Licensing .NET Standard (.NET Core) Projects topic.

    Adding License Automatically

    License is automatically added to project when you drop a PgSqlConnection component from Toolbox onto a form designer.

    Under .NET Compact Framework, in the moment of compilation license information is automatically added if the dotConnect for PostgreSQL addin for Visual Studio is running.

    Adding License Manually

    In some cases you have to manually add license. It is necessary for console applications, class libraries, and existing projects initially built with dotConnect for PostgreSQL version that did not use component licensing, that is, 2.40 and older. In this case perform the following steps:

    If IDE fails to compile the license automatically, you can do it yourself as described in section Compiling License Manually.

    Class Libraries Support

    In case where it is impossible to put the license information straight to executable file, dotConnect for PostgreSQL allows you to create class libraries that can be used with certain executable files. To do this perform the following steps:

    1. Create and setup file named licenses.licx as described above.
    2. Create a text file named licenses.config and place it next to licenses.licx.
    3. In this file enumerate names of executable files that will work with the library, every file name on separate line, for example:

      MyApplication.exe
      MyAnotherApp.exe
      ExtraTool.exe

    You do not have to add the file licenses.config to project.

    Licensing a library without specifying the executables that will use it is possible by agreement with Devart. For details on this, please mail to [email protected] or [email protected].

    Licensing Web Projects

    There are two types of web projects depending on the type of licensing.

    1. First, Web Application Project (Web Forms, MVC, Web API, etc.) are compiled entirely, so that web server does not perform any compilation on demand. In this case licensing web applications is same as licensing common Class Library applications.
    2. Second, there are Web Site Projects, when source files are uploaded to server, where they are compiled on user request. In this case you should deploy a special assembly App_Licenses.dll to the Bin directory of your site for the Web Site projects. To create this assembly, right-click the licenses.licx file in the Solution Explorer view and then click Build Runtime Licenses. The required assembly will be created automatically. Note that the corresponding shortcut menu command is available when the licenses.licx file is located in the root folder of the site.

    Licensing Compact Framework Projects

    For .NET Compact Framework the Visual Studio add-in automatically embeds all required information into every assembly that uses Devart.Data.PostgreSql.dll library. Class libraries are supported automatically.

    If the license fails to be added to a project, you can add and compile it manually. Note that there is no license compiler from Microsoft for .NET Compact Framework. You can request the compiler from Devart support team.

    There is a known problem with the .NET Compact Framework. A "License not found" exception can be thrown by PgSqlDataAdapter.Fill method in case when PgSqlConnection had never been opened. To avoid the problem just open (or open and close) any connection before calling the PgSqlDataAdapter.Fill method.

    DbProviderFactory Notes

    Applications that call dotConnect for PostgreSQL through DbProviderFactory require registration in DbProviderFactory. This registration can be performed either by launching installer of dotConnect for PostgreSQL with the Minimal install type (the licenses.licx file is not required in this case), or manually as it is described in the Deployment topic. DbProviderFactory support allows using dotConnect for PostgreSQL in SQL Server 2008/2012 Business Intelligence Solutions.

    Compiling License Manually

    The license resource cannot be compiled automatically when your project does not have reference to Devart.Data.PostgreSql.dll or dotConnect for PostgreSQL is not installed on your build server. This section describes how to compile the required resource manually.

    Generate licensing resource file using following command line:
    "%Compiler Path%\lc.exe" /target:MyApplication.exe /complist:licenses.licx /i:"%Assembly Path%\Devart.Data.PostgreSql.dll"
    Where

    Substitute these arguments with actual values. If the license compiler fails with an error, try adding full assembly specification to licenses.licx file, for example:
    Devart.Data.PostgreSql.PgSqlConnection, Devart.Data.PostgreSql, Version=7.1.26.0, Culture=neutral, PublicKeyToken=09af7300eec23701

    License compiler will generate 'MyApplication.exe.licenses' resource file. You should add this file to your project as an embedded resource. Note that you should not add licenses.licx to the project because the *.licenses file already includes all the necessary license information.

    If the default namespace of your project is not an empty string, it must be the same as the target assembly name (in this case - 'MyApplication'). IDE adds the default namespace to the resource name when building application, so you have to rename 'MyApplication.exe.licenses' to 'exe.licenses' before adding it to project. If the default namespace of your project is not set (is an empty string) you do not have to rename the resource file before adding it to project.

    You can also generate the license resource manually for the class library assembly (*.dll) in the same way. Just place licenses.config in the folder with your licenses.licx (and change /target:MyApplication.exe to /target:YourClassLibraryName.dll).

    Licensing Mono Projects

    Since automatic license generation and embedding is not possible with Mono you have to add and compile license manually as described above.

    Troubleshooting

    When something's wrong with license information you get one of the following exceptions on connecting to server:

    Exception text Possible reasons and what to do

    License not found...

    This generally indicates that license information could not be found, or you try to apply it in some way that does not suit the kind of application. For example:

    • File licenses.licx, required for dotConnect for PostgreSQL to function properly, could not be found.
    • File licenses.licx is not added as embedded resource.
    • File App_Licenses.dll not found in ASP.NET 2.0 applications.

    To fix the problem determine type of your application and read corresponding section in this topic.

    This exception can be thrown by PgSqlDataAdapter.Fill method, in case when PgSqlConnection had never been opened. To avoid the problem just open (or open and close) any connection before calling the PgSqlDataAdapter.Fill method.

    License not valid...

    This means that license information was found but it is incorrect. It usually happens in the following cases:

    1. The project was earlier compiled with old or trial version of dotConnect for PostgreSQL.
    2. File licenses.config used by a class library does not refer to launched executable.
    3. The App_Licenses.dll belongs to other application or needs to be recompiled.
    4. Something's wrong with the operating system or installation of dotConnect for PostgreSQL.
    5. You are building your project on a computer with no dotConnect for PostgreSQL installed (for example, it is not installed on your build server), and the compiled license resource is not added to the project.

    If you encounter one of these problems, do the following (the numbers of actions correspond to the numbers of the problems in the above list):

    1. Delete all files from the bin and obj folders and rebuild the project.
    2. Specify the executable in the licenses.config file.
    3. Rebuild App_Licenses.dll for the current application.
    4. Perform the following steps:
      1. uninstall dotConnect for PostgreSQL;
      2. remove all Devart.* and policy.*.Devart.* files from the GAC;
      3. clear the Program Files\Devart\dotConnect and Program Files\Common Files\Devart\dotConnect folders;
      4. re-install dotConnect for PostgreSQL.
    5. There are two ways to solve the problem:
      1. Install dotConnect for PostgreSQL on the computer where you build your project.
      2. Compile the license resource (*.licx file) on a computer, where dotConnect for PostgreSQL is installed, and then add the result file (*.licenses) to your project as an embedded resource. After this you can build your project on a computer with no dotConnect for PostgreSQL installed.

    If this does not help, send a small compiled binary with sources to our support address, so we can investigate the problem in more details.

    Sorry, your trial period has expired...

    This exception indicates that you used trial version of dotConnect for PostgreSQL, and the 30 days trial period is expired. To continue using dotConnect for PostgreSQL register it or uninstall from your machine.

    You can also see this message if the application was compiled with registered version of dotConnect for PostgreSQL, but deployed with trial assembly Devart.Data.PostgreSql.dll. If this is the case, replace old files with latest assemblies.