Problem returning a collection of a class from a DLL to a client app

R

rbeyea

I am writing a DLL (DLL1) that is wrapping another DLL (DLL2). I need to
extract the information returned from DLL2 and pass it out to the Client
application this is using DLL1.

DLL2 returns data that I would like to return through DLL1 as a collection
so the user can use foreach (lookup li in _myAdapter.lookupInfoCol) and get
the li.JID and li.MailAddr1 data from the returned collection.

The data is in the collection and I think it is getting returned to the Client.
But I am getting a messages:
1. C:\Develop\CSharp\TestJuryWrapper\JPNGDNAPI\myConsole\myConsole.cs(25):
'myConsoleNS.myConsole._myAdapter' denotes a 'field' where a 'class' was
expected
and
2. C:\Develop\CSharp\TestJuryWrapper\JPNGDNAPI\myConsole\myConsole.cs(26):
The type or namespace name 'lookup' could not be found (are you missing a
using directive or an assembly reference?)

Any and all helps is extremely appreciated.
Thanks in advance,
rich

when trying to compile. Below is the code.

-> JSIAccessAdapter.cs

using System;
using System.Text;
using System.Runtime.InteropServices;
using System.Reflection;
using System.IO;
using System.Collections;

namespace JPNGDNAPI
{

/// <summary>
/// JSIAccessAdapter is the base for the Jury Systems, inc wrapper..
/// </summary>
public class JSIAccessAdapter
{

// strings for communication with cobol dll
private string _ctlArea;
private string _reqArea;
private string _commArea;

// Declare the Classes for access.
private LookupInfo _LookupInfo;
private LookupInfoCol _LookupInfoCol;

public JSIAccessAdapter()
{

}

public LookupInfoCol GetJurorLookup(string LastName, string FirstName,
string DOB)
{

string spaces = new String(' ', 100);
StringBuilder sb = new StringBuilder(213, 213);

// Set up the Ctl Area.
sb.Append("00000000000000000000000000000");
sb.Append(spaces);
_ctlArea = sb.ToString();

StringBuilder sbReq = new StringBuilder(43, 43);

sbReq.Append(LastName);
sbReq.Append(FirstName);
sbReq.Append(DOB);

_reqArea = sbReq.ToString();

_commArea = new String(' ', 4096);

// CallCobolRoutine(_commArea, _ctlArea, _reqArea);

// Instantiate the identityInfo class with the CommArea
// This will extract CommArea into the individual fields.
LookupInfoCol lookupInfoCol = new LookupInfoCol(_commArea);

return lookupInfoCol;

}


public LookupInfo lookupInfo
{
get
{
return _LookupInfo;
}
set
{
_LookupInfo = value;
}
}

public LookupInfoCol lookupInfoCol
{
get
{
return _LookupInfoCol;
}
set
{
_LookupInfoCol = value;
}
}



}
}

-> LookupInfo.cs

using System;

namespace JPNGDNAPI
{
/// <summary>
/// Summary description for LookupInfo.
/// </summary>
public class LookupInfo
{

private string _JID ;
private string _MailAddr1 ;

// // Constructor
// public LookupInfo()
// {
// }
//
// public LookupInfo(string JID, string MailAddr1)
// {
// this.JID = JID;
// this.MailAddr1 = MailAddr1;
// }

public string JID
{
get
{
return _JID;
}
set
{
_JID = value;
}
}

public string MailAddr1
{
get
{
return _MailAddr1;
}
set
{
_MailAddr1 = value;
}
}


}
}

->LookupInfoCol.cs

using System;
using System.Collections;

namespace JPNGDNAPI
{
/// <summary>
/// Summary description for LookupInfo.
/// </summary>
public class LookupInfoCol : ArrayList
{

const int C_MaxInfoItems = 15;

private ArrayList _LookupInfoCollection = new ArrayList();

private LookupInfo _LookupInfo = new LookupInfo();

// Constructor
public LookupInfoCol(String commArea)
{
ExtractLookupInfo(commArea);
}

private void ExtractLookupInfo(string commArea)
{

int j = 0; // JID - Starting Location in Comm Area
int k = 135; // Mail Address 1 - Starting Location in Comm Area
for (int i = 0; i < C_MaxInfoItems; i++)
{
if(commArea.Substring(j, 9) != "000000000")
{
lookupInfo = new LookupInfo();

_LookupInfo.JID = commArea.Substring(j, 9);
_LookupInfo.MailAddr1 = commArea.Substring(k, 30);

// LookupInfo lookupInfo = new LookupInfo(commArea.Substring(j, 9),
commArea.Substring(k, 30));
j += 9;
k += 30;

_LookupInfoCollection.Add(lookupInfo);
}

}

}


public LookupInfo lookupInfo
{

get
{
return _LookupInfo;
}
set
{
_LookupInfo = value;
}
}

}
}

-> MyConsole.cs - Client Console App.

using System;
using JPNGDNAPI;

namespace myConsoleNS
{
/// <summary>
/// Summary description for Class1.
/// </summary>
class myConsole
{

private JSIAccessAdapter _myAdapter = new JSIAccessAdapter();

/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main(string[] args)
{
// Get access to the .Net Adapter
JSIAccessAdapter _myAdapter = new JSIAccessAdapter();



_myAdapter.lookupInfoCol = _myAdapter.GetJurorLookup("Hartquist", "Barbara",
"19411111");


-----------------------------> Message 1 appears for this line below.
_myAdapter.lookupInfoCol.lookupInfo lookup = _myAdapter.lookupInfo();

-----------------------------> Message 2 appears for the line below. Because
the line above is failing.
foreach (lookup li in _myAdapter.lookupInfoCol)
{
Console.WriteLine("JID = " + li.JID);
Console.WriteLine("JID = " + li.MailAddr1);
}


}
}
}
 
G

Guest

Hi rbeyea,
1. C:\Develop\CSharp\TestJuryWrapper\JPNGDNAPI\myConsole\myConsole.cs(25):
'myConsoleNS.myConsole._myAdapter' denotes a 'field' where a 'class' was

I believe is because in your Main method you have the following line:

_myAdapter.lookupInfoCol.lookupInfo lookup = _myAdapter.lookupInfo();

You are trying to declare an object, but instead of declaring it of type
LookupInfo (take notice of your capitalization) you have tried to use a field
in the object called lookupinfo. What you should have said is:

JPNGDNAPI.LookupInfo lookup = _myAdapter.lookupInfo;

notice that it is _myAdapter.lookupInfo because it is a property not
_myAdapter.lookupInfo() which it would be if that was a method.

Hope that helps
Mark R Dawson
http://www.markdawson.org





rbeyea said:
I am writing a DLL (DLL1) that is wrapping another DLL (DLL2). I need to
extract the information returned from DLL2 and pass it out to the Client
application this is using DLL1.

DLL2 returns data that I would like to return through DLL1 as a collection
so the user can use foreach (lookup li in _myAdapter.lookupInfoCol) and get
the li.JID and li.MailAddr1 data from the returned collection.

The data is in the collection and I think it is getting returned to the Client.
But I am getting a messages:
1. C:\Develop\CSharp\TestJuryWrapper\JPNGDNAPI\myConsole\myConsole.cs(25):
'myConsoleNS.myConsole._myAdapter' denotes a 'field' where a 'class' was
expected
and
2. C:\Develop\CSharp\TestJuryWrapper\JPNGDNAPI\myConsole\myConsole.cs(26):
The type or namespace name 'lookup' could not be found (are you missing a
using directive or an assembly reference?)

Any and all helps is extremely appreciated.
Thanks in advance,
rich

when trying to compile. Below is the code.

-> JSIAccessAdapter.cs

using System;
using System.Text;
using System.Runtime.InteropServices;
using System.Reflection;
using System.IO;
using System.Collections;

namespace JPNGDNAPI
{

/// <summary>
/// JSIAccessAdapter is the base for the Jury Systems, inc wrapper..
/// </summary>
public class JSIAccessAdapter
{

// strings for communication with cobol dll
private string _ctlArea;
private string _reqArea;
private string _commArea;

// Declare the Classes for access.
private LookupInfo _LookupInfo;
private LookupInfoCol _LookupInfoCol;

public JSIAccessAdapter()
{

}

public LookupInfoCol GetJurorLookup(string LastName, string FirstName,
string DOB)
{

string spaces = new String(' ', 100);
StringBuilder sb = new StringBuilder(213, 213);

// Set up the Ctl Area.
sb.Append("00000000000000000000000000000");
sb.Append(spaces);
_ctlArea = sb.ToString();

StringBuilder sbReq = new StringBuilder(43, 43);

sbReq.Append(LastName);
sbReq.Append(FirstName);
sbReq.Append(DOB);

_reqArea = sbReq.ToString();

_commArea = new String(' ', 4096);

// CallCobolRoutine(_commArea, _ctlArea, _reqArea);

// Instantiate the identityInfo class with the CommArea
// This will extract CommArea into the individual fields.
LookupInfoCol lookupInfoCol = new LookupInfoCol(_commArea);

return lookupInfoCol;

}


public LookupInfo lookupInfo
{
get
{
return _LookupInfo;
}
set
{
_LookupInfo = value;
}
}

public LookupInfoCol lookupInfoCol
{
get
{
return _LookupInfoCol;
}
set
{
_LookupInfoCol = value;
}
}



}
}

-> LookupInfo.cs

using System;

namespace JPNGDNAPI
{
/// <summary>
/// Summary description for LookupInfo.
/// </summary>
public class LookupInfo
{

private string _JID ;
private string _MailAddr1 ;

// // Constructor
// public LookupInfo()
// {
// }
//
// public LookupInfo(string JID, string MailAddr1)
// {
// this.JID = JID;
// this.MailAddr1 = MailAddr1;
// }

public string JID
{
get
{
return _JID;
}
set
{
_JID = value;
}
}

public string MailAddr1
{
get
{
return _MailAddr1;
}
set
{
_MailAddr1 = value;
}
}


}
}

->LookupInfoCol.cs

using System;
using System.Collections;

namespace JPNGDNAPI
{
/// <summary>
/// Summary description for LookupInfo.
/// </summary>
public class LookupInfoCol : ArrayList
{

const int C_MaxInfoItems = 15;

private ArrayList _LookupInfoCollection = new ArrayList();

private LookupInfo _LookupInfo = new LookupInfo();

// Constructor
public LookupInfoCol(String commArea)
{
ExtractLookupInfo(commArea);
}

private void ExtractLookupInfo(string commArea)
{

int j = 0; // JID - Starting Location in Comm Area
int k = 135; // Mail Address 1 - Starting Location in Comm Area
for (int i = 0; i < C_MaxInfoItems; i++)
{
if(commArea.Substring(j, 9) != "000000000")
{
lookupInfo = new LookupInfo();

_LookupInfo.JID = commArea.Substring(j, 9);
_LookupInfo.MailAddr1 = commArea.Substring(k, 30);

// LookupInfo lookupInfo = new LookupInfo(commArea.Substring(j, 9),
commArea.Substring(k, 30));
j += 9;
k += 30;

_LookupInfoCollection.Add(lookupInfo);
}

}

}


public LookupInfo lookupInfo
{

get
{
return _LookupInfo;
}
set
{
_LookupInfo = value;
}
}

}
}

-> MyConsole.cs - Client Console App.

using System;
using JPNGDNAPI;

namespace myConsoleNS
{
/// <summary>
/// Summary description for Class1.
/// </summary>
class myConsole
{

private JSIAccessAdapter _myAdapter = new JSIAccessAdapter();

/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main(string[] args)
{
// Get access to the .Net Adapter
JSIAccessAdapter _myAdapter = new JSIAccessAdapter();



_myAdapter.lookupInfoCol = _myAdapter.GetJurorLookup("Hartquist", "Barbara",
"19411111");


-----------------------------> Message 1 appears for this line below.
_myAdapter.lookupInfoCol.lookupInfo lookup = _myAdapter.lookupInfo();

-----------------------------> Message 2 appears for the line below. Because
the line above is failing.
foreach (lookup li in _myAdapter.lookupInfoCol)
{
Console.WriteLine("JID = " + li.JID);
Console.WriteLine("JID = " + li.MailAddr1);
}


}
}
}
 
Top