s196675m
March 3rd, 2008, 01:15 PM
HOPEFULLY someone can help me.
I am trying to access a function from an unmanaged DLL from my visual c++ managed GUI.
Declaration of the function I am trying to import from unmanaged (native) DLL is:
extern "C" __declspec(dllexport) TGrayImage<int>* init_seg(TGrayImage<float>* pImg, TMonoImage* monoImg, int nClass)
Even though there are many functons in the DLL, only this function is exported.
Now In my GUI, I have added the following line to import that functon so that I can call that functon from GUI.
At the top of the file after using namespaces
[System::Runtime::InteropServices::DllImport("segment.dll")]
TGrayImage<int> * init_seg(TGrayImage<float>* pimg, TMonoImage* mono, int nNum);
I didn't do any Marshalling parameter. I have no idea how to Marshall a pointer to a Template class or pointer to a class. I searched before posting but I didn't get clear understanding about it.
Just for clarification, pimg and mono I am trying to pass is Managed varialble created within managed GUI.
TGrayImage<float>* pimg = new TGrayImage<float>* (width,height);// used new not gcnew
TmonoImage* mono = new TMonoImage(width, height);
I have added the proper library (compiled with pure:MSIL) in my my GUI which supplied TGrayImage,TMonoImage.
Header file for TGrayImage and TMonoImage already included in the GUI.
When I call init_seg function from GUI, I got the following message:
An unhandled exception of type 'System.AccessViolationException' occurred in GUI.exe
Additional information: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
Please help me to Marshall these parameter correctway. I will appreciate your big help.
Thank you.
I am trying to access a function from an unmanaged DLL from my visual c++ managed GUI.
Declaration of the function I am trying to import from unmanaged (native) DLL is:
extern "C" __declspec(dllexport) TGrayImage<int>* init_seg(TGrayImage<float>* pImg, TMonoImage* monoImg, int nClass)
Even though there are many functons in the DLL, only this function is exported.
Now In my GUI, I have added the following line to import that functon so that I can call that functon from GUI.
At the top of the file after using namespaces
[System::Runtime::InteropServices::DllImport("segment.dll")]
TGrayImage<int> * init_seg(TGrayImage<float>* pimg, TMonoImage* mono, int nNum);
I didn't do any Marshalling parameter. I have no idea how to Marshall a pointer to a Template class or pointer to a class. I searched before posting but I didn't get clear understanding about it.
Just for clarification, pimg and mono I am trying to pass is Managed varialble created within managed GUI.
TGrayImage<float>* pimg = new TGrayImage<float>* (width,height);// used new not gcnew
TmonoImage* mono = new TMonoImage(width, height);
I have added the proper library (compiled with pure:MSIL) in my my GUI which supplied TGrayImage,TMonoImage.
Header file for TGrayImage and TMonoImage already included in the GUI.
When I call init_seg function from GUI, I got the following message:
An unhandled exception of type 'System.AccessViolationException' occurred in GUI.exe
Additional information: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
Please help me to Marshall these parameter correctway. I will appreciate your big help.
Thank you.