The Problem
I was working on a system utilising .NET 4.x and Sybase. This combination is not supported by Entity Framework so NHibernate was used.
It was planned to migrate the project to .NET Core, however a number of issues were encountered ustilising NHibernate.
Much investigation was performed, espcially using Resharper to disassemble the Sybase driver
The solution is shown below. Voila, you can use .NET Core and NHibernate and Sybase.
Solution Attempt Number 1
Code
- Create WebAPI project on DotNet Core 3.1
- Add references to NHibernate 5.2.7
Errors

Discussion
It appears that the NHibernate code cannot find the the Sybase ASE driver Sybase.ADONet2.AseClient installed as part of the nuget package
Solution Attempt Number 2
Code
As per Verrsion 1 but with
- NHibernate 5.2.7 Source code downloaded and .csproj added to solution and references instead of NHibernate nuget package (so can step through code)
- Reference added to Sysbase DLLs

Errors

Discussion
An exception is thrown in the Sybase.AdoNet2.ASeClient.dll in the constructor which calls LoadLibraries():
NB Disassembly of the driver done by ReSharper


The error is thrown at the line 252 on the Directory.GetAccessControl method – this is not supported in .Net Core:
https://stackoverflow.com/questions/41584932/support-for-file-security-in-net-core

The “workaround” suggested does not appear to work within the context of the Driver (not known why but driver might run in a restricted execution context). This article also discusses the driver error and that some System.IO methods have been removed in dotnetcore.
The Real Solution
Code
- Add AdoNetCore.AseClient nuget package – this is a 3rd party Sybase ASE driver
- Reference NHibernate nuget version 5.2.7
- Add Driver classes as below

These files are “driver” classes customised to use the AdoNetCore.AseClient driver. These are “copies” of the equivalent files in the NHibernate source code with the following modifications



The above specification for connection.driver_class is necessary as “full assembly specification” giving assembly name and class name otherwise NHibernate doesn’t know in which DLL to “looK” for the class.
The CustomDialect class was changed to reference these files:

Discussion
he connection.driver_class specification in SybaseASECoreDialect was the only “tricky” thing to “get right”. In the NHibernate “virgin” SysbaseASE15Dialect only specifies the “Driver” class name for the connection.driver_class

The NHibernate can “find” Nhibernate.Driver.SybaseAseClientDriver as it is contained within the NHibernate DLL. Using the custom classes it is necessary to specify the “full name” as the code is in separate assembly
