How to get an handle on an out-of-process COM component ?

O

Oriane

Hi there,

I get a reference on a out-of-process COM (exe) component. The generated
interop dll displays the methods but no constructor is available. So how can
I have an handle on the running component ?

Best regards
 
A

Alvin Bruney [ASP.NET MVP]

No difference, make sure your assembly is COM visible and that it has a
public parameterless constructor. With that, you simply new an object on it,
you don't need to call the constructor explicitly in most cases.

--

Regards,
Alvin Bruney [MVP ASP.NET]

[Shameless Author plug]
Download OWC Black Book, 2nd Edition
Exclusively on www.lulu.com/owc $15.00
Need a free copy of VSTS 2008 w/ MSDN Premium?
http://msmvps.com/blogs/alvin/Default.aspx
 
O

Oriane

Hi Alvin,
"Alvin Bruney [ASP.NET MVP]" <vapor dan using hot male spam filter> a écrit
dans le message de
No difference, make sure your assembly is COM visible and that it has a
public parameterless constructor. With that, you simply new an object on
it, you don't need to call the constructor explicitly in most cases.
I don't really understand your answer. Which assembly do you talk about ? I
wrote that the Visual Studio 2008 generated assembly has no constructor
(public, private or parameterless...). So the New simply doesn't compile.

Best regards
 
O

Oriane

Ok let's rephrase this: the *class* I want to instantiate has no constructor
(of course I don't need an "assembly constuctor" !).
 
O

Oriane

I think you think I want to expose a .Net assembly as a COM component. What
I want is the exact contrary: I have a COM component and I want to reference
it inside a .net project.

So I have add the COM exe component as a reference on my .net project with
Visual Studio 2008, which produced an interop dll assembly (with tlbimp.exe)
.. I want then to instantiate a .net class inside this assembly, but the only
constructor is internal. So I'm stuck...
 
O

Oriane

Finally (and I apologize for these many answers !!!!) I think that the
problem is not on my side. A colleague of mine has made the COM component in
VB 6. How can he change its code to make the classes inside its component
"public" so that "tlbimp.exe" can expose a public non-internal constructor ?

Best regards and many thanks
 
A

Alvin Bruney [ASP.NET MVP]

You can't change the code otherwise you would have recompile the dll. If you
add a reference to VB6.dll for instance. In your c# project, add a using
statement > using vb6.dll; In the body of your code do something like
VB6.SomeClass sc = new VB6.SomeClass();
sc.useSomeMethod();

That should work for you.

--

Regards,
Alvin Bruney [MVP ASP.NET]

[Shameless Author plug]
Download OWC Black Book, 2nd Edition
Exclusively on www.lulu.com/owc $15.00
Need a free copy of VSTS 2008 w/ MSDN Premium?
http://msmvps.com/blogs/alvin/Default.aspx
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top