B
Brett Kelly
Hello all,
I'm in a situation where I need to retrieve a member from the
System.Data.SqlDbType 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.Reflection;
using System.Data;
namespace PleaseFreakinWork
{
public class TypeTest
{
public static void Main(string[] args)
{
try
{
Type MyType = Type.GetType("System.Data.SqlDbType");
Console.WriteLine("Type Name:" + MyType.Name);
}
catch(Exception ex)
{
Console.WriteLine(ex.Message);
Console.WriteLine(ex.StackTrace);
}
}
}
}
And when I run this, it blows up on the Console.WriteLine call w/
"Object ref not set to an instance of an object". Now, if I change the
type name to System.Reflection.Assembly, it works fine. But if I
change it to System.Data.SqlClient.SqlConnection (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.SqlDbType 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.Reflection;
using System.Data;
namespace PleaseFreakinWork
{
public class TypeTest
{
public static void Main(string[] args)
{
try
{
Type MyType = Type.GetType("System.Data.SqlDbType");
Console.WriteLine("Type Name:" + MyType.Name);
}
catch(Exception ex)
{
Console.WriteLine(ex.Message);
Console.WriteLine(ex.StackTrace);
}
}
}
}
And when I run this, it blows up on the Console.WriteLine call w/
"Object ref not set to an instance of an object". Now, if I change the
type name to System.Reflection.Assembly, it works fine. But if I
change it to System.Data.SqlClient.SqlConnection (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