Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
CreateObject
Message
De
12/04/2006 09:54:42
 
Information générale
Forum:
ASP.NET
Catégorie:
Code, syntaxe and commandes
Titre:
Divers
Thread ID:
01112449
Message ID:
01112877
Vues:
13
Eric,

I may be misunderstanding what you want to do, but it sounds like you just want to cast the object to the correct type (I'm assuming, maybe incorrectly, that you know what that type should be?)
Type t = Type.GetTypeFromProgID(cProdID)
MyBaseObject MyClass = (MyBaseObject)Activator.CreateInstance(t)
~~Bonnie


>In this case I want to create an object from a registered VFP DLL. But not referenced as an Interop Assembly. I need VFP objects available in a windows service app. I want to pause the service, rebuild my DLLs then continue the service. This works fine if I re-add the reference in the service project and rebuild the service but it's not practical to do that. I tried this:
>
>Type t = Type.GetTypeFromProgID(cProdID)
>object MyClass = Activator.CreateInstance(t)
>
>The trouble is the IDE doesn't recognize the typeof Myclass until runtime. It only sees typeof object not the type represented in cProgID.
>
>I think I need to declare MyClass as the typeof(cProgID) but i'm having trouble with the syntax.
>
>Thanks,
>
>-E
>
>
>
>
>>>Does anyone have a preferred way to create an object from a registered server?
>>>
>>>What is the equivalent of CreateObject in C#?
>>
>>new
>>
>>Cetin
Bonnie Berent DeWitt
NET/C# MVP since 2003

http://geek-goddess-bonnie.blogspot.com
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform