Hi Team,
I got Issues when i call the unmanaged resources functions from c#.net core dll into vb.net core windows application and automatically stops the execution of program when hit that function
Please below is my code
Dll Unmanaged function
using System; using System.IO; using System.Reflection; using System.Runtime.InteropServices; using System.Text;
namespace TestLibrary1 { public class Class1 { [UnmanagedCallersOnlyAttribute] public static IntPtr AddNE(IntPtr a) { try { IntPtr add = a;
return add; } catch (Exception ex) { Console.WriteLine("Exception: " + ex.Message); } return (IntPtr)0; } } }
vb.netcore windows code below to call dll
Imports System.Runtime.InteropServices Imports Google.Apis.Calendar.v3.Data
Public Class Form1 Private Const DllName As String = "TestLibrary1NE.dll"
<DllImport(DllName)> Private Shared Function AddNE(ByVal a As IntPtr) As IntPtr End Function Private Sub btnSend_Click(sender As Object, e As EventArgs) Handles btnSend.Click Try Dim ptrAddress As IntPtr = Marshal.StringToHGlobalAnsi(txtAddress.Text.Trim()) Dim ptrResponse As IntPtr = AddNE(ptrAddress) Dim strResponse As String = Marshal.PtrToStringAnsi(ptrResponse) MessageBox.Show(strResponse)
Catch ex As EntryPointNotFoundException Console.WriteLine(e.ToString()) End Try End End Sub End Class
but here when hit the dll function from vb.netcore windows application,suddenly execution stops automatically
may i know the what is the solution to fix this and how to find out the error here
Thanks,
Raj