English 中文(简体)
为什么对COM组件的调用只使用VisualStudio QuickWatch窗口返回值?
原标题:Why does a call to a COM component only return values using the VisualStudio QuickWatch window?

我目前在C#MVC3项目中使用的com组件有点奇怪。

COM组件(名为YVPCUST)包含以下vb6例程:

Public Function GetDocument(ByVal a_sCode As Variant, ByRef a_sLocation As Variant, ByRef a_sDestination As Variant, ByRef a_sSuffix As Variant) As Integer
    Dim oSystem     As System

    Set oSystem = CreateObject("qtcsl32.System")
    GetDocument = oSystem.GetDocumentByRef(a_sCode, a_sLocation, a_sDestination, a_sSuffix)
    Set oSystem = Nothing

End Function

C#MVC3项目使用COM组件层构建,该层直接引用名为YVPCUST的组件:

qtcsl32.YVPCUST yvpCust = new qtcsl32.YVPCUST();

object code = (object)"RAAG";
object minimumAge = 0;
object maximumAge = 0;
object suffix = (object)string.Empty; //not to be used

int returnCode;

returnCode = yvpCust.GetDocument(code, minimumAge, maximumAge, suffix);

GetDocument()例程应该获取所提供代码的最大和最小年龄。但是,当我在编译或调试模式下运行应用程序并遍历最后一行时,minimumAge和maximumAge值设置不正确,它们被设置为默认值0(无论我重新执行此行的次数如何)。

但是,(在调试模式下)如果我中断最后一行的代码,而是使用QuickWatch运行该行,当我从QuickWatch窗口返回到代码时,当我将鼠标悬停在这些值上时,这些值将被设置为正确的最小和最大年龄。

有人知道为什么会发生这种情况吗?

这个COM组件可以在应用程序的其他地方使用(但不是这个rountine),没有问题。

最佳回答

我意识到COM组件的C#包装器有以下声明:

short GetDocument(object a_sCode, ref object a_sLocation, ref object a_sDestination, ref object a_sSuffix);

然后我意识到代码行应该已经写好了(包括参考文件s):

returnCode = yvpCust.GetDocument(code, ref minimumAge, ref maximumAge, suffix);

这并不能解释为什么它使用QuickWatch窗口工作,但我已经设法获得了所需的结果。

问题回答

暂无回答




相关问题
Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

NSArray s, Primitive types and Boxing Oh My!

I m pretty new to the Objective-C world and I have a long history with .net/C# so naturally I m inclined to use my C# wits. Now here s the question: I feel really inclined to create some type of ...

C# Marshal / Pinvoke CBitmap?

I cannot figure out how to marshal a C++ CBitmap to a C# Bitmap or Image class. My import looks like this: [DllImport(@"test.dll", CharSet = CharSet.Unicode)] public static extern IntPtr ...

How to Use Ghostscript DLL to convert PDF to PDF/A

How to user GhostScript DLL to convert PDF to PDF/A. I know I kind of have to call the exported function of gsdll32.dll whose name is gsapi_init_with_args, but how do i pass the right arguments? BTW, ...

Linqy no matchy

Maybe it s something I m doing wrong. I m just learning Linq because I m bored. And so far so good. I made a little program and it basically just outputs all matches (foreach) into a label control. ...

热门标签