What is this error (process 16500) exited with code -1073740940. ?

VKSB 236 Reputation points
2020-12-08T11:59:07.78+00:00

Hi,

When I build my small Visual Basic Console program I get this message on the console;

"
H:\My Program Projects MS VS 2019 Community\Swe_Version Function Testing\bin\Debug\netcoreapp3.1\Swe_Version Function Testing.exe (process 16500) exited with code -1073740940."

What does this mean?

Please let me know how to rectify it.

Thanks
VKSBK

.NET CLI
.NET CLI
A cross-platform toolchain for developing, building, running, and publishing .NET applications.
326 questions
VB
VB
An object-oriented programming language developed by Microsoft that is implemented on the .NET Framework. Previously known as Visual Basic .NET.
2,644 questions
0 comments No comments
{count} votes

Accepted answer
  1. RLWA32 42,551 Reputation points
    2020-12-09T00:20:52.947+00:00

    I suspect that even when you tried to use StringBuilder that you declared the function as returning a String. This is a problem. The char* pointer that the unmanaged function _swe_version@4 returns will not be properly marshaled to a managed string and this is a source of the heap corruption error.

    This will fail -

        Public Declare Function swe_version Lib "swedll32.dll" Alias "_swe_version@4" (ByVal strVersion As StringBuilder) As String  
    

    This will succeed -

        Public Declare Function swe_version Lib "swedll32.dll" Alias "_swe_version@4" (ByVal strVersion As StringBuilder) As IntPtr  
    

    This will succeed -

        Public Declare Sub swe_version Lib "swedll32.dll" Alias "_swe_version@4" (ByVal strVersion As StringBuilder)  
      
    
    0 comments No comments

13 additional answers

Sort by: Most helpful
  1. VKSB 236 Reputation points
    2020-12-09T19:33:38.35+00:00

    Dear RLWA32,

    That is much better & easier to understand. Thanks.

    Thanks
    Kind regards
    VKSBK

    0 comments No comments