Re: COM Interop



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








.



Relevant Pages

  • Re: CALL using OMITTED
    ... look for ways that Cobol can help with this. ... invoke MyCollection "new" returning CollectionObject ... I've never done it so I don't know the full implications - hopefully it creates a unique reference in the first Collection without impacting the second. ... Procedure Div using.... ...
    (comp.lang.cobol)
  • Re: Clams before Columbus
    ... In my review of Nielsen/Scott on the Kensington Rune Stone I ... of the Skaw in northern Jutland, ... shell found in a sand dune, ... That's where I got the original reference that I went to see. ...
    (sci.archaeology)
  • Re: Clams before Columbus
    ... I asked "Where are the clams from ... ONE shell found in a sand dune, ... That's where I got the original reference that I went to see. ... be fragments on one beach in Denmark, such that she is able to identify ...
    (sci.archaeology)
  • Re: Clams before Columbus
    ... I asked "Where are the clams from ... shell found in a sand dune, ... the authors suggest that it might even be younger than Columbus. ... The reference may be valid. ...
    (sci.archaeology)
  • Re: new block notation (was: Re: ruby-dev summary 26468-26661)
    ... It is possible to invoke all three in an arbitrary scope (where 'self' and instance variables refer to a specific, runtime-chosen instance of any class) by passing them as a block to a special ... It is possible to get a reference to a method and assign it to a variable. ... It is possible to invoke a method reference in the scope of the instance to which it is tied without supplying the instance as a receiver. ... Lambdas are not associated with any specific instance. ...
    (comp.lang.ruby)