rajreddy-1121 avatar image
0 Votes"
rajreddy-1121 asked rajreddy-1121 commented

error when call the unmanaged resouce functions from core dll into vb.netcore windows application

Hi Team,

I got Issues when i call the unmanaged resources functions from 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

public static void OpenGrpcConnectionNE(IntPtr ptrAddress)
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

Private Shared Sub OpenGrpcConnectionNE(ByVal ptrAddress As IntPtr)
End Sub

Private Sub btnSend_Click(sender As Object, e As EventArgs) Handles btnSend.Click
If String.IsNullOrEmpty(txtAddress.Text.Trim()) Then
MessageBox.Show("Please enter address")
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


             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.
End Try
End Sub

· 4
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

It is probably easier to create a Class Library in C# and reference and use it directly from VB. It is not clear why do you need IntPtr etc.

0 Votes 0 ·

That dll function should call to different clients like c++,,c# clients also.thats why we put it in common syntax

0 Votes 0 ·

What technique did you use to export the OpenGrpcConnectionNE as an unmanaged function?

0 Votes 0 ·

what do you mean by export?,That is function to open the connection in grpc server by sending ip address through parameter

0 Votes 0 ·

0 Answers