Need help working from home with your Bentley software? We're here to help - click here

Licensing error with Waterobjects.NET project due to Licensing changes

Product(s): WaterCAD, WaterGEMS, HAMMER, StormCAD, SewerCAD, SewerGEMS, CivilStorm, PondPack
Version(s): Connect Edition Update 2
Area: Licensing

Problem

While using WaterObjects.NET with CONNECT Edition Update 2 or greater of OpenFlows products, an error occurs due to the new Subscription Entitlement Service (formerly known as CONNECT licensing) used to license the product (versus SELECTserver licensing in previous versions).

How can a Waterobjects.NET project be corrected to use Subscription Entitlement Service, to acquire a license?

One possible symptom of this includes:

An unhandled exception of type 'System.IO.FileNotFoundException' occurred in Unknown Module. The specified module could not be found. (Exception from HRESULT: 0x8007007E)

Solution

The API for the License object has changed, to support Subscription Entitlement Service Licensing.

1) First, you will need to copy the “Bentley.entliclib.dll” and "Bentley.Licensing.dll" files from the WaterGEMS installation folder into your output folder. These DLL files cannot be referenced directly. A post-build event is the easiest way to do this automatically. For example:

xcopy "C:\Program Files (x86)\Bentley\WaterGEMS\x64\bentley.entliclib.dll" $(TargetDir) /q /y /r /d
xcopy "C:\Program Files (x86)\Bentley\WaterGEMS\x64\Haestad.Licensing.dll" $(TargetDir) /q /y /r /d

Note that the root of the install folder (default “C:\Program Files (x86)\Bentley\WaterGEMS”) is the x86 copy. The x64 copy is in the x64 folder. Ensure that you copy the correct version based on what platform is being built (x86 and x64). If you have the platform set to “Any CPU” then it will be based on the version of Windows; either 32-bit (x86) or 64-bit (x64).

2) Second, your project needs to reference Haestad.LicensingFacade.dll and Haestad.Support.dll.  If you are building x64, make sure you reference Haestad.LicensingFacade.dll from the x64 folder of your WaterGEMS installation (the root of the installation is x86).

3) Lastly, use the following code to configure your project to use the new licensing.

// Create the ProductRelease object
ProductRelease aproduct = new ProductRelease(ProductId.Bentley_WaterGEMS, "10.02.00.43");

// Get the license object for the product.
License license = License.Default(aproduct, IntPtr.Zero, null);

// Initialize internals of the license.
license.Initialize();

// Start the license
license.StartDesktop();

license.StopDesktop();
license.Dispose();
license = null;
// Note:  the second parameter of Default is the owner window handle.  If you have access to
// a System.Windows.Forms.Form object, we would recommend passing in Form.Handle where Form
// represents a System.Windows.Forms.Form.  Handle is a property on the Form object which is
// an IntPtr.  This will allow any messages from the license API to be displayed.

An updated SDK is not yet available as of May 13th, 2019.

See Also

WaterObjects.NET - Extending the capabilities of your OpenFlows product 

WaterObjects.NET: Change in Haestad.LicensingFacade at 10.02.00.43? 

Recommended
Related