Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Activator.CreateInstance MissingMethodException

8 views
Skip to first unread message

Raul Lorenzo

unread,
Nov 1, 2006, 6:46:57 AM11/1/06
to
Hello,

I am trying creating a class dynamically at runtime with
Activator.CreateInstance(ObjType); where ObjType is retrieved through

foreach (Type tipo in ass.GetTypes())
{
ObjType=tipo.GetType();
tmp=(IPlugin)Activator.CreateInstance(ObjType);
}

ObjType is "linked" with per example this class

public class PersonaUserControlController:AbstractUserControlController
{
private IAlumnosUseCase model;
private IPersonaUserControl view;
public PersonaUserControlController()
{
//
// TODO: Add constructor logic here
//
this.model =
(IAlumnosUseCase)UseCaseFactory.getInstance().getUseCase("AlumnosUseCase");
this.view =
(IPersonaUserControl)UserControlFactory.getInstance().getUserControl("PersonaUserControl");
plugin_name = "PersonaUserControl";
ConfigureMenu();
}
...more methods but only one constructor
}

/***************************************************************/
I think this could help....

abstract public class
AbstractUserControlController:AbstractPlugin,IUserControlController
{
}

abstract public class AbstractPlugin:IPlugin
{
}

/***************************************************************/
Why did exception raises if one constructor exists and without parameters?

Thanks in advance

Joanna Carter [TeamB]

unread,
Nov 1, 2006, 12:45:15 PM11/1/06
to
"Raul Lorenzo" <rlo...@agalisa.es> a écrit dans le message de news:
4548891f$1...@newsgroups.borland.com...

| I am trying creating a class dynamically at runtime with
| Activator.CreateInstance(ObjType); where ObjType is retrieved through
|
| foreach (Type tipo in ass.GetTypes())
| {
| ObjType=tipo.GetType();
| tmp=(IPlugin)Activator.CreateInstance(ObjType);
| }

I think your problem is that you are getting the type of System.Type !!

foreach (Type tipo in ass.GetTypes())
{

// assuming tipo now contains the type that you want to create...

| ObjType=tipo.GetType();

// ObjType now contains System.Type as that would be the type of tipo.

| tmp=(IPlugin)Activator.CreateInstance(ObjType);
| }

I think you need to remove one line of code like this :

foreach (Type tipo in ass.GetTypes())
{

tmp=(IPlugin)Activator.CreateInstance(tipo);
}

Joanna

--
Joanna Carter [TeamB]
Consultant Software Engineer


0 new messages