When upgrading or deploying an application using one or more SocketTools .NET classes, an unhandled System.DllNotFoundException error occurs. A stack trace shows it is the result of a System.TypeInitializationException being thrown when the application first starts.
This error occurs when the SocketTools class is unable to dynamically load the native interop library on the system. Because SocketTools installs the 32-bit and 64-bit versions of the interop library on your development system, it is unlikely you’ll encounter this error during development. Usually it only occurs after you attempt to redistribute your application to another system.
In addition to the managed .NET assemblies which are used by your application, SocketTools also uses an interop library which provides the lower-level networking and encryption functionality used by the SocketTools classes. Although the classes themselves are platform neutral, the interop library comes in native x86 (32-bit) and x86-64 (64-bit) versions which also must be installed on the target system.
If your application targets the x86 platform, you must redistribute the 32-bit version of the SocketTools10.Interop.dll library, along with the individual .NET assemblies you’re using, such as SocketTools.FtpClient.dll or SocketTools.ImapClient.dll. If your application targets the x64 platform, you will need to redistribute the 64-bit version of the interop library.
Redistributable versions of the SocketTools .NET interop libraries can be found in:
C:\Program Files (x86)\SocketTools 10.0 .NET Edition\Redist\x86 (32-bit)
C:\Program Files (x86)\SocketTools 10.0 .NET Edition\Redist\x64 (64-bit)
To help simplify the redistribution process, we also provide MSI installer packages which you can include with your installation project and deploy on the end user’s system.
For more information, refer to our article on redistributing .NET applications.