Reputation: 83
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:
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"
Upvotes: 1
Views: 586
Reputation: 83
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.
Upvotes: 0
Reputation: 37211
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:
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;
Upvotes: 3
Reputation: 613013
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.
Upvotes: 3