473,725 Members | 1,811 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Passing Pointers from manged to unmanged code

Hi,

I want to create an Hashtable in C# and pass an pointer to the hashtable to
a C code.
Later, the C code could reference the hashtable by passing the pointer to
the hashtable as a ref parameter.
what is the correct way to do this?

Thanks,
Nov 16 '05 #1
3 1468
Germic wrote:
Hi,

I want to create an Hashtable in C# and pass an pointer to the hashtable to
a C code.
Later, the C code could reference the hashtable by passing the pointer to
the hashtable as a ref parameter.
what is the correct way to do this?

Thanks,


You can't pass complex data structures, like a Hashtable, to native
code. Only primitive types, like integers, floats, strings, arrays of
those types, POD's, ... can be passed back and forth between managed and
native code.
A starting point: MarshalAsAttrib ute, StructLayoutAtt ribute, ...
Converting data to pass it from managed to unmanaged code (and back) is
called *marshalling*.

Cheers,
Benoit
Nov 16 '05 #2
you could try to expose your assembly as a COM component. then you write
accessors inside your assembly which manipulate your hashtable....
"Germic" <sy**********@y ahoo.com> schrieb im Newsbeitrag
news:e0******** ******@TK2MSFTN GP10.phx.gbl...
Hi,

I want to create an Hashtable in C# and pass an pointer to the hashtable to a C code.
Later, the C code could reference the hashtable by passing the pointer to
the hashtable as a ref parameter.
what is the correct way to do this?

Thanks,

Nov 16 '05 #3
Hi Michael,

Thanks for your suggestions. Could you pls explain a bit more on this. I am
quite new to C# & Interop

Thanks,

"Michael Groeger" <go*********@we b.de> wrote in message
news:Ow******** ******@TK2MSFTN GP09.phx.gbl...
you could try to expose your assembly as a COM component. then you write
accessors inside your assembly which manipulate your hashtable....

Nov 16 '05 #4

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

Similar topics

1
3544
by: lolomgwtf | last post by:
I have a managed C++ method that wraps unmanaged code and creates a managed object holding data retrieved form an unmanged one. I want create an instance of this managed class in C#, pass it to this method and have it set the instance to hold the right data. >From what I've read it seems I should be able to pass C# objects to managed C++ methods and it should just work; however, when I try it, my C# instance comes out null. If I step...
2
3018
by: Manish | last post by:
Hi, I m facing a problem in re-writing a code from VB to C #. We are using a third party DLL to develop a application of Fax. The current application is already written in VB and we have to convert it into C#. In VB we are using a function from the DLL whose signature is like : Declare Function RFVB_SendFiles1 Lib "RF2VB.DLL" (ByVal hServer As Long, _ ByVal lFI10Object As
2
4679
by: lolomgwtf | last post by:
I have a managed C++ method that wraps unmanaged code and creates a managed object holding data retrieved form an unmanged one. I want create an instance of this managed class in C#, pass it to this method and have it set the instance to hold the right data. >From what I've read it seems I should be able to pass C# objects to managed C++ methods and it should just work; however, when I try it, my C# instance comes out null. If I step...
0
242
by: P Reddy | last post by:
Hi All, Greetings!!! I have a question. Please respond.... I am trying to write a C# component that need to inherit some of the the interfaces from unmanged code(VC). I think one way to resolve this is to port unmanged interfaces and header files in to manage C++ as Visual Studio allows porting and compiling all this
11
32076
by: Danijel Babic | last post by:
Hello! Can you tell me how to set pointer to variable in VB.NET Thank you!
2
4512
by: IcedCrow | last post by:
I am a little bit confused so am proposing this question. Thanks in advance to anyone who can answer it for me. I was told many times that one of the things that .NET got rid of was pointers. So for the past year and a half I have been running under this assumption. Today I ran into something called an "IntPtr" which is a structure that acts as... a pointer!! (This is in VB.NET, I imagine it is everywhere then)
3
1822
by: brian_harris | last post by:
I am tring to start a thread where I am passing info into thread. According to MS documentation I must do this by creating a class for that thread. I have done this but am getting a compiler error. The error is: c:\T02010_NET_ora9\cgi-bin\programs\TimeReader\TimeReaderWinService.cpp(104): error C2475: 'ThreadWithState::readerThread' : forming a pointer-to-member requires explicit use of the address-of operator ('&') and a qualified name...
9
1672
by: Timothee Groleau | last post by:
Hi all, My name is Tim, I'm just getting started with C++ and this is my first post to the group. Is there a standard recommended approach to use a vector of pointers along with <algorithm>? To be specific, here is my situation, I have 2 classes A and B. Class A contains a private vector of pointers to B objects and I need to sort this
0
1867
by: ElysianEagle | last post by:
Hi, I have a DLL written in C that creates a structure as a local variable, populates it, and then calls a function in managed c#. here is what im talking about: //-----unmanged code's header file typedef struct M { int a; int b;
0
8872
marktang
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...
0
8747
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,...
0
9246
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 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...
1
9162
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,...
0
5997
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();...
0
4505
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...
0
4773
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2619
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2150
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.