I am converting a VB6 app to VS2013 VB.net.

In my VB6 app I have the following:

Private Declare Function vbInit Lib "MyTest.dll" ( _
ByVal myRegRootPath As String, _
ByVal myPath As String, _
ByVal myClassPath As String, _
ByVal myStorePath As String, _
ByVal UndoBuff As Long) As Long

Which works just fine in the VB6 app.

Using this function in VB.net I get the following error :

An unhandled exception of type 'System.AccessViolationException' occurred in My_test.exe
Additional information: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.

I have tried changing the call as follows:

<DllImport("MyTest.dll", CharSet:=CharSet.Ansi)> _
Public Function vbInit(<MarshalAs(UnmanagedType.LPStr)> ByVal myRegRootPath As String, _
<MarshalAs(UnmanagedType.LPStr)> ByVal myPath As String, _
<MarshalAs(UnmanagedType.LPStr)> ByVal myClassPath As String, _
<MarshalAs(UnmanagedType.LPStr)> ByVal myStorePath As String, _
ByVal UndoBuff As Integer) As Integer

I do know that the dll was created in C++ vs2008 and it is unmanaged and that the strings are Multibyte CHarset.

Is using the DLLImport the proper thing to do? If so why do I get the error using the above DLLImport? Am I using the wrong UnmanagedTYpe?

ANy light anyone can shine on this error is greatly appreciated.