|
-
February 16th, 2010, 09:15 PM
#1
Transferring data between managed and unmanaged code
Hi,
** Please move if I posted in the wrong forum - I wasn't sure where this belonged! **
I'm looking for some advice... I would like to have a native C++ project read data from the process it is attached to, and feed that data to a C# project for analysis, and then pass a single return value back to the C++ class.
Here's what I have so far:
1/ A C# managed (obviously!) project (Code Library DLL)
2/ A C++ managed project (DLL), with only one managed function 'FuncX', and the rest declared as unmanaged using the #pragma approach.
I'm attaching the C++ DLL to a process and reading information from the process, and that all works fine.
Because I will be writing a lot of app. code, I would like to use C#, which means I have to get the data read from my application using the C++ DLL into the C# project. I would like to just transfer the data by adding a reference of my C# project to the C++ project (hence me creating the C++ project as managed) and moving the data over in a struct or class (defined in the C# project). In the one managed function I am creating an instance of my C# managed 'data copier' class, copying the data to it (which compiles at least) and then looking to pass the data (within the populated class instance) and execution to the C# library, but it doesn't seem to work (all sorts of problems).
Am I going down the right path here (and just need to persevere more)?
Or, am I all wrong, and if so, what is the best way to accomplish this?
Thanks for your help!
Last edited by BigWinston; February 16th, 2010 at 09:20 PM.
Regards,
Big Winston
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|