This page shows how to use FirmaSAT with .NET Core (dotnetcore).
2024-09-13: This page updated from dotnet core 3.1 to 8.0.
It is similar to the instructions on how to use Using CryptoSys PKI with .NET Core.
Prerequisites | Principles | A simple test | Instructions | Full .NET Tests | Using Visual Studio Code | Contact us
diFirmaSAT2.dll
must exist in your application's
Library Search Path.
¶ We use the word "core" in our documentation to refer to the "core" of the FirmaSAT application,
the native Windows DLL file diFirmaSAT2.dll
. Don't get confused with "dotnet core".
The .NET interface library file diFirmaSatNet.dll
provided with the FirmaSAT distribution
works with both the standard .NET Framework and .NET Core. You just need to set a reference to it in your dotnetcore project file.
All the example C# source code modules provided in the distribution and elsewhere on this site works on .NET Core without alteration.
A copy of the file diFirmaSatNet.dll
is installed by default in the folder C:\Program Files (x86)\FirmaSAT
( or C:\Program Files\FirmaSAT
on a 32-bit platform).
You can refer to this directly as a "hint" in your project file: a copy will be made in the \bin
subdirectory when you first build the project.
The equivalent of an "Hello World!" program for FirmaSAT is to print the version number of the native FirmaSAT DLL
using the General.Version()
method.
Here is the code module firmasat_simple.cs
. Note the using FirmaSAT;
line.
// firmasat_simple.cs using System; using FirmaSAT; namespace firmasat_simple { class Program { static void Main(string[] args) { Console.WriteLine("Version = {0}", General.Version()); } } }Expected output (similar to):
Version = 90182If this works OK, it shows you have done things correctly and you can move on to more complicated projects.
> dotnet new console -n firmasat_simple -o firmasat_simpleThis should display:
The template "Console Application" was created successfully. ...etc. Restore succeeded.This will create a new subdirectory called
firmasat_simple
with the following structure.
\---firmasat_simple | firmasat_simple.csproj | Program.cs | \---obj project.assets.json project.nuget.cache ... etc.
cd firmasat_simple
Program.cs
to firmasat_simple.cs
and edit it to match the above code.
Or just copy the new file firmasat_simple.cs
and delete Program.cs
.
<Project Sdk="Microsoft.NET.Sdk"> <PropertyGroup> <OutputType>Exe</OutputType> <TargetFramework>netcoreapp3.1</TargetFramework> </PropertyGroup> <!-- BEGIN ADD THIS --> <ItemGroup> <Reference Include="diFirmaSatNet"> <SpecificVersion>False</SpecificVersion> <HintPath>C:\Program Files (x86)\FirmaSAT\diFirmaSatNet.dll</HintPath> </Reference> </ItemGroup> <!-- END ADD THIS --> </Project>Note we can use a hard-coded reference to
diFirmaSatNet.dll
in the HintPath because a copy will be made in our local bin directory when the project is built.
If you used a different directory when installing FirmaSAT, you will need to change the HintPath to match.
> dotnet buildIf this works OK, it should show
Build succeeded.
0 Warning(s)
0 Error(s)
> dotnet runExpected output:
Version = 107034
bin\Debug\netcoreapp3.1
.
\---firmasat_simple
| firmasat_simple.cs
| firmasat_simple.csproj
|
+---bin
| \---Debug
| \---netcoreapp8.0
| diFirmaSatNet.dll
| firmasat_simple.deps.json
| firmasat_simple.dll
| firmasat_simple.exe
| firmasat_simple.pdb
| firmasat_simple.runtimeconfig.dev.json
| firmasat_simple.runtimeconfig.json
|
which you can run directly
> .\bin\Debug\netcoreapp3.1\firmasat_simple.exe Version = 107034
The full .NET tests provided in the distribution work exactly the same as with the .NET Framework. The source code module TestFirmaSat.cs is unchanged.
The setup in dotnetcore uses similar instructions as above, but we need to add a subdirectory for the test files, and add an instruction for the starting working directory to the project file.
The test files are included in the distribution in the file FirmaSATtestfiles.zip.
dotnet new console -n TestFirmaSat -o TestFirmaSat
cd TestFirmaSat
Project.cs
with TestFirmaSat.cs.FirmaSATtestfiles
. So the file structure should now be as follows.
\---TestFirmaSat | TestFirmaSat.cs | TestFirmaSat.csproj | +---FirmaSATtestfiles | A7.xml | AAA010101AAA201501BN-base.xml | AAA010101AAA201501CT-base.xml | AAA010101AAA201501CT_new-signed.xml | AAA010101AAA201705CT.xml | ... etc. \---obj project.assets.json project.nuget.cache ... etc.
ItemGroup/Reference
as above,
plus a StartWorkingDirectory
element so the program will start in the directory with the test files
(the program assumes the test files are in its current working directory).
<Project Sdk="Microsoft.NET.Sdk"> <PropertyGroup> <OutputType>Exe</OutputType> <TargetFramework>netcoreapp3.1</TargetFramework> </PropertyGroup> <PropertyGroup> <StartWorkingDirectory>.\FirmaSATtestfiles\</StartWorkingDirectory> </PropertyGroup> <ItemGroup> <Reference Include="diFirmaSatNet"> <SpecificVersion>False</SpecificVersion> <HintPath>C:\Program Files (x86)\FirmaSAT\diFirmaSatNet.dll</HintPath> </Reference> </ItemGroup> </Project>
dotnet build
dotnet run
INTERROGATE THE CORE DIFIRMASAT DLL: Version=90182 CompileTime=May 27 2020 06:24:18 ModuleName=C:\WINDOWS\SYSTEM32\diFirmaSAT2.dll ... Current working directory is C:\DotNetCore\diFirmaSatNet\TestFirmaSat\FirmaSATtestfiles FORM THE PIPESTRING FROM AN XML FILE: Sat.MakePipeStringFromXml('cfdv33a-base.xml')= ||3.3|A|123ABC|2017-12-04T01:23:59|02|...[cut]...|| SIGN AN XML FILE: Sat.SignXml('cfdv33a-base.xml'-->'cfdv33a_new-signed.xml') returns 0 Sat.ValidateXml('cfdv33a_new-signed.xml') returns 0 ...[cut]...
(Version and compile time may vary)
You can use the free Visual Studio Code to analyse and even run your dotnetcode project.
code .
(that's the word "code" followed by a space and a dot).
code .This will open up Visual Studio Code and show all your project files in the VSCode explorer window. You can even run your project from the IDE, but you may get a lot of unnecessary warnings, etc.
To contact us or comment on this page, please send us a message.
This page first published 9 December 2019. Completely rewritten 7 July 2020. Last updated 15 August 2025.