SafeNet has an application called
Sentinel RMS.
Sentinel RMS is a suite of applications that help one company license out its software.
One of my current projects requires me to use
Sentinel RMS within a Microsoft .NET framework using C#.
I had a couple of problems setting up the example solutions
SafeNet gave out, so I thought I’d document them here. There’s probably not that many people who will use
Sentinel RMS but I did run into a problem that might well be generally useful:
API call fail with message:System.BadImageFormatException: An attempt was made to load a program with an incorrect format. (Exception from HRESULT: 0x8007000B)
at SentinelRMSCore.Interface.LSAPI.VLSinitialize()
at SentinelRMSCore.RMSDKCore.VLSinitialize():VLSinitialize
API call fail with error-code:501
While the manual for
Sentinel RMS was pretty good it was all about the API’s and how to call them. The documentation was missing a
How to get started section that would describe how to set up Visual Studio. There is a brief few lines saying which version of Visual Studio are supported but that’s about it.
- Download SDK RMS 8.5.0 Windows 32 and 64-bit GA release (you can get this from your support representative)
- Download the Sentinel RMS 8.4.1 .Net Interface (you can get this from your support representative)
- Unpack and install the SDK.
- Add the following DLL folder to your PATH:
C:\Program Files (x86)\SafeNet Sentinel\Sentinel RMS Development Kit\8.5\English\MsvcDev\Lib\MSVS2008\Win32\DLL\
This will allow the C# assemblies to find the required DLLs.
- Unpack the .Net Interface.
- Navigate to
RMS 8.4.1 .NET Interface\Examples
- Create a folder called
Libraries
- Copy the contents of
RMS 8.4.1 .NET Interface\Library
into the RMS 8.4.1 .NET Interface\Examples\Libraries
folder
- Navigate to
RMS 8.4.1 .NET Interface\Examples\VisualC#\AddRemoveLicense
- Double click the solution file (.sln) to launch Visual Studio. The documentation says that only Microsoft Visual Studio 2003/2005/2008 is supported so make sure its one of those.
- When the solution loads in, right-click on the project name and select Properties.
- Under the Application tab change the Target Framework to 3.5.
- Under the Build tab change the Platform Target to x86.
- Then save, clean solution, rebuild solution and run.
I found that if you didn’t add the DLL folder to the
PATH
then I got the following error message, and in order to fix it I had to manually copy the lsapiw32.dll into the Release/Debug folder. There didn’t seem to be anywhere in visual studio that let you add extra DLL search folders because it is
rubbish.
API call fail with message:System.DllNotFoundException: Unable to load DLL ‘lsapiw32.dll’: The specified module could not be found. (Exception from HRESULT: 0x8007007E)
at SentinelRMSCore.Interface.LSAPI.VLSinitialize()
at SentinelRMSCore.RMSDKCore.VLSinitialize():VLSinitialize
API call fail with error-code:501
The other problem, which is probably more generally useful, was that of the
System.BadImageFormatException exception. This occurs when the
Common Language Runtime (CLR) tries to load an assembly that contains unmanaged code built targeting a different platform (
thanks Dave).
In my case with Sentinal, the
lsapiw32.dll
was compiled with the platform x86 for the 32-bit version of the DLL. Visual Studio defaults to building for a target platform of
Any and this discrepancy is what causes the error. Equally if I had chosen to fill the
Libraries
folder with DLLs from the
Library(x64)
folder (and the corresponding
C:\Program Files (x86)\SafeNet Sentinel\Sentinel RMS Development Kit\8.5\English\MsvcDev\Lib\MSVS2008\Win64\DLL
) instead then I would have had exactly the same problem.
Well, I do not have the Sentinel SDK at least this version, but I had it in the past so i will try to guess to solve your problem. Although it was for a C++ project, i believe that because the APIs do not initialize first that it could be a linking problem or that support on 64 bit is not that great. Of course throwing 32 bit dlls on the 64bit system won’t help.
I wonder if i can test the sdk. Is there a link for download? I need to create a C# sample for myself.