Re: COM Interop
- From: "kris" <krishm18@xxxxxxxxx>
- Date: Wed, 4 Jul 2007 11:06:50 +0530
Hi Himangi,
I am facing with some problems when i say Activator.CreateInstance(appType);
When i am calling this function , i need to cast the object to some class
name in my component.
Because i am not referencing this component anywhere in my program , i am
getting a compile time error saying
"The type or namespace name could not found , are you missing some
reference."
check the code statement below.
MyClass instance = (MyClass)Activator.CreateInstance(appType);
//if the above line succeeds , then i will call a function as below.
//instance.SomeMethod()
Can you please suggest me on this.
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Type appType = Type.GetTypeFromProgID("Your COM PROGID");//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
instance = Activator.CreateInstance(appType);
After this, use Reflection to invoke the methods/properties of the COM
object ('instance')
Thanks & Regards
Kris
"G Himangi" <info@xxxxxxxxxx> wrote in message
news:OE288ZWvHHA.4736@xxxxxxxxxxxxxxxxxxxxxxx
Its possible to do this via late-binding if your COM object supports
Automation.
Then you can use :
Type appType = Type.GetTypeFromProgID("Your COM PROGID");
instance = Activator.CreateInstance(appType);
After this, use Reflection to invoke the methods/properties of the COM
object ('instance')
---------
- G Himangi, Sky Software http://www.ssware.com
Shell MegaPack : GUI Controls For Drop-In Windows Explorer like Shell
Browsing Functionality For Your App (.Net & ActiveX Editions).
EZNamespaceExtensions.Net : Develop namespace extensions rapidly in .Net
EZShellExtensions.Net : Develop all shell extensions,explorer bars and
BHOs rapidly in .Net
---------
"kris" <krishm18@xxxxxxxxx> wrote in message
news:%235PzkXJvHHA.3588@xxxxxxxxxxxxxxxxxxxxxxx
Hi ,
I am trying to reference a COM dll ( x.dll) from my C# code.
I have to do this programatically at runtime and access its functions.
( Not through Project-->Add Reference->COM-------etc that we do through
visual studio).
Can anyone help me , how i can do this.
Regards
Kris
.
- References:
- COM Interop
- From: kris
- Re: COM Interop
- From: G Himangi
- COM Interop
- Prev by Date: Re: Enum
- Next by Date: Re: Read-Only Word document in AxWebBrowser
- Previous by thread: Re: COM Interop
- Next by thread: Prevent embedded Word instance resizing for invisible task pane
- Index(es):
Relevant Pages
|