I have an issue that I'm having trouble debugging. I'm looking for suggestions on how to track this issue down. Here is my interop definition:
[DispId(1610743816)]
[MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)]
public virtual void GetOptions(
[MarshalAs(UnmanagedType.SafeArray, SafeArraySubType = VarEnum.VT_BSTR), In] ref Array OptionNames,
[MarshalAs(UnmanagedType.SafeArray, SafeArraySubType = VarEnum.VT_RECORD)] out Array Types,
[MarshalAs(UnmanagedType.SafeArray, SafeArraySubType = VarEnum.VT_BOOL)] out Array IsPortable,
[MarshalAs(UnmanagedType.SafeArray, SafeArraySubType = VarEnum.VT_BOOL)] out Array IsStartupOnly,
[MarshalAs(UnmanagedType.SafeArray, SafeArraySubType = VarEnum.VT_BSTR)] out Array Values,
[MarshalAs(UnmanagedType.SafeArray, SafeArraySubType = VarEnum.VT_I4)] out Array ErrorIndices,
[MarshalAs(UnmanagedType.SafeArray, SafeArraySubType = VarEnum.VT_RECORD)] out Array ErrorCodes,
[MarshalAs(UnmanagedType.SafeArray, SafeArraySubType = VarEnum.VT_BSTR)] out Array ErrorMsgs);
Here's the call:
Array arrOptionNames;
arrOptionNames = new String[] { "USER" };
System.Array arrTypes;
System.Array arrIsPortable;
System.Array arrIsStartupOnly;
System.Array arrValues;
System.Array arrErrorIndices;
System.Array arrErrorCodes;
System.Array arrErrorMsgs;
opServ.GetOptions(
ref arrOptionNames,
out arrTypes,
out arrIsPortable,
out arrIsStartupOnly,
out arrValues,
out arrErrorIndices,
out arrErrorCodes,
out arrErrorMsgs);
Here is the error and stack trace
An Exception Was Encountered - Details Below
Source: mscorlib
Description: Specified array was not of the expected type.
Stack Trace:
at System.StubHelpers.MngdSafeArrayMarshaler.ConvertSpaceToManaged(IntPtr pMarshalState, Object& pManagedHome, IntPtr pNativeHome)
at ABC.OptionService.GetOptions(Array& OptionNames, Array& Types, Array& IsPortable, Array& IsStartupOnly, Array& Values, Array& ErrorIndices, Array& ErrorCodes, Array& ErrorMsgs)
at ABC.Library.ServerTests.SASWorkspaceServerTest.TestServer() in c:\v940m5\ItconfigDotNet\itconfig.library\servertests\ServerTest.cs:line 218
So the StubHelper.MngdSafeArrayMarshaler.ConvertSpaceToManaged has decided that one of my System.Array's (SafeArrays) is of the wrong type. Since there is only one array initialized and it appears to be of the correct type I'm puzzled. Anyone have any ideas about what is going on, or how to debug deeper (ConvertSpaceToManaged appears to be unmanaged).