是否可以调试VS2008中的COM DLL? [英] Is it possible to debug a COM dll in VS2008?

查看:202
本文介绍了是否可以调试VS2008中的COM DLL?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这可能是一个非常愚蠢的问题。

是否可以调试VS2008中没有源代码的COM DLL?



我想这样做的原因是我传递一个数组到一个COM方法,我希望这个数组被填充的方法。

但是未填充数组。所以我想进入COM方法看看发生了什么。这可能吗?



下面是我使用的代码示例:

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


$ b $ p



  [id(0x000000c9)] 
HRESULT GetBinaryData(
[in] SAFEARRAY $ b [out,retval] VARIANT_BOOL * retval);

GetBinaryData 方法是COM方法

  procedure TComTestForm.TestUserBtnClick(Sender:TObject); 
var
nCnt:integer;
用户:IUser;
角色: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到nSize - 1 do
begin
OutLine(IntToStr(IntegerArray(ArrayData)[nCnt]));
end;

OutLine('----');


$ b b

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



end;

解决方案

,是的,你可以逐步通过逐个指令的COM方法实现的代码。



然而,即使你知道程序集很好,并且明确地知道所有的处理器指令是如何工作的,这是一个很高的顺序来调试别人的代码在这种方式,除非它是一个真正的,真的很简单的方法。



如果你对汇编程序不熟悉,甚至不要考虑它,除非你准备好几周的学习曲线。



如果COM方法似乎没有按照您期望的方式工作,我将首先尝试使用非托管代码测试方法(例如C ++ ),因为你的问题可能在COM Interop编组,而不是在COM方法本身。


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);

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.

这篇关于是否可以调试VS2008中的COM DLL?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆