如何“使用"从Tlbimp.exe输出? [英] How to "using" output from Tlbimp.exe?

查看:128
本文介绍了如何“使用"从Tlbimp.exe输出?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了一个简单的ATL COM服务器,然后使用Tlbimp工具将其转换为托管DLL. MSDN文章"CLR Inside Out:COM Interop简介"中的示例代码显示了如何通过使用"语句在客户端软件中声明托管库.但是对于一个没有经验的程序员,似乎缺少一些信息.我的客户端软件遇到了编译器错误:"C2873:在使用声明中不能使用符号."

我相信以下是COM经验丰富的简单问题.如果有人愿意分享您的知识,将不胜感激.提前谢谢.

Q1:我的非托管COM服务器已注册.我需要注册Tlbimp生成的托管DLL吗?

问题2:如何将托管DLL引入CLR客户端软件? VS2005/C ++是我的开发环境.

问题3:在我的非托管COM服务器中,有一个成员定义为wchar_t *. TlbImp抱怨警告TI0000,说类型库导入器无法这样转换成员的签名".暂时,我评论了那个成员.但是最终,我需要知道指针类型出了什么问题?

再次感谢.

I created a simply ATL COM server and then converted it to managed DLL using Tlbimp tool. The example code in MSDN article, "CLR Inside Out: Introduction to COM Interop", shows how to declare the managed library in client software by "using" statement. But to an unexperienced programmer, there seems missing some pieces of information. My client software got compiler error: "C2873: symbol cannot be used in a using-declaration."

I believe below are easy questions to COM experienced. Would appreciate if someone out there is willing to share your knowledge. Thanks in advance.

Q1: My unmanaged COM server is registered. Do I need to register Tlbimp generated managed DLL?

Q2: How should I introduce the managed DLL to my CLR client software? VS2005/C++ is my development environment.

Q3: In my unmanaged COM server, there is a member defined as wchar_t*. TlbImp complains with a warning TI0000, saying "The type library importer could not convert the signature for the member so and so". For the time being, I commented out that member. But eventually, I need to know what''s wrong with the pointer type?

Thanks again.

推荐答案

A1:否.

A2:您应将对托管DLL的引用添加到CLR项目中.
A3:COM本身可以使用LPWSTRLPWCSTR类型; .NET Interop可以封送这些类型.显示导致TlbImp抱怨的代码.

—SA
A1: No.

A2: You should add reference to the managed DLL to your CLR project.

A3: COM itself can work with the types LPWSTR or LPWCSTR; and .NET Interop can marshal those types. Show the code which cause TlbImp complain.

—SA


这篇关于如何“使用"从Tlbimp.exe输出?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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