迁移到VS2010后出现奇怪的IDL错误
这是我们在 VS2008 下成功使用的一个非常简单的 IDL 接口(为简洁起见,缩短了参数列表):
interface Mailer
{
string findNode( [in] string requestedNode );
unsigned short addMessage( [in] string msg, [in] unsigned short kind );
};
我们正在将解决方案迁移到 VS2010 SP1。现在我们遇到了以下构建错误:
M.idl(3): error MIDL2025: syntax error : expecting a type specification near "string"
使用 VS2008 SP1,这总是像魅力一样工作 请注意,我已经将 in
替换为 [in]
。正当我摸不着头脑的时候,我发现MIDL 2010也不喜欢in
,但对[in]
却只字不提。
请注意,接受unsigned short
(通过反转接口的 2 个方法观察到)。
怎么会?如何让 MIDL 再次理解 string
?
TIA。
Here's a very simple IDL interface that we've used successfully under VS2008 (arguments list shortened for brevity):
interface Mailer
{
string findNode( [in] string requestedNode );
unsigned short addMessage( [in] string msg, [in] unsigned short kind );
};
We're migrating the solution to VS2010 SP1. Now we have the following build error:
M.idl(3): error MIDL2025: syntax error : expecting a type specification near "string"
This always worked like a charm using VS2008 SP1
Note that I already replaced in
by [in]
. While scratching my head, I discovered that MIDL 2010 also dislikes in
but don't say anything about [in]
.
Note that unsigned short
is accepted (as observed by inverting the 2 methods of the interface).
How come? How can I make MIDL understand string
again ?
TIA.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
看起来编译器不知道类型“string”,也许您忘记在项目中包含一些引用,或者它的位置在 VS2010 中更改等。仔细检查包含、引用等。
PS这有意义吗?
Looks like compiler doesn't know about type 'string', maybe you forgot to include some reference in project, or it's location changed in VS2010, etc. Double check for includes, references and a like.
P.S. Does that makes sense?
对于从 C# 公开,这样:
我看到您可能是指从 C++ 公开它:
For exposing from C# ,this:
I saw that you possibly mean exposing it from C++:
看来 IDL 文件虽然存在于项目中,但根本没有使用。 VS2008 默默地忽略它(就像它对未引用的 .h 文件所做的那样)。
由于某种原因,VS2010 尝试编译它,即使它没有在其他地方引用。由于内容完全有问题(字符串确实不是本机 IDL 类型,而是最好的属性),所以我现在遇到了错误。
解决方案:从项目中排除文件!
It appears that the IDL file, although present in the project, isn't used at all. VS2008 silently ignored it (as it would do for an unreferenced .h file).
For some reason, VS2010 tries to compile it even if it's not referenced anywhere else. And since the contents is totally buggy (string is indeed not a native IDL type but an attribute as best), I now have errors.
Solution: Exclude file from project!