H
hazz
this is a repost with a hopefully more clearly stated scenario and more
concise questions at the end.
given the following two classes, my intent is to use pass a token into the
instantiated class DBPassword and return a string;
**************************************
public class DBPassword
{
public DBPassword()
{
//Empty constructor
}
public string GetPassword(Token token)
{
string sPassword = "Howdy Doody";
return sPassword;
}
}
******************what I will pass into DB.GetPassword.GetPassword above
********************
public class Token
{
protected string m_strPWD;
public Token()
{
}
public string Password
{
get
{
return m_strPWD;
}
set
{
m_strPWD=value;
}
}
**************************************
Token tkn = new Token();
tkn.Password = "password";
object[] args = {tkn}; //This is my intention, how do I do this?
Assembly assmbly = Assembly.LoadFrom("O:\\DBPassword\\DBPassword.dll");
Type[] types = assmbly.GetTypes();
foreach (Type t in types)
{
mi = t.GetMethod("GetPassword");
if (mi != null)
{
DBPassword ppdr =
(DBPassword)Activator.CreateInstance(t,BindingFlags.Public |
BindingFlags.InvokeMethod | BindingFlags.CreateInstance, null, args, null);
**************************************
When I run the above, "Constructor on type DBPasswordProvider.DBPassword not
found." } System.Exception is thrown.
Why would this exception be thrown? There is a constructor for public
DBPassword.
Should I use Activator.CreateInstance or InvokeMember?
How do I pass in the token as an arg if I do use CreateInstance?
Which of the 9 overloaded versions of Activator.CreateInstance would I
choose for this?
Thank you very much,
-Greg
p.s. I cross-posted with the remoting newsgroup as I wasn't sure which was
the best newsgroup for this question.
concise questions at the end.
given the following two classes, my intent is to use pass a token into the
instantiated class DBPassword and return a string;
**************************************
public class DBPassword
{
public DBPassword()
{
//Empty constructor
}
public string GetPassword(Token token)
{
string sPassword = "Howdy Doody";
return sPassword;
}
}
******************what I will pass into DB.GetPassword.GetPassword above
********************
public class Token
{
protected string m_strPWD;
public Token()
{
}
public string Password
{
get
{
return m_strPWD;
}
set
{
m_strPWD=value;
}
}
**************************************
Token tkn = new Token();
tkn.Password = "password";
object[] args = {tkn}; //This is my intention, how do I do this?
Assembly assmbly = Assembly.LoadFrom("O:\\DBPassword\\DBPassword.dll");
Type[] types = assmbly.GetTypes();
foreach (Type t in types)
{
mi = t.GetMethod("GetPassword");
if (mi != null)
{
DBPassword ppdr =
(DBPassword)Activator.CreateInstance(t,BindingFlags.Public |
BindingFlags.InvokeMethod | BindingFlags.CreateInstance, null, args, null);
**************************************
When I run the above, "Constructor on type DBPasswordProvider.DBPassword not
found." } System.Exception is thrown.
Why would this exception be thrown? There is a constructor for public
DBPassword.
Should I use Activator.CreateInstance or InvokeMember?
How do I pass in the token as an arg if I do use CreateInstance?
Which of the 9 overloaded versions of Activator.CreateInstance would I
choose for this?
Thank you very much,
-Greg
p.s. I cross-posted with the remoting newsgroup as I wasn't sure which was
the best newsgroup for this question.