What happens between the .NET and COM interaction layer?

I am using COM in my C # .NET project.
However, one of the methods that I call does not work as expected.
Therefore, I am interested to know what happens between my .NET code, the Interop layer and COM.
I know what tlbimp.execreates the metadata wrapper for the COM component, and I see these generated methods in the object browser.
Can I see / debug what happens when one of these wrapper methods is called?

I pass the array to the method below and expect this array to be filled, however the array is not filled. I call the following tlbimp.exegenerated method with unexpected results:

int GetTags(System.Array buffer)
    Member of CServer.IUser

IDL Method:

[id(0x000000d5)]
HRESULT GetTags(
                [in] SAFEARRAY(long) buffer, 
                [out, retval] long* retval);  

.NET code calling this method:

Array tagsArray = Array.CreateInstance(typeof(int), tagsLength);
userWrapper.GetTags(tagsArray);

COM, , . , , , Array , .
, - , COM-.
, , GetTags().

.

"if you are not satisified with the COM Interop marshaller, you can "override" just about every aspect of it through the very large and useful System::Runtime::InteropServices namespace"

?

EDIT: Delphi script,

procedure TComTestForm.TestUserBtnClick(Sender: TObject);
var
  nCnt :integer;
  User :IUser;
  Persona :IUserPersona;
  ArrayBounds :TSafeArrayBound;
  ArrayData :Pointer;
  TagList :PSafeArray;
  nSize :integer;
begin
  User := Session.GetUser;

  ArrayBounds.lLbound   := 0;
  ArrayBounds.cElements := 0;

  TagList := SafeArrayCreate( varInteger, 1, ArrayBounds );
  User.GetTags( TagList );
  if SafeArrayAccessData( TagList, ArrayData ) = S_OK then
    begin
      nSize := TagList.rgsabound[0].cElements;
      OutLine( '----Available Tags, ' + IntToStr(nSize) + ' tags' );
  for nCnt := 0 to nSize - 1 do
    begin
      OutLine( IntToStr( IntegerArray(ArrayData)[nCnt] ) );
    end;
  OutLine( '----');

  SafeArrayUnAccessData( TagList );
  SafeArrayDestroy( TagList );
    end;

end;
+3
2

: , , GetTags ( COM-). , [in].

COM- , [in, out] (SAFEARRAY *).


. , -, COM- .NET COM- .NET.

CCW (com callable wrapper) .NET- COM SafeArray. , , , . , - ? ?


, , COM-interop SAFEARRAY .

, , , .NET COM SAFEARRAY object, object Array.

+2

, ...

Delphi , , , GetTags SAFEARRAY. COM in-process, .NET , "", , Delphi.

, , :

  • API Ole Automation SAFEARRAY P/Invoke SAFEARRAY pData​​li >
  • GetTags SAFEARRAY
  • , ...
  • API Win32 SAFEARRAY

, COM- , - , .

+1

All Articles