error when call the unmanaged resouce functions from c#.net core dll into vb.netcore windows application
Hi Team,
I got Issues when i call the unmanaged resources functions from c#.net core dll into vb.netcore windows application and automatically stops the execution of program when hit that function
Please below is my code
Dll Unmanaged function
--------------------------------------
[UnmanagedCallersOnlyAttribute]
public static void OpenGrpcConnectionNE(IntPtr ptrAddress)
{
try
{
string strAddress = Marshal.PtrToStringAnsi(ptrAddress);
channel = GrpcChannel.ForAddress(strAddress);
}
catch (Exception ex)
{
WriteLog("ExceptionLog.txt", "OpenGrpcConnectionNE: " + ex.Message);
}
}
vb.netcore windows code below to call dll
-------------------------------------------------------------
<DllImport("ClassLibNE.dll")>
Private Shared Sub OpenGrpcConnectionNE(ByVal ptrAddress As IntPtr)
End Sub
Private Sub btnSend_Click(sender As Object, e As EventArgs) Handles btnSend.Click
Try
If String.IsNullOrEmpty(txtAddress.Text.Trim()) Then
MessageBox.Show("Please enter address")
Else
Dim strRequest As String = String.Format("CassDensity={0},CassId={1},EmpId={2},ExtProdId={3},JulianDate={4},LotId={5},Motherlot={6},ProdId={7},QuantityIn={8}, QuantityOut={9},Sah={10},SputId={11},SputId2={12},TestcellId={13},TestcellOper={14},TestcellTime={15}", txtCassDensity.Text.Trim(), txtContainerNumber.Text.Trim(), txtEmployeeID.Text.Trim(), txtExtProduct.Text.Trim(), txtJulianDate.Text.Trim(), txtLotNumber.Text.Trim(), txtMotherLot.Text.Trim(), txtProduct.Text.Trim(), txtQuantityIn.Text.Trim(), txtQuantityOut.Text.Trim(), txtSAH.Text.Trim(), txtSputterResource.Text.Trim(), txtFlexiSputter.Text.Trim(), txtTestcellResource.Text.Trim(), txtOperation.Text.Trim(), txtTestcellTime.Text.Trim())
Dim ptrAddress As IntPtr = Marshal.StringToHGlobalAnsi(txtAddress.Text.Trim())
Dim ptrRequest As IntPtr = Marshal.StringToHGlobalAnsi(strRequest)
'Dim cls As Class1 = New Class1
OpenGrpcConnectionNE(ptrAddress)
Dim ptrResponse As IntPtr = LotStatusInquiryNE(ptrRequest)
Dim strResponse As String = Marshal.PtrToStringAnsi(ptrResponse)
End If
End If
Catch ex As Exception
' Show the exception's message.
MessageBox.Show(ex.Message)
End Try
End Sub