0

I have to call VM32VBWRAP.dll from c#. It is a library for manage pvcs from code. I am able for calling all methods which don't have any ref parameter. But I can't call methods with ref parameters.

I always get this error:

"Attempted to read or write protected memory. This is often an indication that other memory is corrupt." at System.StubHelpers.MngdNativeArrayMarshaler.ConvertContentsToManaged(IntPtr pMarshalState, Object& pManagedHome, IntPtr pNativeHome) at LibraryPanello.SourceControl.Pvcs.PvcsGetLockInfoVB(Int32 archiveType, String pathAndFileNameServer, String pathAndFileNameLocal, String usernameInPVCS, Byte[]& version, Byte[]& versionNew, Byte[]& usernameOutPVCS, Int16 info, Byte flag)

My declaration is:

[DllImport("VM32VBWRAP.dll", CharSet = CharSet.Ansi, SetLastError = true, 
           EntryPoint = "_wPvcsGetLockInfoVB@36")] 
static extern int PvcsGetLockInfoVB( 
    int archiveType, string pathAndFileNameServer, 
    string pathAndFileNameLocal, string usernameInPVCS,     
    [MarshalAs(UnmanagedType.LPArray, SizeConst = 64)] ref byte[] version, 
    [MarshalAs(UnmanagedType.LPArray, SizeConst = 64)] ref byte[] versionNew,  
    [MarshalAs(UnmanagedType.LPArray, SizeConst = 64)] ref byte[] usernameOutPVCS, 
   short info, byte flag );

Any idea????

Joachim Isaksson
  • 176,943
  • 25
  • 281
  • 294
Alex
  • 1
  • 1
  • No idea at all, but are you missing the ref keyword when calling the dll method? I can´t see it in the errormessage. – nabuchodonossor Aug 02 '13 at 09:52
  • Since I'm not 100% clear from the signature, how would the method be called from native code? Passing buffers in that are filled with the data, or getting buffers passed out that are allocated by the method? – Joachim Isaksson Aug 02 '13 at 10:08
  • Hello.. i am facing the same problem.. any idea? – Tithi Patel Apr 23 '14 at 08:22

0 Answers0