[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

kris

7/2/2007 10:42:00 AM

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




2 Answers

G Himangi

7/3/2007 11:40:00 AM

0

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....
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@yahoo.com> wrote in message
news:%235PzkXJvHHA.3588@TK2MSFTNGP06.phx.gbl...
> 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
>
>
>
>


kris

7/4/2007 5:37:00 AM

0

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@ssware.com> wrote in message
news:OE288ZWvHHA.4736@TK2MSFTNGP05.phx.gbl...
> 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....
> 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@yahoo.com> wrote in message
> news:%235PzkXJvHHA.3588@TK2MSFTNGP06.phx.gbl...
>> 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
>>
>>
>>
>>
>
>