473,473 Members | 4,185 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

sending pointer from C++ to C#

3 New Member
Hello all,
I have to send a pointer from C++ to C#. How can I do this?
Error message I am getting on the C# program is
"Pointers and fixed size buffers may only be used in an unsafe context"
Please help.
Jul 13 '10 #1
5 4400
GaryTexmo
1,501 Recognized Expert Top Contributor
When using pointers in C#, you need to wrap the code in an unsafe code block.

Expand|Select|Wrap|Line Numbers
  1. unsafe
  2. {
  3.   // your pointer operations here
  4. }
Jul 13 '10 #2
arjun404346
3 New Member
thnx,
now its showing error
"Unsafe code requires the 'unsafe' command line option to be specified
:( :(
Jul 13 '10 #3
GaryTexmo
1,501 Recognized Expert Top Contributor
In the Solution Explorer, find your project (the one that contains the unsafe code). Right-click and select properties. In the left-hand pane, select the Build tab.

In the first category, General, there should be a checkbox that says "Allow unsafe code".

Check this and save the properties.
Jul 13 '10 #4
arjun404346
3 New Member
Actually I am working on unity3d and there is no setting option for compiling. I have to send a pointer from a C++ program (which is being compiled on Visual C++) to C# program (which is being compiled by unity3d compiler).

I have to change IplImage (contained in openCv library for C) to Texture2D image (used by unity3d) and for that I have to tell unity3d where this IplImage is stored in the memory. And so I need to send a pointer
Jul 14 '10 #5
GaryTexmo
1,501 Recognized Expert Top Contributor
Google around for it. It's a command line switch on the compiler itself. If you're not using Visual Studio, you'll have to figure out how to enable that as a compile option on the tool you are using.

I'm think it might be something as simple as adding /unsafe to the command line for it, but I'm not sure... which is why you should look it up :)
Jul 14 '10 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Pravin | last post by:
I am trying to access C function from C#. I have made DLL of C Code. I have exported function to be caled using DEF file. defination of the function I want to call is have one of the parameter is...
4
by: Leo | last post by:
Hello, I have a C dll with a method signature of: int activate(datastruct *data) where datastruct is defined as: typedef struct datastruct { long result;
8
by: intrepid_dw | last post by:
Hello, all. I've created a C# dll that contains, among other things, two functions dealing with byte arrays. The first is a function that returns a byte array, and the other is intended to...
16
by: Dave | last post by:
I'm having a problem trying to set up code in VB to handle the case where an argument in an API definition is defined as a pointer to a pointer. An excerpt from the API's definition is: void...
51
by: Joe Van Dyk | last post by:
When you delete a pointer, you should set it to NULL, right? Joe
12
by: MQ.john | last post by:
//Working Example: #include <stdio.h> #include <time.h> int main () { time_t rawtime; /* define rawtime as time_t */ time ( &rawtime );
6
by: dtschoepe | last post by:
Hi all, Working on homework again... I've got a weird problem, I've been banging my head against the wall on what is causing it. I have a pointer to a typdef named Person. At one point in the...
15
by: colin | last post by:
Hi, Im familiar with c,c++ etc, and Ive spent a week trying to write my first app in c# it works reasonably well, but im having difficulty getting to grips with inter thread signalling etc. I...
5
by: lanclot | last post by:
hi i am trying to authenticate a user using ClientLogin by sending a post to https://www.google.com/accounts/ClientLogin in my c program use ssl and socket the next code is my request:...
0
by: mjaaland | last post by:
Hi! I've been working with DLLimports passing structs and various other parameters to unmanaged code. I had problems earlier sending pointer to structs to the unmanaged code, and this forum solved...
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
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,...
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,...
1
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...
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...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
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...
0
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...
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

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.