A
A.M-SG
Hi,
The following code gives me InvalidCastException with the following message:
{"Unable to cast object of type 'System.Collections.Generic.List`1' to type
'System.Collections.Generic.IList`1'."}
What is the reason?
Any help would be appreciated,
Alan
public OracleDatabase ELOracleDatabase
{
get
{
if (_ELOracleDatabase == null)
{
// ****************************
// InvalidCastException happens here!
IList<IOraclePackage> oraclePackages =
(IList<IOraclePackage>)(new List<OraclePackage>());
_ELOracleDatabase = new OracleDatabase(_connectionString,
null);
}
return _ELOracleDatabase;
}
}
class OraclePackage : IOraclePackage
{
string _name, _prefix;
OraclePackage()
{
_name = string.Empty;
_prefix = string.Empty;
}
public string Name
{
get { return _name; }
set { _name = value; }
}
public string Prefix
{
get { return _prefix; }
set { _prefix = value; }
}
}
public interface IOraclePackage
{
string Name
{ get; }
string Prefix
{ get; }
}
The following code gives me InvalidCastException with the following message:
{"Unable to cast object of type 'System.Collections.Generic.List`1' to type
'System.Collections.Generic.IList`1'."}
What is the reason?
Any help would be appreciated,
Alan
public OracleDatabase ELOracleDatabase
{
get
{
if (_ELOracleDatabase == null)
{
// ****************************
// InvalidCastException happens here!
IList<IOraclePackage> oraclePackages =
(IList<IOraclePackage>)(new List<OraclePackage>());
_ELOracleDatabase = new OracleDatabase(_connectionString,
null);
}
return _ELOracleDatabase;
}
}
class OraclePackage : IOraclePackage
{
string _name, _prefix;
OraclePackage()
{
_name = string.Empty;
_prefix = string.Empty;
}
public string Name
{
get { return _name; }
set { _name = value; }
}
public string Prefix
{
get { return _prefix; }
set { _prefix = value; }
}
}
public interface IOraclePackage
{
string Name
{ get; }
string Prefix
{ get; }
}