473,411 Members | 2,093 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

is the best way to wrap C functions with mananged C++ or C#?

Hi,

As a newbie to .Net, I am interested in wrapping a library's C
functions to be accessible from .Net. These C functions take strings
as input and output parameters and may reallocate strings internally if
they need to be extended.

It appears that there are (at least) 2 ways to wrap my C functions.
The first way is to use managed C++ and create a .Net assembly. The
second way is to use C# to do the same thing.

My question is what are the advantages to either case assuming I now
C++ and C# equally well (or pooly)? Both would be accessible to any
..Net language and it would seem that I would be able to build a single
DLL if I used mananged C++ whereas I would need a separate DLL for my
C# wrapper. Are there other (dis)advantages I'm not considering?

Thanks,

Ted

Nov 17 '05 #1
1 1656
te**@intex.com wrote:
Hi,

As a newbie to .Net, I am interested in wrapping a library's C
functions to be accessible from .Net. These C functions take strings
as input and output parameters and may reallocate strings internally
if they need to be extended.

It appears that there are (at least) 2 ways to wrap my C functions.
The first way is to use managed C++ and create a .Net assembly. The
second way is to use C# to do the same thing.

My question is what are the advantages to either case assuming I now
C++ and C# equally well (or pooly)? Both would be accessible to any
.Net language and it would seem that I would be able to build a single
DLL if I used mananged C++ whereas I would need a separate DLL for my
C# wrapper. Are there other (dis)advantages I'm not considering?


You're probably better able to accomodate odd memory management requirements
using an MC++ wrapper, and the resulting solution should be slightly more
efficient due to differences between the IJW interop used by MC++ and the
PInvoke interop used by C#.

-cd
Nov 17 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

22
by: Simon | last post by:
Hi, I have written a function to trim char *, but I have been told that my way could be dangerous and that I should use memmove(...) instead. but I am not sure why my code could be 'dangerous'...
8
by: name | last post by:
Back again for more critique... <grin> ------------------------------------------------ #include <stdio.h> #include <stdlib.h> #include <string.h> #include <limits.h> #define MAX 10000
3
by: Robert Schuldenfrei | last post by:
Hi NG, I am looking for an opinion here. I am new to C# and SQL, being an old COBOL hand. I have started into a conversion of an old COBOL ERP system. I have a number of functions working now...
3
by: John Smith | last post by:
I wrote some code in C in a dll which I would like to call from C#. However I'm stuck because of the strongly typed behavior of C# which makes limitations. Here are the prototypes for two...
3
by: Marc Gravell | last post by:
Kind of an open question on best-practice for smart-client design. I'd really appreciate anyones views (preferably with reasoning, but I'll take what I get...). Or if anybody has any useful links...
3
by: FUGATO | last post by:
I need to help to wrap up text. I have a line all the text and I need to wrap the text with 40 characters each line but without using function. Somebody help me about that and give me an idea
4
by: mwebel | last post by:
Hi, i am using a function from a C library which happens to use a lot of static variables and functions. The library used to be a executable but was turned into dll library. My problem is that...
41
by: Jim | last post by:
Hi guys, I have an object which represents an "item" in a CMS "component" where an "item" in the most basic form just a field, and a "component" is effectively a table. "item" objects can be...
6
by: Jack | last post by:
I have a set of functions to wrap a library. For example, mylib_init() mylib_func() mylib_exit() or handle = mylib_init() mylib_func(handle)
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

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.