CryptoSys PKI Pro Manual

Using with .NET: C# and VB.NET

To use the .NET interface with C# and VB.NET (VB2010+):

  1. Copy the dotnet diCrSysPKINet.dll library file into a convenient folder (the install program puts this file by default in C:\Program Files (x86)\CryptoSysPKI\DotNet).
  2. In your application, add a reference to the library:
    1. Project > Add Reference.
    2. In the .NET tab, click on the Browse button to find and select the library file diCrSysPKINet.dll.
    3. Click on OK and the wizard will add the reference of the class library to your project.
  3. Add the line (for C#)
    using CryptoSysPKI;
    
    or (for VB.NET)
    Imports CryptoSysPKI
    

    to your code.

  4. Call the methods in the various classes. Note that the methods in the .NET interface may have different parameters and return values to the functions in the core VB6/C DLL.

Alternatively, with C#, you can just include the source code module CryptoSysPKI.cs in your project and there is no need to reference the class library DLL.

Note that you must also have the core Win32 (or X64) executable diCrPKI.dll installed on your system for the .NET interface to work. If not, it will throw an exception immediately:

Unhandled Exception: System.DllNotFoundException: 
Unable to load DLL 'diCrPKI.dll': 
The specified module could not be found. 
(Exception from HRESULT: 0x8007007E)

If you are working on a 64-bit system, Visual Studio will go looking for the 64-bit core DLL in the Windows system folder (usually C:\Windows\System32). Make sure you set the Solution Platform to be Any CPU.

The .NET class library diCrSysPKINet.dll is compiled for all platforms (Win32 and X64) and requires at least .NET 4.0 and should be upwardly compatible with all later .NET versions. This means that you must be using VS2010 or later.

All methods in the CryptoSysPKI .NET Class Library are static methods. You do not need to instantiate or dispose of any objects.

For examples, see the test code TestPKIcsharp.cs and TestPKIvbnet.vb provided in the distribution.

The file diCrSysPKINet.dll and distribution test code will be found in the DotNet sub-directory of the installation folder, typically C:\Program Files (x86)\CryptoSysPKI\DotNet (or C:\Program Files\CryptoSysPKI\DotNet on a 32-bit machine). To find the installation folder, use Start > All Programs > CryptoSysPKI > CryptoSys PKI Reference Files.

If you need to convert old VB6 code, see Converting VB6 to VB.NET.

[PREV: Using with C++ (STL)...]   [Contents]   [Index]   
   [NEXT: Combining bitwise options...]

Copyright © 2004-24 D.I. Management Services Pty Ltd. All rights reserved. Generated 2024-09-23T07:52:09Z.