Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
CreateObject
Message
 
To
12/04/2006 09:54:42
General information
Forum:
ASP.NET
Category:
Coding, syntax and commands
Title:
Miscellaneous
Thread ID:
01112449
Message ID:
01113012
Views:
12
Type t = Type.GetTypeFromProgID("ftpmanager.manageftp","localhost");
object FTPMan = (manageftp)Activator.CreateInstance(t);
In the above scenario the compiler does not understand that the type ftpmanager.manageftp is the type that FTPMan needs to be. It fails to compile and says I am missing an assembly reference. In this case I don't want to use an assembly reference, I want .net to create this type on the fly without a compiled Interop assembly. I also need the compiler to understand this type's members so I can build code to call methods on that type in other places in my class.

I think I need to brush up on reflection. ;P

>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
Eric Kleeman - EDS Consulting Services
MCP Visual FoxPro
MCSD C#.NET
Hua Hin Thailand
Los Angeles California
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform