I have had to write a C# COM Server using .NET to service an existing classic ASP web application. So far so good in that I have been able to call simply functions which return say a single string or integer.
I have a call however that needs to return an array of strings. The function is shown below. There appears to be an issue with the marshalling of string back to the ASP page as when I try to iterate through the entries using a for loop I get a type mis-match.
How can I return an array of strings from this function?
public string EnumAssets(int instanceID, int locationID)
List<string> listValues = new List<string>();
// First ensure that the database is open and the user logged in
if (ValidateOpenAndLoggedIn() == 0)
AuditWizardDataAccess awDataAccess = new AuditWizardDataAccess();
AssetList listAssets = new AssetList(awDataAccess.GetAssets(locationID, AssetGroup.GROUPTYPE.userlocation ,false), true);
// Iterate through the returned list of Asset objects and format them for return as strings
foreach (Asset asset in listAssets)
listValues.Add(Pack(asset.Name, ICON_PERIPH, true, asset.AssetID));
listValues.Add(Pack(asset.Name, ICON_ASSET, true, asset.AssetID));
// Convert the list to an array of strings and return it
string returnValues = listValues.ToArray();