Previously, I ran into a problem trying to share a type definition between my ASMX webservice and my .aspx page (webclient)
As I understand the advice, the "problem" this creates can be solved by copying the array of objects created in the client to a new array of objects as defined by the ASMX proxy class.
Being a rookie in C# I am still struggling with this simple task. Here are more parts of my code (the other fragments in the previous post remain unchanged):
... here is where I populate the "test data" I want to pass to the web service:
// create an array of MetaData objects
MetaData[] nvPairs = new MetaData[20]; // arbitrary length of 20 pairs
// create arbitrary MetaData objects in the array
nvPairs[0] = new MetaData("Grant Number", "2577-9912");
nvPairs[1] = new MetaData("OPEAnalyst", "Simpson");
... here I attempt a function to "copy" from "real" type defined in my TRIMBrokerUtil namespace (which I can't use completely because of the proxy) to the proxy version of that type:
protected TRIMBrokerASMXProxy.ASMXProxy.MetaData[] CopyMetaData(
MetaData utilArray)
{
TRIMBrokerASMXProxy.ASMXProxy.MetaData[] outArray =
new TRIMBrokerASMXProxy.ASMXProxy.MetaData[utilArray.Name.Length];
int i;
for (i = 0; i < utilArray.Name.Length; i++)
{
outArray[i].Name = utilArray.Name;
outArray[i].Value = utilArray.Value;
}
return outArray;
}
... and then here is where I try to call that function (compiler flags 2 errors on this line:
TRIMBrokerASMXProxy.ASMXProxy.MetaData[] kvData =
CopyMetaData(metaDataArray);
Both of the compile errors below point to the same line:
Error 1 The best overloaded method match for '_Default.CopyMetaData(TRIMBrokerUtil.MetaData)' has some invalid arguments
Error 2 Argument '1': cannot convert from 'TRIMBrokerUtil.MetaData[]' to 'TRIMBrokerUtil.MetaData'
Am I close ?