C# and COM

  • Thread starter Thread starter Joe
  • Start date Start date
J

Joe

Hello,
I have to create an interface to allow another application to communicate
with ours. I'm thinking of adding a COM interface into our exe to allow this
but I'm not sure this is the best way to go.

The other application needs to be able to launch ours, send it some data and
call some configuration methods.

Any suggestions?

Thanks,
Joe
 
If your other application is not written in a managed language (like C#) this
is likely the only option.

If your other application is written in a manage language (like C) I would
recommend simply using class libraries and reference them directly and not
use COM directly.
 
Hello Joe,

As Peter suggested, if the .NET assembly will be consumed by native
executables, we can register the .NET assembly as COM server.

Regarding how to register the .NET assembly as COM server, please refer to
the following articles:

MSDN: COM Interop Part2: C# Server Tutorial
http://msdn2.microsoft.com/en-us/library/aa645738(VS.71).aspx

codeproject: Calling Managed .NET C# COM Objects from Unmanaged C++ Code
http://www.codeproject.com/KB/cs/ManagedCOM.aspx

I hesitated to recommend that codeproject article because it has an error
in its sample code. The interface IMyDotNetInterface and the class
MyDotNetClass should be declared as public. However, this article
demonstrates how to use regasm
(http://msdn2.microsoft.com/en-us/library/tzat5yw6(VS.71).aspx) to generate
and register tlb (type library).

If you have any other questions or concerns, please feel free to let me
know.

Regards,
Jialiang Ge ([email protected], remove 'online.')
Microsoft Online Community Support

Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
(e-mail address removed).

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
 
Hello,

Currently the application that needs to interact with ours is a .NET
application written in C#. We want the application to be able to launch our
application out of proc. If they just reference our application using a
standard .NET reference then they can call all our applications methods but
it's within their memory space. We don't really want this.

Is this our only option when it comes to .NET calling .NET?

Thanks,
Joe
 
You could consider wrapping the COM with a C# wrapper then remoting that
wrapper from a service. The code running the COM would then be out of
process with your application, but you would have a fair amount of calling
overhead and complexity added in. Of course on the upside you could have
that service running anywhere in the network.
 
Hello Joe and Christopher,

I agree with Christopher's idea. .NET Remoting can help us do the
out-of-proc call from .NET to .NET. Another solution is to use DCOM.

See how to write a DCOM server in C#:
http://blogs.msdn.com/adioltean/archive/2004/06/18/159479.aspx

and how to consume the DCOM server in a C# client:
http://www.thescripts.com/forum/thread49121.html

Regards,
Jialiang Ge ([email protected], remove 'online.')
Microsoft Online Community Support

=================================================
Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
(e-mail address removed).

This posting is provided "AS IS" with no warranties, and confers no rights.
=================================================
 
Joe said:
Hello,
I have to create an interface to allow another application to communicate
with ours. I'm thinking of adding a COM interface into our exe to allow
this but I'm not sure this is the best way to go.

The other application needs to be able to launch ours, send it some data
and call some configuration methods.

Any suggestions?

Thanks,
Joe



What kind of application is this? Interactive or not?
If the other applications are .NET only there is no need to expose this
through COM, this is only required when you want to expose functionality to
non .NET application.

Willy.
 
Hi Joe,

I am writing to check the status of the issue. Would you mind letting me
know the result of the suggestions? If you need further assistance, feel
free to let me know. I will be more than happy to be of assistance.

Have a great day!

Regards,
Jialiang Ge ([email protected], remove 'online.')
Microsoft Online Community Support

=================================================
Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
(e-mail address removed).

This posting is provided "AS IS" with no warranties, and confers no rights.
=================================================
 

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

Back
Top