CFanatic

Go Back   CFanatic > Programming > C# Programming

Join CFanatic Forum Now

Passing Data From C# To Managed C++ Lib topic posted under C# Programming which is a part of Programming category in CFanatic Forum
Reply
 
Thread Tools Display Modes
  #1  
Old 08-31-2010, 04:07 PM
 
Join Date: Aug 2010
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
littlespy is on a distinguished road
| More
Passing Data From C# To Managed C++ Lib

Hi,
We are building a GIS application that must make many repetitive calls in a small amount of time. (IE processing thousands of points in a few seconds). Because of the way the ESRI ArcObjects framework we are using interfaced with COM components through the interop layer we have decided to move the heavy parts of our application out our C# program and into managed c++.


Which leads me to the problem that I've been tackling all day. I've built a .NET managed class in C++ and an importing it into my C# application by adding a reference to the DLL. That all works fine, but as for passing a Class object from the C# program to the DLL I have been having a lot of trouble. Here is some code to help clarify:

This is the C++ Class, pretty simple

Code:
namespace ArcProxy {

        public ref class ArcProxy
        {
        public:
                ArcProxy()
                {
                        ::CoInitializeEx(NULL, COINIT_MULTITHREADED);
                        //ESRI_SET_VERSION(esriArcGISEngine);
                }

                ~ArcProxy()
                {
                        ::CoUninitialize();
                }

                void PointOperations(void *ipPointFeatures, long numPoints)
                {
                        IFeatureCursor *cur;
                        VARIANT v;
                        //v.

                        IFeatureClass * fc = (IFeatureClass *)ipPointFeatures;
                        fc->GetFeatures(v, true, &cur);
                        
                        //return ipPointFeatures;
                }

                int test() { return 2;}
        };
}
I am trying to call it in my C# doing something like this:
Code:
                ArcProxy.ArcProxy proxy = new ArcProxy.ArcProxy();

                unsafe
                {
                    IntPtr refPtr = new IntPtr();
                    Marshal.StructureToPtr(sourceFeatureClass, refPtr, true);

                    proxy.PointOperations(refPtr.ToPointer(), 100000);
                }
I am a bit confused as to how I can pass a managed object from C# to managed c++. sourceFeatureClass is just an object of type IFeatureClass (if anyone is familar with arcobjects). If I can pass the data in as a void * to my c++ dll then I can simply cast the void * to a IFeatureClass * in c++ and be happily on my way.

If anyone could provide any insight into this problem I would be very grateful.
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
why it is not passing the value sunil17 C Programming 0 08-31-2010 04:00 AM
managed DLL Noelman MFC Programming 0 08-28-2010 02:24 AM
Passing Complex Types in COM PrettyFlower Network Programming 0 06-30-2010 10:30 PM
Hello there, just passing by. StiltsChickMonica Introduce yourself 1 02-03-2009 03:39 AM
passing arrays in C# Xarzu C# Programming 3 09-29-2008 05:27 AM

 

Advertisement

CFanatic Search
Custom Search

Advertisement

All times are GMT -5. The time now is 03:27 PM.



Powered by vBulletin® Version 3.7.4
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO ©2010, Crawlability, Inc.
Cfanatic.com is a premier member of the IDG TechNetwork. For advertising opportunities contact here
Get Paid for Working on Projects Matching Your Expertise at Go4Expert's Jobs Board