开发者

Is it possible to debug a COM dll in VS2008?

This may be a very stupid question.

Is it possible to debug a COM dll in VS2008 for which I do not have the source code?

The reason I want to do this is I am passing an Array to a COM method and I expect this Array to be populated by the method.

However the Array is not being populated. So I want to step into the COM method to see whats happening. is this possible?

Below is an example of the code I am using:

Array binaryArray = Array.CreateInstance(typeof(sbyte), 896);
bool success = photo.GetBinaryData(binaryArray);

IDL for the GetBinaryData method:

[id(0x000000c9)]
HRESULT GetBinaryData(
                [in] SAFEARRAY(char) buffer, 
                [out, retval] VARIANT_BOOL* retval);
开发者_JS百科

The GetBinaryData method is the COM method which I would like to step into.

EDIT: Adding a Delphi test script which works

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;


In principle, yes, you can step through the code of the COM method implementation instruction-by-instruction.

However, even if you know assembly well and understand exactly how all the processor instructions work, it's a tall order to debug someone else's code in this fashion unless it's a really, really simple method.

If you are new to assembler, don't even consider it unless you're prepared to do weeks of learning curve first.

If the COM method doesn't appear to be working in the way you expected based on its documentation, I would first try to test the method using unmanaged code (e.g. C++), as your problem may be in the COM Interop marshalling rather than in the COM method itself.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜