471,339 Members | 1,312 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

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

Can I expose my API/COM interfaces as .Net interfaces?

Hi.

I'm really new to this world of .Net so your help would be most
appreciated...

We have API and COM interfaces developed in c. We would also like to
supply a .net interface to our clients.

Searching - I found many new words :-) like .Net wrapper, Assembly...
but I couldn't find a clear cut answer -
What do I need to do in order to expose a .net interface?

What is the difference between "real" .NET APIs and having some kind of
wrapper around API or COM interface...?

Thanks in advance
Rakefet

Aug 16 '05 #1
6 1796
Try these
CCW (Com callable wrappers) and RCW( Run time callable wrappers)

I think you will be quiet near

Shivprasad Koirala
C# , VB.NET , SQL SERVER , ASP.NET Interview Questions
http://www.geocities.com/dotnetinterviews/

Aug 16 '05 #2
Hi, yes Rakefet, COM interfaces can be exposed quite easily to the .Net
world. Here is something to help you get started...

http://www.codeproject.com/csharp/COMInteropNET.asp

--
Regards,

Tim Haughton

Agitek
http://agitek.co.uk
http://blogitek.com/timhaughton

<ra*****@repliweb.com> wrote in message
news:11**********************@g14g2000cwa.googlegr oups.com...
Hi.

I'm really new to this world of .Net so your help would be most
appreciated...

We have API and COM interfaces developed in c. We would also like to
supply a .net interface to our clients.

Searching - I found many new words :-) like .Net wrapper, Assembly...
but I couldn't find a clear cut answer -
What do I need to do in order to expose a .net interface?

What is the difference between "real" .NET APIs and having some kind of
wrapper around API or COM interface...?

Thanks in advance
Rakefet

Aug 16 '05 #3
Hi,

To use COM you need to do nothing, from VS you can access the COM classes
from Projects/Add References then VS will create the wrapper for you. If you
want to provide these wrapper you can do so, check
http://msdn.microsoft.com/library/de...allcomcomp.asp

Now the real problems are the APIs, I assume you mean native win32 dlls,
with this you cannot use the above approach, In this case classes in .NET
that mimics those dlls, inside the classes you will need to P/Invoke the
methods. If you define structures you will need to define them again in
..net.
P/Invoke can be tricky if you are using complex structures or calling
methods. You will need to read a lot about it, start with
http://msdn.microsoft.com/msdnmag/issues/03/07/NET/ also take a look at
www.pinvoke.net , very useful !!! you will get ideas of hwo you can marshall
parameters.
Cheers,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

<ra*****@repliweb.com> wrote in message
news:11**********************@g14g2000cwa.googlegr oups.com...
Hi.

I'm really new to this world of .Net so your help would be most
appreciated...

We have API and COM interfaces developed in c. We would also like to
supply a .net interface to our clients.

Searching - I found many new words :-) like .Net wrapper, Assembly...
but I couldn't find a clear cut answer -
What do I need to do in order to expose a .net interface?

What is the difference between "real" .NET APIs and having some kind of
wrapper around API or COM interface...?

Thanks in advance
Rakefet

Aug 16 '05 #4
You can add reference to a COM DLL to your project and the IDE will create
an interop wrapper assembly for you. It's a very simple and painless
process.

The difference will be that the COM interop assembly will set up sensible
managed / unmananged marshalling for you and provide .NET enumerations and
structures that you can use with the COM objects in your DLL. You can of
course do all of this by hand if you wish but generally the IDE which uses
TLBImp internally does a pretty good job.

--
Bob Powell [MVP]
Visual C#, System.Drawing

Ramuseco Limited .NET consulting
http://www.ramuseco.com

Find great Windows Forms articles in Windows Forms Tips and Tricks
http://www.bobpowell.net/tipstricks.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/faqmain.htm

All new articles provide code in C# and VB.NET.
Subscribe to the RSS feeds provided and never miss a new article.

<ra*****@repliweb.com> wrote in message
news:11**********************@g14g2000cwa.googlegr oups.com...
Hi.

I'm really new to this world of .Net so your help would be most
appreciated...

We have API and COM interfaces developed in c. We would also like to
supply a .net interface to our clients.

Searching - I found many new words :-) like .Net wrapper, Assembly...
but I couldn't find a clear cut answer -
What do I need to do in order to expose a .net interface?

What is the difference between "real" .NET APIs and having some kind of
wrapper around API or COM interface...?

Thanks in advance
Rakefet

Aug 16 '05 #5
ra*****@repliweb.com wrote:
We have API and COM interfaces developed in c. We would also like to
supply a .net interface to our clients.
What do I need to do in order to expose a .net interface?


Hi Rakefet. This is a common question. There are tools included with .NET
(tlbimp.exe) and Visual Studio (Add Reference->COM tab) to facilitate this
scenario. You can read more about using COM components from .NET at the
following URLs:

Interoperability of COM components with .NET
http://www.c-sharpcorner.com/Code/20...lityin.NET.asp

COM Interoperability in the .NET Framework
http://aspnet.4guysfromrolla.com/articles/010803-1.aspx

I hope this helps.
--
Derrick Coetzee, MCP, MSFT (Speech Server)
This posting is provided "AS IS" with no warranties, and confers no
rights.
Aug 17 '05 #6
Thanks a lot to everyone - the information was very helpful.

Rakefet

Aug 18 '05 #7

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by Prigozhin Roman | last post: by
3 posts views Thread by Miguel Ferreira via .NET 247 | last post: by
22 posts views Thread by RSH | last post: by
2 posts views Thread by Luiz | 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.