Hostpolicy requirement

Feature:

dotnet MyApp.dll
A fatal error was encountered. The library 'libhostpolicy.so' required to execute the application was not found in '/home/sampleuser/Documents/Tests/netcoreapp/MyApp/Result/'.
Failed to run as a self-contained app. If this should be a framework-dependent app, add the /home/sampleuser/Documents/Tests/netcoreapp/MyApp/Result/MyApp.runtimeconfig.json file specifying the appropriate framework.

Solution:

It is necessary to copy the MyApp.runtimeconfig.json file from the folder with the source assembly to the folder with the protected assembly (example path /home/sampleuser/Documents/Tests/netcoreapp/MyApp/Result/).

System.DllNotFoundException

Feature:

Unhandled exception. System.TypeInitializationException: The type initializer for '<Module>' threw an exception.
 ---> System.DllNotFoundException: Unable to load shared library 'CodeStorage64.dll' or one of its dependencies. In order to help diagnose loading problems, consider setting the LD_DEBUG environment variable: libCodeStorage64.dll: cannot open shared object file: No such file or directory
   at Templates.CommonTemplate.Į(IntPtr Ǩ, IntPtr Ǩ)
   at Templates.CommonTemplate.į(IntPtr Ǩ, IntPtr Ǩ)
   at Templates.CommonTemplate.ĭ(Int32 Ǩ, Int32 Ǩ)
   at .cctor()
   --- End of inner exception stack trace ---
Aborted (core dumped)

Solution:

  1. Make sure that the CodeStorage64.so file is in the same folder as the protected assembly being run.
  2. Make sure that the program is run with LD_LIBRARY_PATH, which stores the path to the folder with the protected assembly being run, i.e. instead of dotnet MyApp.dll, it should be run as LD_LIBRARY_PATH=. dotnet MyApp.dll.
  3. It is necessary to check the user access rights (read, write, run) and the owner user;  change them or try to run as the root user if necessary.

Connect failed

Feature:

[2021/08/09 08:40:52:6790] N: Connect failed errno=111

Solution:

  1. Make sure grdcontrol is running. It must be run as root (sudo ./grdcontrol).
  2. Make sure the grdcontrol.properties configuration file is nearby.

Unhandled exception. System.NullReferenceException: Object reference not set to an instance of an object

A typical error during .NET application protection without using the Forward exceptions option.

Reason:

LD_LIBRARY_PATH=. is missing when running as dotnet ./SampleDotNetCoreApp.dll.

Feature:

Without obfuscation
at SampleDotNetCoreApp.Program.Main(String[] args)
With obfuscation
at i.i(String[] i)

Solution:

LD_LIBRARY_PATH=. should be set for .NET Core and .NET 5+ as it uses the dlopen() function internally.


  • No labels