Problem with Type.GetType(string var) returning null

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
}
 
J

Jon Skeet [C# MVP]

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".
 
A

Arne Vajhøj

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
 
V

VC

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

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

Merry Christmas!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top