I don't think you've been clear about exactly what you've tried that caused
that "too few elements" error. Nothing in your msg has told anything how many
elements there should be in an array, so that's an odd error message to be
getting unless you left something out. (If you had Cobol code that expects an
array of [say] 20 values, and the code failed when accessing the 2nd value,
that might mean that the whole array wasn't passed over. Can you tell what
line of Cobol code has failed when there's an error on the Cobol side?)
If you're trying to call a test routine akin to your "intermediate AcuCobol
adapter program" (IAAP), how did you define it? (It wasn't the Call method
whose defn you showed, was it? You hadn't mentioned the adapter program yet so
I didn't think so; and why would you set it up to take 14 parameters? I assume
that's the AcuCobol COM thingy that lets you call arbitrary Cobol routines, and
you'll have to pass the name of your IAAP when you call it.)
You hopefully can tell COM that the value to be passed is a safearray; if you
don't, you have some futzing to do -- on the .Net side, you'll have to stuff
the array you want to pass into an Object (the .Net "wrapper" type that
somewhat corresponds to a COM VARIANT), and on the Cobol side, you'll have to
extract the safearray from the VARIANT* wrapper that surrounds it.
How are you calling the method from .Net? How are you pulling the array
elements out on the Cobol side? (Any code at all might help -- particularly if
you know what line caused the error on the Cobol side.)
Good luck...
At 04:48 PM 5/11/2006, Jon Stonecash wrote (in part)
>I have a need for .NET code to call AcuCobol programs. AcuCobol provides a
>COM interface with a number of methods. To the extent that I have tested this
>interface everything works.
>
>The problem is that this interface has a limitation (50) on the number of
>distinct parameters that can be passed from .NET to an individual AcuCobol
>program. I need to exceed that limit by at least a factor of three. (This is
>legacy code and as much as I would wish to change it, I cannot.)
>
>This is the definition of the specific COM method as displayed by OleView:
>
>[id(0x60020009), helpstring("Calls a COBOL program.")]
>HRESULT Call(
>[in] VARIANT* Name,
>[in, out, optional] VARIANT* arg0,
>[snip]
>[in, out, optional] VARIANT* arg13);
>
>Since each of the variables is a variant and a variant can hold an array, my
>thought was to package all of the parameters up into an array in the .NET code
>and pass the array into an intermediate AcuCobol adapter program that would
>"unpack" the parameters from the array and pass them on to the legacy AcuCobol
>code.
>
>I have put together a test cast that does all of this but when I call the COM
>object to fire up the AcuCobol adapter program, I get back an error message
>from the AcuCobol runtime that says that what I passed has too few elements.
>My guess is that the marshalling logic sees the VARIANT* and only marshalls a
>single value.
>
>I am reading Adam Nathan's book on .NET and COM, but there are 1500+ pages and
>my quick scan does not show anything that is on point. Can anyone point me to
>the path that leads to a solution?
>
>Jon Stonecash
J. Merrill / Analytical Software Corp
===================================
This list is hosted by DevelopMentorĀ® http://www.develop.com
View archives and manage your subscription(s) at http://discuss.develop.com