COM+ 的最大数量限制函数参数

发布于 2024-12-09 17:19:56 字数 773 浏览 0 评论 0原文

我正在使用 Delphi 类型库创建 COM+ 应用程序。当我为一个函数调用创建 78 个参数时,出现访问冲突错误。我意识到 COM+ 函数的参数数量是有限制的。所以之后,我必须使用类型化结构/记录来打包参数。然后传递一条记录而不是多个简单数据类型参数。

您知道这个限制吗?您有什么建议?

我做了更多涉及结构/记录的测试,然后安装新组件并在调用它时收到错误:

Type Library使用 Record

我调用该函数:

ReturnVaule := Clients.updClient2(EmploymentApp.SessionID,
                                MyClientDetails,
                                dtLastModificationDate,
                                ClientServices,
                                ClientRequestors,
                                ClientQuestionnaires);

并且收到错误:

“空引用指针已传递给存根”

错误消息

I was using Delphi Type Library to create a COM+ application. I got a access violation error when I created the number 78 parameters for one function call. I realized that there is a limitation for the number of parameters for the COM+ functions. So after, I have to use a typed structure/Record to package the parameters. Then pass a record instead of numbers of simple data type parameters.

Do you know about this limitation and what is your suggest?

I did more test as involved the Struct/Record, then I install the new component and get a error when I call it:

Type Library with the Record

I call the function:

ReturnVaule := Clients.updClient2(EmploymentApp.SessionID,
                                MyClientDetails,
                                dtLastModificationDate,
                                ClientServices,
                                ClientRequestors,
                                ClientQuestionnaires);

and I get the error:

"A null reference pointer was passed to the stub"

error message

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

千と千尋 2024-12-16 17:19:56

我不认为 Delphi 或 COM+ 中有任何这样的限制。我不确定是什么导致了您的错误,但我认为您需要更详细地描述您所做的事情。

无论如何,使用具有这么多参数的方法是不明智的。超过大约 4 或 5 个已经在拉伸它。将此事件视为一个温和的暗示,以更易于管理的方式重新思考您的设计。

I don't believe that there is any such limit in Delphi or COM+. I'm not sure what caused your error but I think you'd need to describe what you did in more detail.

No matter what, it is not sensible to have methods with that many parameters. More than about 4 or 5 is already stretching it. Take this incident as a gentle hint to rethink your design in a more manageable manner.

最笨的告白 2024-12-16 17:19:56

正如您所说,您可以使用类型库编辑器来声明您的记录类型,然后修改您的方法以使用该类型的参数。

编辑:来自类型库编辑器的示例屏幕截图:

在此处输入图像描述

来自类型库编辑器的类型库声明生成以下内容代码(摘录):

type

// *********************************************************************//
// Forward declaration of types defined in TypeLibrary
// *********************************************************************//
  ITest = interface;
  ITestDisp = dispinterface;

// *********************************************************************//
// Declaration of CoClasses defined in Type Library
// (NOTE: Here we map each CoClass to its Default Interface)
// *********************************************************************//
  Test = ITest;


// *********************************************************************//
// Declaration of structures, unions and aliases.
// *********************************************************************//
  TestRecord = packed record
    Field1: Integer;
    Field2: WideString;
    Field3: TDateTime;
  end;


// *********************************************************************//
// Interface: ITest
// Flags:     (4416) Dual OleAutomation Dispatchable
// GUID:      {F3EA5C38-23A6-4919-A51F-31C46DB6012D}
// *********************************************************************//
  ITest = interface(IDispatch)
    ['{F3EA5C38-23A6-4919-A51F-31C46DB6012D}']
    procedure TestMethod(TestParam: TestRecord); safecall;
  end;

// *********************************************************************//
// DispIntf:  ITestDisp
// Flags:     (4416) Dual OleAutomation Dispatchable
// GUID:      {F3EA5C38-23A6-4919-A51F-31C46DB6012D}
// *********************************************************************//
  ITestDisp = dispinterface
    ['{F3EA5C38-23A6-4919-A51F-31C46DB6012D}']
    procedure TestMethod(TestParam: {??TestRecord}OleVariant); dispid 201;
  end;

As you said, you can use the type library editor to declare your record type and then modify your method to use a parameter of that type.

Edit: Example screenshot from the type library editor:

enter image description here

The type library declarations from the type library editor generates the following code (excerpt):

type

// *********************************************************************//
// Forward declaration of types defined in TypeLibrary
// *********************************************************************//
  ITest = interface;
  ITestDisp = dispinterface;

// *********************************************************************//
// Declaration of CoClasses defined in Type Library
// (NOTE: Here we map each CoClass to its Default Interface)
// *********************************************************************//
  Test = ITest;


// *********************************************************************//
// Declaration of structures, unions and aliases.
// *********************************************************************//
  TestRecord = packed record
    Field1: Integer;
    Field2: WideString;
    Field3: TDateTime;
  end;


// *********************************************************************//
// Interface: ITest
// Flags:     (4416) Dual OleAutomation Dispatchable
// GUID:      {F3EA5C38-23A6-4919-A51F-31C46DB6012D}
// *********************************************************************//
  ITest = interface(IDispatch)
    ['{F3EA5C38-23A6-4919-A51F-31C46DB6012D}']
    procedure TestMethod(TestParam: TestRecord); safecall;
  end;

// *********************************************************************//
// DispIntf:  ITestDisp
// Flags:     (4416) Dual OleAutomation Dispatchable
// GUID:      {F3EA5C38-23A6-4919-A51F-31C46DB6012D}
// *********************************************************************//
  ITestDisp = dispinterface
    ['{F3EA5C38-23A6-4919-A51F-31C46DB6012D}']
    procedure TestMethod(TestParam: {??TestRecord}OleVariant); dispid 201;
  end;
╄→承喏 2024-12-16 17:19:56

最后,我使用 Variant 参数来传输大部分参数,然后将它们作为数组读取出来。它工作得很好,但要知道数组的索引映射到哪个参数并不容易。

At last, I use a Variant parameter to transfer most of the parameters, then read them out as a array. It works fine, but it is not easy to know the index of the array is mapping to which parameter.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文