VB6的无与伦比C#RCW错误 [英] VB6's Nothing & C# RCW Error

查看:68
本文介绍了VB6的无与伦比C#RCW错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图通过使用通过COM互操作公开的C#编写的.NET

组件来扩展旧版VB6应用程序。一切似乎都很顺利(VB应用程序创建了.NET组件而不是

遗留VB6组件并成功调用了一些方法)直到我点击

snag。


对于VB6应用程序调用的一种方法,方法

需要2个参数(字符串值)和一个自定义接口。根据

处理,此自定义界面可能是有效对象,或者可能是

Nothing。当在实现

此接口的旧版VB6对象上调用此方法时,不会遇到任何错误。在我的

..NET组件上调用此方法时,我收到以下错误:

对象引用未设置为对象的实例(0x8000403)。 br />
我已经确定错误是由于自定义接口参数(我通过创建一个
$来确保它在VB6调试器中被捕获时可以避免这个问题b $ b实现接口的对象实例。


我的问题是,是什么导致生成的运行时可调用包装器被C#生成
失败自定义界面

为Nothing时出现0x8000403错误的请求并且,更重要的是,无论如何我可以禁用此错误

或解决问题而无需更改VB6传统

应用程序?


我希望这些信息足够详细,以便读者能够确定这是一个明显的错误是否有明显的解决方案(只是

一个我我不知道。但是,如果不是,需要一个例子,

请告诉我,我会生成一个。感谢任何帮助。


谢谢,Tyler

I am attempting to extend a legacy VB6 application by making it use a .NET
component written in C# exposed through COM interop. Everything appeared to
be going well (VB application creates the .NET component instead of the
legacy VB6 component and invokes some methods successfully) until I hit a
snag.

For one method that is being invoked by the VB6 application, the method
takes 2 parameters (string values) and a custom interface. Depending on
processing, this custom interface may be a valid object, or may be
"Nothing". When this method is invoked on a legacy VB6 object implementing
this interface, no error is experienced. When this method is invoked on my
..NET component, I get the following error:
Object reference is not set to an instance of an object (0x8000403).
I have determined that the error is due to the custom interface parameter (I
can avoid the problem when it is caught in the VB6 debugger by creating an
instance of an object that implements the interface).

My question is, what causes the runtime callable wrapper that is generated
by C# to fail the request with the 0x8000403 error when the custom interface
is "Nothing" and, more importantly, is there anyway I can disable this error
or work-around the problem without having to change the VB6 legacy
application?

I hope this information is sufficiently detailed to allow a reader to
determine whether this is an obvious error with an obvious solution (just
one that I don''t know). However, if it is not and an example is required,
please let me know and I will generate one. Any assistance is appreciated.

Thanks, Tyler

推荐答案

您好泰勒,


是否有任何一方(遗留应用程序或.NET组件)假定

第二个参数始终不为空?

你能不能发布使用参数的C#代码?


-

此致,

Dmitriy Lapshin [C#/ .NET MVP]

今天将单元测试的强大功能带到VS .NET IDE中!
http://www.x-unity.net/teststudio.aspx


" Tyler" < TY *** @ newsgroups.nospam>在消息中写道

news:eD ************** @ TK2MSFTNGP09.phx.gbl ...
Hi Tyler,

Does any of the parties (either the legacy app or the .NET component) assume
that this second parameter is always not null?
Could you post the C# code working with the parameter?

--
Sincerely,
Dmitriy Lapshin [C# / .NET MVP]
Bring the power of unit testing to the VS .NET IDE today!
http://www.x-unity.net/teststudio.aspx

"Tyler" <ty***@newsgroups.nospam> wrote in message
news:eD**************@TK2MSFTNGP09.phx.gbl...
我试图扩展一个遗留的VB6应用程序,它使用通过COM互操作公开的C#编写的.NET组件。一切都出现了好转(VB应用程序创建了.NET组件而不是传统的VB6组件并成功调用了一些方法),直到我遇到了一个
障碍。对于VB6应用程序调用的一种方法,该方法需要2个参数(字符串值)和一个自定义接口。取决于处理,该自定义界面可以是有效对象,或者可以是没有。在遗留VB6对象上调用此方法
实现此接口时,不会出现错误。在我的
.NET组件上调用此方法时,我收到以下错误:
对象引用未设置为对象的实例(0x8000403)。
我有确定该错误是由自定义接口参数引起的(我可以通过创建实现该接口的对象的实例来解决在VB6调试器中捕获的问题)。

我的问题是,当自定义
接口是时,导致C#生成的运行时可调用包装器导致0x8000403错误的请求失败的原因是什么?没什么"而且,更重要的是,无论如何,我可以禁用这个
错误
或解决问题而无需更改VB6传统的
应用程序?

我希望这些信息足够详细,以便读者能够确定这是一个明显的错误,有一个明显的解决方案(只是一个我不知道的错误)。但是,如果不是,并且需要一个例子,请告诉我,我将生成一个。任何帮助都表示赞赏。

谢谢,Tyler
I am attempting to extend a legacy VB6 application by making it use a .NET
component written in C# exposed through COM interop. Everything appeared
to
be going well (VB application creates the .NET component instead of the
legacy VB6 component and invokes some methods successfully) until I hit a
snag.

For one method that is being invoked by the VB6 application, the method
takes 2 parameters (string values) and a custom interface. Depending on
processing, this custom interface may be a valid object, or may be
"Nothing". When this method is invoked on a legacy VB6 object
implementing
this interface, no error is experienced. When this method is invoked on
my
.NET component, I get the following error:
Object reference is not set to an instance of an object (0x8000403).
I have determined that the error is due to the custom interface parameter
(I
can avoid the problem when it is caught in the VB6 debugger by creating an
instance of an object that implements the interface).

My question is, what causes the runtime callable wrapper that is generated
by C# to fail the request with the 0x8000403 error when the custom
interface
is "Nothing" and, more importantly, is there anyway I can disable this
error
or work-around the problem without having to change the VB6 legacy
application?

I hope this information is sufficiently detailed to allow a reader to
determine whether this is an obvious error with an obvious solution (just
one that I don''t know). However, if it is not and an example is required,
please let me know and I will generate one. Any assistance is
appreciated.

Thanks, Tyler






Hi Tyler,


感谢您在此发帖。关于这个问题,我是

找到合适的资源来帮助你,我们会尽快更新。


问候,


Steven Cheng

Microsoft在线支持


安全! www.microsoft.com/security(This )发布按原样提供;,

没有保修,也没有授予任何权利。)

Hi Tyler,

Thank you for posting here. Regarding on the issue, I am
finding proper resource to assist you and we will update as soon as posible.

Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security(This posting is provided "AS IS",
with no warranties, and confers no rights.)


我目前正在创建一个样本,我可以发布到

来证明这个问题,因为这个问题看起来并不是已知

或常见问题 - 尽管我希望我只是遗漏了一些明显的东西。

我准备好后会发布这个样本。


Tyler
I am currently in the process of creating a sample that I can post to
demonstrate the problem as it does not appear that this issue is a "known"
or "common" problem - although I expect I am just missing something obvious.
I will post this sample when I have it ready.

Tyler


这篇关于VB6的无与伦比C#RCW错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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