What changes when running unit tests with ReSharper's Debug?
First, I have requested the team responsible for the imported library to review their code for any problems. I'm almost positive the problem lies there.
When I "run" the unit tests (NUnit 2.5.10), I get this access violation:
System.AccessViolationException : Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
at System.StubHelpers.MngdNativeArrayMarshaler.ClearNative(IntPtr pMarshalState, IntPtr pNativeHome, Int32 cElements)
at DllImportLibrary.GetStrings(IntPtr log, String[]& stringList, UInt32& numStrings)
at MyLibrary.MyTest.Test0() in MyTest.cs: line 151
The sig:
When I "debug" the unit tests, everything succeeds. It fails as expected when debugging with Visual Studio.
Can you share anything that the ReSharper debugger changes when it runs?
... or provide any insight into why it would work with the ReSharper debugger?
at DllImportLibrary.GetStrings(IntPtr log, String[]& stringList, UInt32& numStrings)
at MyLibrary.MyTest.Test0() in MyTest.cs: line 151
The sig:
[return: MarshalAs(UnmanagedType.I1)]
[DllImport("imported.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl, SetLastError = true)]
public static extern bool GetStrings(IntPtr log,
[MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 2)] out string[] stringList,
out uint numStrings);
[DllImport("imported.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl, SetLastError = true)]
public static extern bool GetStrings(IntPtr log,
[MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 2)] out string[] stringList,
out uint numStrings);
When I "debug" the unit tests, everything succeeds. It fails as expected when debugging with Visual Studio.
Can you share anything that the ReSharper debugger changes when it runs?
... or provide any insight into why it would work with the ReSharper debugger?
Please sign in to leave a comment.
This turned out to be a bug in my code when dealing with char** return types from unmanaged code.