adding a COM dll as reference during runtime

  • Thread starter Thread starter shubhlu
  • Start date Start date
S

shubhlu

hi

I have a problem that I have a COM dll and i need to access the
methods in that dll. But what is required here is that the dll needs
to be added as a reference only during runtime and not like they are
generally added (Project-->Add Reference-->COM). Is it possible to do
that?

Please help me out on this matter.

Thanks and regards

krish
 
I have a problem that I have a COM dll and i need to access the
methods in that dll. But what is required here is that the dll needs
to be added as a reference only during runtime and not like they are
generally added (Project-->Add Reference-->COM). Is it possible to do
that?

Well a reference is by definition a compile time thing. But you can
certainly instantiate COM objects dynamically at runtime and call them
assuming they support late binding with IDispatch.

Use Type.GetTypeFromProgID/CLSID to find the COM type, instantiate
with Activator.CreateInstance and call its methods using reflection
(Type.InvokeMember etc).


Mattias
 
krish,

I am kind of curious why you think you can't add a reference at
compile-time. What is it that prevents you from doing so?
 
hi nicholas

thnx a lot for answering back

actually i am a beginner so am not very sure wat exactly is the problem
anyways can u plz do me the favour of explaining how to add a COM dll
during runtime. if u can plz send me some code snippet as example

thnks and regards

krish
 
Back
Top