471,328 Members | 1,915 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,328 software developers and data experts.

Creating COM server with C#

m.a
Hello,

Where can I find detail information about how I can create a COM server
with C#? Is there any tutorial or any book in this subject?

I am using MSVC 2005 professional or MSVC 2008 express.

Thanks


Jun 27 '08 #1
6 1028
You cannot AFAIK write a native COM server in C#.

What you *can* do is write a "serviced component" (i.e. a COM+ dll that
you can host as a COM+ application in "Component Services".

http://msdn.microsoft.com/en-us/library/ty17dz7h.aspx

Alternatively, you can use a COM-server compatible framework to write a
shim COM server to the managed (.NET) COM library (dll); for
quick'n'dirty jobs I've used VB6 for this; or C++ if you are literate
with it (I'm not very...).

Marc
Jun 27 '08 #2
m.a

"Marc Gravell" <ma**********@gmail.comwrote in message
news:ep**************@TK2MSFTNGP06.phx.gbl...
You cannot AFAIK write a native COM server in C#.

What you *can* do is write a "serviced component" (i.e. a COM+ dll that
you can host as a COM+ application in "Component Services".

http://msdn.microsoft.com/en-us/library/ty17dz7h.aspx

Alternatively, you can use a COM-server compatible framework to write a
shim COM server to the managed (.NET) COM library (dll); for quick'n'dirty
jobs I've used VB6 for this; or C++ if you are literate with it (I'm not
very...).

Marc

Thanks Marc,
What is the difference between COM and COM+? I want to use my COM in
matlab. Can I write COM+?

Regards
Jun 27 '08 #3
In many simple cases, not a huge amount - you're simply piggy-backing
off COM+'s ability to host a library in a host exe as a service. But
COM+ has support for a lot of things like transaction support (think:
DTC / TransactionScope). You don't have to use them, though.

As for matlab, no idea; but the point is that COM+ acts as the COM
server. So it might be wroth a try with a quick test project (just don't
write everything until you know the concept is sound).

Marc
Jun 27 '08 #4
m.a wrote:
"Marc Gravell" <ma**********@gmail.comwrote in message
news:ep**************@TK2MSFTNGP06.phx.gbl...
>You cannot AFAIK write a native COM server in C#.

What you *can* do is write a "serviced component" (i.e. a COM+ dll that
you can host as a COM+ application in "Component Services".

http://msdn.microsoft.com/en-us/library/ty17dz7h.aspx

Alternatively, you can use a COM-server compatible framework to write a
shim COM server to the managed (.NET) COM library (dll); for quick'n'dirty
jobs I've used VB6 for this; or C++ if you are literate with it (I'm not
very...).

Marc


Thanks Marc,
What is the difference between COM and COM+? I want to use my COM in
matlab. Can I write COM+?

Regards

It is pretty easy to expose interfaces as COM. You just need to decorate
the interface and or its methods with [ComVisible(true)] following is an
example interface.
[ComVisible(true)]
public interface ITypeDefinition : IDisposable
{
/// <summary>
/// Get the name of this type
/// </summary>
String TypeName{get;}
}

Once you have the assembly built you can use the regasm tool to register it.

Use help on ComVisible and regasm to find out the details. You might
check www.codeproject.com for examples. I find most everything I have
questions about has some sort of example there.

Hope that helps.
Leon Lambert
Jun 27 '08 #5
Yes, exposing as COM is tricky - but exposing as a COM *server* (exe) as
opposed to a COM *library* (dll) is the tricky bit.

Of course, it is entirely possible that the OP hasn't used "server" as a
technical term, but simply means "COM", in which case a library should
work fine.

Marc
Jun 27 '08 #6
Of course - maybe I am using the term incorrectly ;-p

I'll use different terms...

If you just need a callable COM object, then yes, it is easy. If you
need it to be out-of-process, then it is harder.

Marc
Jun 27 '08 #7

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

7 posts views Thread by mike | last post: by
6 posts views Thread by Jerry Spence1 | last post: by
reply views Thread by Peter D. Dunlap | last post: by
12 posts views Thread by Mats Lycken | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.