473,703 Members | 2,958 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Marshaling complex structs from C# to managed C++ wrapper

I have written a managed C++ wrapper class around an old
C++ DLL that I have to use in my application. My problem
is I need to marshal a bunch of structures from C# to the
C++ class. These structuers contain mostly StringBuilder
objects, but some contain arrays of other structs that
themselves contain StringBuilder objects.

I have defined the stucts in the C++ header file as
typedef __gc StructName
StringBuilder *hmm;

Passing these back and forth works great. I make a change
to the structs in the C++ class, and it gets back to the
C# class just fine.

Now, how do I define a struct that contains an array of
other structs? Also, how do I instantiate it correctly
and how do I work with it on the C++ side? Can I do a

Any help would be greatly appreciated.


Arthur Autenzio
ar************* @bostonstock.co m

Nov 15 '05 #1
0 1379

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

Similar topics

by: C. N. Sridhar | last post by:
Hi, I'm writing a wrapper to a win32 dll in C#. I need to call a method in DLL which has a Variant type reference parameter. How to marshal variant type from win32 (unmanaged code) to C# (managed code)? I tried using Marshal.GetObjectForNativeVariant(), but of no use.
by: Keith M | last post by:
Hi, I am a bit of a newcomer to C# but have experience with (unmanaged) C++. Now, I have a 3rd party dll and headers. This dll is a C++ style dll that exports classes and structs. I am attempting to write a Managed C++ wrapper dll for this dll in order that it can be used from various C# modules in the overall project. The managed C++ project can 'see' the definitions for the structs that the lower functions use in the supplied...
by: VM | last post by:
What's marshalling? I've had to use it extensively for a project but I don't know what it means. I tried to look for a definition in the Internet but I couldn't find anything that would explain what it is. Is converting a C-style struct to a C# class (or struct) marshalling? And what about the function exports? Are those Marshalling too? Thanks for your help and thanks for helping me with the Dll exports (the several messages I posted in...
by: Nadav | last post by:
Hi I am about to write a performance crutial system, I am considering writing this system based on native COM or unmanaged C++ exposed as CLI, Now, I Wonder... does exposing a native code through CLI ( using a mixed mode DLL ) have any performance penalty? consider one Native C++ CLI assembly calling a methos od another CLI Native C++ Assembly, will there be any marshaling penalty, will there be any penelty at-all? is it possible to pass a...
by: Chua Wen Ching | last post by:
Hi there, I had some problems converting C -> C#. C codes: unsigned char BYTE; unsigned short puint8; typedef struct {
by: MSDousti | last post by:
Hi all, I read some Q&As in the Net, discussing Marshalization of nested structs in C# (or VB.NET). Some guys stated that .NET framework does not support this feature yet. Are they right? BTW, by nested structs I mean structures such as this:
by: Mas L via DotNetMonster.com | last post by:
Hi, I have a c++ source code which I can compile to be a DLL (in VS.NET 2003). And I need to use it in a C# program. After I compiled/build the C++ code to a DLL, I add it as a Reference in my C# program. When I look at the reference and I double click to view it in the objec browser , I see only structs , without their members. And I don't see methods.
by: Lee Crabtree | last post by:
I have several unmanaged struct types that I've created equivalent managed struct types for. How do I marshal the managed structs into their unmanaged versions and vice versa? Here's a quick example of what I'm working with: unmanaged C++: typedef struct _UStruct {
by: Aston Martin | last post by:
Hi All, ********************** My Situation ********************** I am working on project that involves passing a structure to unmanaged code from .Net world (well using C#). Perhaps an example will prove useful. structure MyStruct { // this is a complicated struct declaration in the sense
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.