Dinamically creating instance of object..reflection. 
Author Message
 Dinamically creating instance of object..reflection.

I am trying to create an instance of an object that is declared
in my assembly.

Seems I can get the object, but the type of the object seems to
be System.Runtime.Type instead of the type I asked for. This causes
problems later on.

The code to get the type is as follows:

mNodos.Add(Reflection.Assembly.GetExecutingAssembly.GetType("solution.myname
space.object"))

am I doing something wrong ? (you can Ignore the mNodos.Add() call)

thanks

--
edmz



Mon, 13 Sep 2004 07:11:37 GMT  
 Dinamically creating instance of object..reflection.


Quote:
> I am trying to create an instance of an object that is declared
> in my assembly.

> Seems I can get the object, but the type of the object seems to
> be System.Runtime.Type instead of the type I asked for. This causes
> problems later on.

> The code to get the type is as follows:

> mNodos.Add(Reflection.Assembly.GetExecutingAssembly.GetType("solution.myname
> space.object"))

> am I doing something wrong ? (you can Ignore the mNodos.Add() call)

I think reflection assumes you're going to at least know the type of
object you're going to be instantiating.  The object you get back from
Activator.CreateInstance() is then cast (by you) to the proper object
type when making function calls.

--
Patrick Steele
Microsoft .NET MVP



Tue, 14 Sep 2004 02:11:37 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Using reflection to create class instance

2. Create Object At RunTime (Error) adding news propertys dinamically

3. Creating an object instance from a Type object

4. Reflection Question How to Call a Methode of a Member without Createing a new instance

5. Reflection issue: Getting instances of a Type?

6. Create a CommandButton dinamically

7. Question about creating controls dinamically

8. creating instances of objects

9. Using Same instance of an Object created by Client in the Server

10. Problem about Creating an Instance of an object.

11. Specify server when creating DCOM objects instances in VB

12. How to create a single instance of an object in VB

 

 
Powered by phpBB® Forum Software