Problem with Type.GetType(string var) returning null

  • Thread starter Thread starter VC
  • Start date Start date
V

VC

Why this works?

t = Type.GetType("GlobalDB.DBSqlServer");

GetType returns the type of the class and t is {Name = "DBSqlServer"
FullName = "GlobalDB.DBSqlServer"}

And why this don't works?

string dbInUse = "DBSqlServer";
string type = "GlobalDb." + dbInUse;

t = Type.GetType(type);

t is always null

why? this is driving me crazy



The class declaration:

namespace GlobalDB
{
public class DBSqlServer : DB
{
public DBSqlServer(string connStr)
{
if (connStr != null)
this.ConnectionString = connStr;
else
throw new ApplicationException("Connection String not
given");
}

// other stuff here
}
 
VC said:
Why this works?

t = Type.GetType("GlobalDB.DBSqlServer");

GetType returns the type of the class and t is {Name = "DBSqlServer"
FullName = "GlobalDB.DBSqlServer"}

And why this don't works?

string dbInUse = "DBSqlServer";
string type = "GlobalDb." + dbInUse;

t = Type.GetType(type);

t is always null

why? this is driving me crazy

It's case sensitive - there's a difference between "GlobalDB" and
"GlobalDb".
 
VC said:
Why this works?

t = Type.GetType("GlobalDB.DBSqlServer");

GetType returns the type of the class and t is {Name = "DBSqlServer"
FullName = "GlobalDB.DBSqlServer"}

And why this don't works?

string dbInUse = "DBSqlServer";
string type = "GlobalDb." + dbInUse;

string type = "GlobalDB." + dbInUse;

B not b.
t = Type.GetType(type);

t is always null

why? this is driving me crazy

Arne
 
How stupid I am... I didnt see that.

I have to go to the ophtalmologist. Thanks everyone!!!

Merry Christmas!
 
Back
Top