随笔 - 64, 文章 - 11, 评论 - 12, 引用 - 0
数据加载中……

2014-7<上>疑问

如何调试COM DLL    
      在“解决方案资源管理器”中,右击组件项目并单击快捷菜单上的“属性”。<项目名称>“属性页”对话框中,打开“配置属性”文件夹并选定“调试”类别。在“命令”框中,键入如下内容:dllhost.exe  在“命令参数”框中,键入参数 /ProcessID,继之以应用程序 ID(library XXX)上的GUID。例如:/ProcessID:{3D14228C-FBE1-11D0-995D-0C04FD919C1} 单击“确定”。这样设置后就可以调试了。 如果客户端是C#,再设置客户端项目调试选项中可以调试非托管代码。 总是出现"char * __stdcall _com_util::ConvertBSTRToString的错误
只要在某个文件中添加对comdef.h的包含就可以,这个头文件会链接库,仅包含comutil.h并不会链接相应的库。 7-27日:
C# .net framework4.0 传递SAFEARRAY的问题。 I am able to call a COM interface method using SAFEARRAY(BSTR) as input. If I define instead a simple (containing only some BSTR-s fields) STRUCT to pass into the COM I get "[System.ArgumentException] = {"The parameter is incorrect. (Exception from HRESULT: 0x80070057 (E_INVALIDARG))" The call to my COM server is not made because as it seems the arguments from client does not match the expected arguments on server: E_INVALIDARG Here is my declaration in IDL: typedef enum UserEntityType { User, Group, IPAddress } UserEntityType; [ uuid(4786F77E-BA5F-4806-B224-12AA8601A5B1) ] typedef struct UserEntity { UserEntityType EntityType; BSTR Value; } UserEntity; [id(9)] HRESULT SetUsers([in] SAFEARRAY(UserEntity) input); The exception is thrown at run-time when a C# 4 client calls SetUsers(). solution:The problem was in the C# client that was using the exe COM server where SetUsers([in] SAFEARRAY(UserEntity) input) was defined. In order to fix this (at least for .NET 4.0) one has to change the following property of the imported COM server: Embed Interop Types = False

posted on 2014-07-03 14:50 Robertxiao 阅读(3176) 评论(0)  编辑 收藏 引用 所属分类: 问题集锦


只有注册用户登录后才能发表评论。
网站导航: 博客园   IT新闻   BlogJava   知识库   博问   管理