Home All Groups Group Topic Archive Search About

Invoking Class from a variable string in VB 2005...!

Author
19 Aug 2006 11:02 PM
Gustavo Arriola
Hello to all!
I am trying to accede to a method of a class invoking(the class) from a
variable string.  The class is in other assembly called "infoInsumo"

The code:

Dim Tipo As Type = Type.GetType(Nodo) 'Nodo = "infoInsumo,
infoInsumo" -->The assembly  does not have root namespace
Dim Clase As Object = Activator.CreateInstance(Tipo,
Reflection.BindingFlags.CreateInstance)

But in line "2" the following error jumps to me:

Constructor on type 'infoInsumo' not found.

What implementation I must make in the contructor of the class (infoInsumo)
so that it can obtain my objective?

From already thank you very much!
Gustavo Arriola

Author
20 Aug 2006 12:07 AM
tommaso.gastaldi
Make sure you have a reference to the DLL
and that the class is public.

Tommaso

Gustavo Arriola ha scritto:

Show quoteHide quote
> Hello to all!
> I am trying to accede to a method of a class invoking(the class) from a
> variable string.  The class is in other assembly called "infoInsumo"
>
> The code:
>
> Dim Tipo As Type = Type.GetType(Nodo) 'Nodo = "infoInsumo,
> infoInsumo" -->The assembly  does not have root namespace
> Dim Clase As Object = Activator.CreateInstance(Tipo,
> Reflection.BindingFlags.CreateInstance)
>
> But in line "2" the following error jumps to me:
>
> Constructor on type 'infoInsumo' not found.
>
> What implementation I must make in the contructor of the class (infoInsumo)
> so that it can obtain my objective?
>
> From already thank you very much!
> Gustavo Arriola
Author
20 Aug 2006 12:54 AM
Gustavo Arriola
If, I have created a reference from VS 2005 and class she is public!
What I must do now?

From already thank you very much!
Gustavo
Author
20 Aug 2006 7:36 AM
tommaso.gastaldi
Use fully qualified name of the Type:

"YourClass, YourAssembly"

(or
"YourNamespace.YourClass, YourAssembly")

can also use:
objType.Assembly.FullName.ToString

see:

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemtypeclassassemblyqualifiednametopic.asp

Tommaso

Gustavo Arriola ha scritto:

Show quoteHide quote
> If, I have created a reference from VS 2005 and class she is public!
> What I must do now?
>
> From already thank you very much!
> Gustavo
Author
20 Aug 2006 7:58 AM
tommaso.gastaldi
or also

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemtypeclassfullnametopic.asp

tommaso.gasta***@uniroma1.it ha scritto:

Show quoteHide quote
> Use fully qualified name of the Type:
>
> "YourClass, YourAssembly"
>
> (or
> "YourNamespace.YourClass, YourAssembly")
>
> can also use:
> objType.Assembly.FullName.ToString
>
> see:
>
> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemtypeclassassemblyqualifiednametopic.asp
>
> Tommaso
>
> Gustavo Arriola ha scritto:
>
> > If, I have created a reference from VS 2005 and class she is public!
> > What I must do now?
> >
> > From already thank you very much!
> > Gustavo