Okay. Well, I know this question has a good chance of being closed within the first 10 minutes, but I am going to ask it anyways for I have spent almost day and an half trying to find a solution. Still, I can't figure this one out. There is not much info on this on the Internet not even on the HASP (safenet) website although they have demos.
I have a HASP HL USB dongle. I try to convert their demo and test run it but for the life of me I simply can't get it to login even. It keeps raising Aladdin.HASP.HaspStatus.HaspDotNetDllBroken exception.
However, if I run the C version of their demo, it works perfectly.
Here is the Csharp version of my code:
Aladdin.HASP;
HASP myHasp = new HASP();
var thestatus = myHasp.Login(vender_code);
myHasp.Logout;
I would like to login to USB HASP and get its HaspID and the settings in its memory.
Thanks in advance,
It might be that you aren't having all dependencies for the HASP runtime. I'm packing with the app:
hasp_windows_NNNNN.dll (NNNNN = your number)
hasp_net_windows.dll
MSVCR71.DLL (added manually)
msvc runtime 80
One runtime library is required by HASP and it doesn't tell you which one unless you put it in the DEPENDS.EXE utility (you probably have you on your Visual Studio installation).
To log in (and read some bytes):
byte[] key = new byte[16];
HaspFeature feature = HaspFeature.FromFeature(4);
string vendorCode = "your vendor string, get it from your tools";
Hasp hasp = new Hasp(feature);
HaspStatus status = hasp.Login(vendorCode);
if (HaspStatus.StatusOk != status)
{
// no license to run
return false;
}
else
{
// read some memory here
HaspFile mem = hasp.GetFile(HaspFileId.ReadOnly);
mem.Read(key, 0, 16);
status = hasp.Logout();
if (HaspStatus.StatusOk != status)
{
//handle error
}
}
Hope it helps. My HASPed software works like a charm. BTW, wasn't able to put envelope around .NET app under no combination of settings.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With