Hello all,
I'm in a situation where I need to retrieve a member from the
System.Data.Sql DbType enumeration knowing only the type name.
At this point, I'm just trying to get reflection to work... This is
what I've got so far:
using System;
using System.Reflecti on;
using System.Data;
namespace PleaseFreakinWo rk
{
public class TypeTest
{
public static void Main(string[] args)
{
try
{
Type MyType = Type.GetType("S ystem.Data.SqlD bType");
Console.WriteLi ne("Type Name:" + MyType.Name);
}
catch(Exception ex)
{
Console.WriteLi ne(ex.Message);
Console.WriteLi ne(ex.StackTrac e);
}
}
}
}
And when I run this, it blows up on the Console.WriteLi ne call w/
"Object ref not set to an instance of an object". Now, if I change the
type name to System.Reflecti on.Assembly, it works fine. But if I
change it to System.Data.Sql Client.SqlConne ction (for example), that
doesn't work.
I've tried loading the System.Data.dll assembly, but it errors out
saying that the file or one of its dependencies could not be found...
Help!
TIA,
Brett
I'm in a situation where I need to retrieve a member from the
System.Data.Sql DbType enumeration knowing only the type name.
At this point, I'm just trying to get reflection to work... This is
what I've got so far:
using System;
using System.Reflecti on;
using System.Data;
namespace PleaseFreakinWo rk
{
public class TypeTest
{
public static void Main(string[] args)
{
try
{
Type MyType = Type.GetType("S ystem.Data.SqlD bType");
Console.WriteLi ne("Type Name:" + MyType.Name);
}
catch(Exception ex)
{
Console.WriteLi ne(ex.Message);
Console.WriteLi ne(ex.StackTrac e);
}
}
}
}
And when I run this, it blows up on the Console.WriteLi ne call w/
"Object ref not set to an instance of an object". Now, if I change the
type name to System.Reflecti on.Assembly, it works fine. But if I
change it to System.Data.Sql Client.SqlConne ction (for example), that
doesn't work.
I've tried loading the System.Data.dll assembly, but it errors out
saying that the file or one of its dependencies could not be found...
Help!
TIA,
Brett
Comment