Hello duckula,
This looks like wolfSSL_new is returning NULL. One reason for that could be if no certificate/key was set in WOLFSSL_CTX and PSK is not used.
To set key and certificate use
wolfssl.CTX_use_certificate_file
wolfssl.CTX_use_PrivateKey_file
The return value for these should also be checked to make sure the file could be read.
Alternatively to set PSK use
wolfssl.CTX_use_psk_identity_hint
wolfssl.CTX_set_psk_server_callback
Another thing to be conscious of when build the C# wrapper is that it should have the same settings as what was used when building the wolfSSL library. By default the Visual Studio solution packaged with wolfSSL in wolfssl/wrapper/CSharp/ takes care of this. The preprocessor defines used or macros in user_settings.h should be used for both building wolfSSL and building the C# application.
For wolfSSLCbIOSend and wolfSSLCbIORecv you can log custom call backs to handle sending and receiving data over TCP. See wolfSSL-Example-IOCallbacks.cs for an example of this. The use of custom IO callbacks was added for users who want to use their own TCP calls without modifying the C# wrapper. This allows for a users application to be maintained more easily with future wolfSSL updates.
Regards,
Jacob