[lnkForumImage]
TotalShareware - Download Free Software

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


 

Forums >

microsoft.public.dotnet.framework.interop

change coclass in COM Assembly

herc

6/14/2007 3:23:00 PM

I have a .Net 1.1 assembly that is being exposed/packaged as a COM
object. Interally there is a class "Dog" that to the outside world I
want them to see "Cat". Back in the world of unmanaged C++ this is
easy to do, simply change the name in the idl file from Dog to Cat and
change any references to CLSID_Dog to CLSID_Cat. Is there any way to
do this in C#?

Cartoper

6 Answers

(Mattias Sjögren)

6/14/2007 9:02:00 PM

0

>I have a .Net 1.1 assembly that is being exposed/packaged as a COM
>object. Interally there is a class "Dog" that to the outside world I
>want them to see "Cat". Back in the world of unmanaged C++ this is
>easy to do, simply change the name in the idl file from Dog to Cat and
>change any references to CLSID_Dog to CLSID_Cat. Is there any way to
>do this in C#?

You can still create your typelib from an IDL file and customize it in
any way you want. You don't have to use the typelib that
VS/Tlbexp/Regasm creates for you.


Mattias

--
Mattias Sjögren [C# MVP] mattias @ mvps.org
http://www.msjogren.n... | http://www.dotneti...
Please reply only to the newsgroup.

herc

6/15/2007 1:31:00 PM

0

On Jun 14, 5:02 pm, Mattias Sj?gren <mattias.dont.want.s...@mvps.org>
wrote:
> >I have a .Net 1.1 assembly that is being exposed/packaged as a COM
> >object. Interally there is a class "Dog" that to the outside world I
> >want them to see "Cat". Back in the world of unmanaged C++ this is
> >easy to do, simply change the name in the idl file from Dog to Cat and
> >change any references to CLSID_Dog to CLSID_Cat. Is there any way to
> >do this in C#?
>
> You can still create your typelib from an IDL file and customize it in
> any way you want. You don't have to use the typelib that
> VS/Tlbexp/Regasm creates for you.

Mattias,

I am doing that with my interfaces, how do I tie coclass in the IDL to
a C# class?

Ben Voigt [C++ MVP]

6/15/2007 7:21:00 PM

0

Via the UUID, same as always.


"herc" <cartoper@gmail.com> wrote in message
news:1181914254.786581.42480@u2g2000hsc.googlegroups.com...
On Jun 14, 5:02 pm, Mattias Sjögren <mattias.dont.want.s...@mvps.org>
wrote:
> >I have a .Net 1.1 assembly that is being exposed/packaged as a COM
> >object. Interally there is a class "Dog" that to the outside world I
> >want them to see "Cat". Back in the world of unmanaged C++ this is
> >easy to do, simply change the name in the idl file from Dog to Cat and
> >change any references to CLSID_Dog to CLSID_Cat. Is there any way to
> >do this in C#?
>
> You can still create your typelib from an IDL file and customize it in
> any way you want. You don't have to use the typelib that
> VS/Tlbexp/Regasm creates for you.

Mattias,

I am doing that with my interfaces, how do I tie coclass in the IDL to
a C# class?

herc

6/18/2007 8:58:00 PM

0

On Jun 15, 3:20 pm, "Ben Voigt [C++ MVP]" <r...@nospam.nospam> wrote:
> Via the UUID, same as always.

So you are saying that the UUID that is assigned to the coclass should
be assigned in an attribute to the class in the C# code, correct?

The problem I am trying to solve is this: I am trying to write some
services in .Net that use to be written in VB6 and unmanaged C++. The
kicker is that the class name of the COM Object MUST be
"Application". There is a lot of code already in existence that
simply instantiates the object with the progid of <library
name>.Application.

Can the IDL/TLB contain a coclass of Application and then assign the
uuid of the coclass to a C# class of another name and all be well?

Cartoper

Ben Voigt [C++ MVP]

6/19/2007 3:23:00 AM

0


"herc" <cartoper@gmail.com> wrote in message
news:1182200264.912167.162840@g4g2000hsf.googlegroups.com...
> On Jun 15, 3:20 pm, "Ben Voigt [C++ MVP]" <r...@nospam.nospam> wrote:
>> Via the UUID, same as always.
>
> So you are saying that the UUID that is assigned to the coclass should
> be assigned in an attribute to the class in the C# code, correct?
>
> The problem I am trying to solve is this: I am trying to write some
> services in .Net that use to be written in VB6 and unmanaged C++. The
> kicker is that the class name of the COM Object MUST be
> "Application". There is a lot of code already in existence that
> simply instantiates the object with the progid of <library
> name>.Application.
>
> Can the IDL/TLB contain a coclass of Application and then assign the
> uuid of the coclass to a C# class of another name and all be well?
>

It should, because COM knows nothing of the internal .NET metadata. Have
you tried and run into trouble?

> Cartoper
>

(Mattias Sjögren)

6/19/2007 4:28:00 AM

0

>The problem I am trying to solve is this: I am trying to write some
>services in .Net that use to be written in VB6 and unmanaged C++. The
>kicker is that the class name of the COM Object MUST be
>"Application". There is a lot of code already in existence that
>simply instantiates the object with the progid of <library
>name>.Application.

You can use the ProgIdAttribute to assign any ProgID you want to the
class. It doesn't have to match the actual class name.


Mattias

--
Mattias Sjögren [C# MVP] mattias @ mvps.org
http://www.msjogren.n... | http://www.dotneti...
Please reply only to the newsgroup.