Marek Bar
Marek Bar

Reputation: 903

C# HASP login code

I want to try out hasp api to build my custom security behaviour but when I use code generated by Sentinel HASP ToolBox it does not work. I pasted this code from Toolbox to onLoad Form method:

HaspFeature feature = HaspFeature.Default;

string vendorCode = 
"AzIceaqfA1hX5wS+M8cGnYh5ceevUnOZIzJBbXFD6dgf3tBkb9cvUF/Tkd/iKu2fsg9wAysYKw7RMAsV" + 
"vIp4KcXle/v1RaXrLVnNBJ2H2DmrbUMOZbQUFXe698qmJsqNpLXRA367xpZ54i8kC5DTXwDhfxWTOZrB" + 
"rh5sRKHcoVLumztIQjgWh37AzmSd1bLOfUGI0xjAL9zJWO3fRaeB0NS2KlmoKaVT5Y04zZEc06waU2r6" + 
"AU2Dc4uipJqJmObqKM+tfNKAS0rZr5IudRiC7pUwnmtaHRe5fgSI8M7yvypvm+13Wm4Gwd4VnYiZvSxf" + 
"8ImN3ZOG9wEzfyMIlH2+rKPUVHI+igsqla0Wd9m7ZUR9vFotj1uYV0OzG7hX0+huN2E/IdgLDjbiapj1" + 
"e2fKHrMmGFaIvI6xzzJIQJF9GiRZ7+0jNFLKSyzX/K3JAyFrIPObfwM+y+zAgE1sWcZ1YnuBhICyRHBh" + 
"aJDKIZL8MywrEfB2yF+R3k9wFG1oN48gSLyfrfEKuB/qgNp+BeTruWUk0AwRE9XVMUuRbjpxa4YA67SK" + 
"unFEgFGgUfHBeHJTivvUl0u4Dki1UKAT973P+nXy2O0u239If/kRpNUVhMg8kpk7s8i6Arp7l/705/bL" + 
"Cx4kN5hHHSXIqkiG9tHdeNV8VYo5+72hgaCx3/uVoVLmtvxbOIvo120uTJbuLVTvT8KtsOlb3DxwUrwL" + 
"zaEMoAQAFk6Q9bNipHxfkRQER4kR7IYTMzSoW5mxh3H9O8Ge5BqVeYMEW36q9wnOYfxOLNw6yQMf8f9s" + 
"JN4KhZty02xm707S7VEfJJ1KNq7b5pP/3RjE0IKtB2gE6vAPRvRLzEohu0m7q1aUp8wAvSiqjZy7FLaT" + 
"tLEApXYvLvz6PEJdj4TegCZugj7c8bIOEqLXmloZ6EgVnjQ7/ttys7VFITB3mazzFiyQuKf4J6+b/a/Y";

Hasp hasp = new Hasp(feature);
HaspStatus status = hasp.Login(vendorCode);

if (HaspStatus.StatusOk != status)
{
    //handle error
    Application.Exit();
}

Next I inserted demo HASP HL Net key 10 to try it out. I always get error while using this code in Visual Studio sample project but when I try it in ToolBox then I receive proper answer(HASP_STATUS_OK). Certainly I included reference to hasp .net assembly and added namespace.

What is the reason, that it can't login to hasp hl key from runtime api in c#?

Upvotes: 3

Views: 6329

Answers (1)

Marek Bar
Marek Bar

Reputation: 903

I found solution. First I had to include reference to hasp_windows_demo.dll because hasp_net_windows.dll is just a wrapper lib for hasp_windows_demo.dll. Second: I used VirtualBox to test so when I plugged dongle to usb port usb virtualbox driver crashed - needed reinstall(Mac/Linux issue only).

Upvotes: 2

Related Questions