简体   繁体   English

ActiveX的.NET使用者抛出TargetParameterCountException

[英].NET consumer of ActiveX throwing TargetParameterCountException

I have a .NET (3.5 w/ Dev Studio 2008) app that hosts a visual Active X (written in C++ w/ Dev Studio 2003). 我有一个.NET(3.5 w / Dev Studio 2008)应用程序,它承载一个可视的Active X(用C ++ w / Dev Studio 2003编写)。 Have access to all sources, but can't easily move the Active X control up to 2008. 可以访问所有源,但不能轻易将Active X控件移动到2008年。

This as worked fine in the past. 过去的效果很好。 Made some changes to the Active X control and now, when calling one method on the Active X, I'm getting a TargetParameterCountException 100% of the time. 对Active X控件进行了一些更改,现在,在Active X上调用一个方法时,我有100%的时间获得TargetParameterCountException。 The signature of the Active X method is: Active X方法的签名为:

LONG CMyActive::License(LPCTSTR string1, LPCTSTR string2, LONG long1, LPCTSTR string3, LPCTSTR string4);

When viewing the method in object browser of reflector, .NET sees it as: 在反射器的对象浏览器中查看该方法时,.NET会将其视为:

public virtual int License(string string1, string string2, int long1, string string3, string string4)

I renamed the parameters for demonstration purpose (boss gets twitchy about any code). 我重命名了这些参数以进行演示(老板对任何代码都有些抽搐)。 I left the method name, as it could be relevant. 我留下了方法名称,因为它可能是相关的。

There are method calls prior that work. 在此工作之前有方法调用。 I just can't seen to figure out why I'm all of a sudden getting this exception. 我只是看不出为什么我突然得到这个例外。 The HRESULT is 0x8002000e and a quick search seems to indicate that's a general one. HRESULT是0x8002000e,快速搜索似乎表明这是一个普通的结果。

Thanks to all for reading. 感谢大家的阅读。

Edit 编辑

Thanks for the pointers. 感谢您的指导。 There is some comfort in knowing others are perplexed. 知道别人感到困惑时,我感到有些安慰。 What is odd, is that this did work. 奇怪的是,这确实有效。 This behavior cropped up after a rebuild of the Active X. No interface or other IDL changes. 重建Active X后,这种现象就会出现。接口或其他IDL均未更改。 And it's on multiple machines, not just limited to one dev box or such. 它可以在多台计算机上使用,而不仅限于一个开发盒之类。

Edit 2 编辑2

For S&G's I added a new method, 对于S&G,我添加了一种新方法,

LONG CMyActive::XXXLicense(LPCTSTR string1, LPCTSTR string2, LONG long1, LPCTSTR string3, LPCTSTR string4);

Rebuilt everything and now I can call the new method... This smells like a bug either in the compiler and/or the COM interoperability layer of .NET. 重建了所有内容,现在我可以调用新方法了……在.NET的编译器和/或COM互操作性层中,这闻起来像一个错误。

The HRESULT is DISP_E_BADPARAMCOUNT (better for googling than "0x8002000e"). HRESULT是DISP_E_BADPARAMCOUNT (比“ 0x8002000e”更好的谷歌搜索)。

Seems other people have bumped into this problem: 似乎其他人遇到了这个问题:

http://www.codeguru.com/forum/showthread.php?t=96353 http://www.codeguru.com/forum/showthread.php?t=96353

http://forums.devx.com/showthread.php?t=85215 http://forums.devx.com/showthread.php?t=85215

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM