Article View: borland.public.csharpbuilder.language.csharp
Article #192Re: Activator.CreateInstance MissingMethodException
From: Joanna Carter [TeamB]
Date: Wed, 01 Nov 2006 17:45
Date: Wed, 01 Nov 2006 17:45
39 lines
1917 bytes
1917 bytes
"Raul Lorenzo" <rlorenb@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
Technical Details
Message-ID:
<4548dd31$1@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!g2news2.google.com!news2.google.com!news3.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newshub.sdsu.edu!logbridge.uoregon.edu!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mailReferences:
<4548891f$1@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Thread: 1efe35,41949b2c5311c67b X-Google-Attributes: gid1efe35,public X-Google-Language: ENGLISH,ASCII From: "Joanna Carter [TeamB]" <joanna@not.for.spam> Newsgroups: borland.public.csharpbuilder.language.csharp References: <4548891f$1@newsgroups.borland.com> Subject: Re: Activator.CreateInstance MissingMethodException Date: Wed, 1 Nov 2006 17:45:15 -0000 Lines: 41 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2900.2180 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2180 NNTP-Posting-Host: 82.69.239.102 Message-ID: <4548dd31$1@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1162403121 82.69.239.102 (1 Nov 2006 09:45:21 -0700) X-Authenticated-User: jcarter Path: arc1-ca.pugleaf.net!g2news2.google.com!news2.google.com!news3.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newshub.sdsu.edu!logbridge.uoregon.edu!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail