Mattersphere Developers Forum
Would you like to react to this message? Create an account in a few clicks or log in to continue.

Go down
avatar
Lynne Harding
Posts : 335
Join date : 2018-12-20

How To Build An FWBS.Common.KeyValueCollection[] Empty How To Build An FWBS.Common.KeyValueCollection[]

Fri 24 Jan 2020 - 10:45
I am currently creating a class library to connect Mattercentre to the new printing solution being introduced to the company.
Basically when a document or set of documents is selected from a search list it returns datatype FWBS.Common.KeyValueCollection[]. To test my code I have built an
standalone console application and constructed a method to build a set of test data as a FWBS.Common.KeyValueCollection[].
The code looks like this...
//********************************************************************
// SPR 30-04-2013
// Method to [fake] a KeyValueCollection[]. In the final class library
// , this will be pulled from searchlist.selectedItems in Mattercentre
//********************************************************************
private static FWBS.Common.KeyValueCollection[] TestListOfDocumentIDs()
{
System.Collections.Generic.List mySelectedDocIDs = new System.Collections.Generic.List(new long[] {1233757, 1233756});
int SIZE = mySelectedDocIDs.Count;
FWBS.Common.KeyValueCollection[] results = new FWBS.Common.KeyValueCollection[SIZE];
try
{
for (int x = 0; x < SIZE; x++)
{
FWBS.Common.KeyValueCollection mySubset = new FWBS.Common.KeyValueCollection();
mySubset.Add(“docID”, mySelectedDocIDs[x]);
results[x].Add(Convert.ToString(x), mySubset);
}
}
catch (Exception ex)
{
string cr = System.Environment.NewLine;
string myTitle = “Error Message - “ + ex.TargetSite;
string myMessage = @”“;
myMessage += string.Format(“{0}{1}{2}”, myTitle, cr, cr);
myMessage += string.Format(“{0}{1}{2}{3}”, “ERROR: An exception of type: “, ex.GetType(), cr, cr);
myMessage += string.Format(“{0}{1}{2}{3}”, “Occurred in method: “, ex.TargetSite, cr, cr);
myMessage += string.Format(“{0}{1}{2}{3}”, “Message: “, ex.Message.ToString(), cr, cr);
System.Console.Write(myMessage);
}
return results;
}
Unfortunately I am getting the following exception...
Error Message - FWBS.Common.KeyValueCollection[] TestListOfDocumentIDs()

ERROR: An exception of type: System.NullReferenceException
Occurred in method: FWBS.Common.KeyValueCollection[] TestListOfDocumentIDs() Message: Object reference not set to an instance of an object.

Can anyone see what I'm doing wrong?
Thanks in advance for your help


Back to top
Permissions in this forum:
You cannot reply to topics in this forum