467,173 Members | 1,356 Online
Bytes | Developer Community
Ask Question

Home New Posts Topics Members FAQ

Post your question to a community of 467,173 developers. It's quick & easy.

correct overloaded version for Activator.CreateInstance? I am getting "Constructor on type xxx not found."

Is Activator.CreateInstance(t,BindingFlags.Public | BindingFlags.InvokeMethod | BindingFlags.CreateInstance, null, args, null) appropriate given the following;

**************************************

public interface IPasswordProvider
{
string GetPassword(Token token);
}

public DBPassword()
{
// constructor logic goes here
}

**************************************
public string GetPassword(Token token)
{
string sPassword;
sPassword = "password";
return sPassword;
}

**************************************

and what I have to include as an argument to pass to the GetPassword() is an instance of the following class;

public class Token
{
protected string m_strPWD;
public Token()
{
}
public string Password
{
get
{
return m_strPWD;
}

set
{
m_strPWD=value;
}
}

**************************************

for which I am attempting something like;

Token tkn = new Token();

tkn.Password = "password";

object[] args = {tkn };

but when I utilize this along with Activator.CreateInstance(t,BindingFlags.Public | BindingFlags.InvokeMethod | BindingFlags.CreateInstance, null, args, null),

I get the following - {"Constructor on type DBPasswordProvider.IPasswordProvider not found." } System.Exception

**************************************

Any help will be very much appreciated...

Thank you,

-Greg

Nov 16 '05 #1
  • viewed: 5247
Share:
3 Replies
but when I utilize this along with Activator.CreateInstance(t,BindingFlags.Public | BindingFlags.InvokeMethod | BindingFlags.CreateInstance, null, args, null),

I get the following - {"Constructor on type DBPasswordProvider.IPasswordProvider not found." } System.Exception


Which type does the t variable represent here? If it's
typeof(IPasswordProvider) then the error message makes sense, since
interfaces don't have constructors.

Mattias

--
Mattias Sjögren [MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.
Nov 16 '05 #2
Thank you Mattias! As a follow up to that is it necessary to take the
interface out of the assembly?
Appreciatively,
-Greg

"Mattias Sjögren" <ma********************@mvps.org> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...
but when I utilize this along with Activator.CreateInstance(t,BindingFlags.Public | BindingFlags.InvokeMethod |
BindingFlags.CreateInstance, null, args, null),
I get the following - {"Constructor on type
DBPasswordProvider.IPasswordProvider not found." } System.Exception
Which type does the t variable represent here? If it's
typeof(IPasswordProvider) then the error message makes sense, since
interfaces don't have constructors.

Mattias

--
Mattias Sjögren [MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.

Nov 16 '05 #3
I removed the interface from the assembly and the reference to the interface
and still get the same error.
I am thinking that this is a generic error message and that the real problem
is that one of the arguments I am passing is not correct. Like the args for
example. I am trying to pass in my token object and it may not like
that....
Thanks you for any comments or ideas.
-Greg

"Mattias Sjögren" <ma********************@mvps.org> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...
but when I utilize this along with Activator.CreateInstance(t,BindingFlags.Public | BindingFlags.InvokeMethod |
BindingFlags.CreateInstance, null, args, null),
I get the following - {"Constructor on type
DBPasswordProvider.IPasswordProvider not found." } System.Exception
Which type does the t variable represent here? If it's
typeof(IPasswordProvider) then the error message makes sense, since
interfaces don't have constructors.

Mattias

--
Mattias Sjögren [MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.

Nov 16 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

6 posts views Thread by Sean Hamilton | last post: by
1 post views Thread by Soheil | last post: by
1 post views Thread by bob@coolgroups.com | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.