|
There was three of the posts actually - all out-of-context crap.
This one only stayed because there was a reply before many of us marked them as abuse
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Did it happen to look like the crap on his blog space in the profile? Just tons of crap code
"I guess it's what separates the professionals from the drag and drop, girly wirly, namby pamby, wishy washy, can't code for crap types." - Pete O'Hanlon
|
|
|
|
|
Paul Conrad wrote: Did it happen to look like the crap on his blog space in the profile? Just tons of crap code
Yep. Like Mark said there were three of them. I replied to the top one and sent abuse on all of them. Guess I shouldn't have posted a reply
led mike
|
|
|
|
|
Hi,
Can you give me any Managed c++ treeview creation example project.
Thanks
|
|
|
|
|
Have you tried searching around here or on google?
"I guess it's what separates the professionals from the drag and drop, girly wirly, namby pamby, wishy washy, can't code for crap types." - Pete O'Hanlon
|
|
|
|
|
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 can't decipher your post.
s196675m wrote: 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)
First you indicate an unmanged source, then:
s196675m wrote: 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.
At this point I am at a complete loss to understand your scenario.
led mike
|
|
|
|
|
Sorry, for ambiguity.
led mike wrote: s196675m wrote:
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)
First you indicate an unmanged source, then:
Yes you are right. This line of declaration from unmanged source. (part of unmanaged DLL.
led mike wrote: s196675m wrote:
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);
These sample code is part of GUI( managed). I just showed here how I initialize pimg and mono variables before passing to the imported function
I have added the proper library (compiled with pure:MSIL) in my my GUI which supplied TGrayImage,TMonoImage.
Here I am trying to mean, The other library I used with GUI also complied as a managed library.
At this point I am at a complete loss to understand your scenario.
Now my main question is:
(1) Did I imported the function correctly ?
(2) Do I need to marshall the parameters before passing to the function?
(3) How Can I marshall the first two parameters?
Thank you.
|
|
|
|
|
s196675m wrote: Now my main question is:
Sorry but have not at all cleared up the seeming contradictory statements in your orginal post
s196675m wrote: I have added the proper library (compiled with pure:MSIL) in my my GUI which supplied TGrayImage,TMonoImage.
Here I am trying to mean, The other library I used with GUI also complied as a managed library.
First you say it's a native library then you seem to be saying you compiled it as a managed library (pure:MSIL). It can't be both so I still have no idea what you are saying.
led mike
|
|
|
|
|
The passed pointers should marshal no problem.
Where exactly is the exception occurring? Can you step into the init_seg() call in the debugger?
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
I think the easiest way is to use #pragma unmanaged/managed.
Set your project properties to /clr, create a native function and wrap it with #pragma unmanaged/managed, include your .h native library header and link to your .lib.
Call the native function from your GUI.
|
|
|
|
|
Maybe, but I tried code like the OP's and it works fine. Until (s)he answers with better
error info, it's hard to tell, but I think the error has nothing to do with marshaling.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Mark Salsbery wrote: but I think the error has nothing to do with marshaling.
It's far more likely it's due to copy/paste coding rather than actually understanding the technologies you are attempting to utilize.
By the way, what the heck were you doing being on here 7 hours ago? Get some sleep
led mike
|
|
|
|
|
Agreed.
led mike wrote: By the way, what the heck were you doing being on here 7 hours ago?
Hehe it's hectic around here. My GF is working long hours here on graduation projects for her second degree.
So I just hang out getting some work done or playing on CP...until the screenwriters start cranking out new TV show
episodes again I work at home so regular work hours just don't exist.
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Hi
I am creating a toolstrip,Menustrip.
can you tell me how to move a toolstrip from one place to another place.
|
|
|
|
|
|
Hi,
In Visual Studio, ProjectLocation dialog box is there know . How to create a dialogbox like that ? I want to create like this with the same operation. Can you tell me
Thank you,
|
|
|
|
|
What dialog are you talking about?
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
1) When using null it show error: undeclared identifier. what can i do to declare a null? If no way to use null then what is the replacement for it?
2) How to declare array return type for a function?
In c# public byte[] type(); In c++/cli public array<byte> type(); not working. </byte>
modified on Monday, March 3, 2008 12:34 AM
|
|
|
|
|
|
1) nullptr
2) array<Byte> ^method();
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
My GUI application called a function in a library (image processing library) but it takes 20 to 30 times more time to execute this function when comparing to the time required when calling standalone .exe file.
Both library and GUI compiled with managed c++ (pure:clr) and in the GUI there is a reference for the library as a additional dependencies in the linker input.
When I make .exe (using pure:MSIL) file instead of .lib and run from command line passing the required argument is just take one to one and half minute to execute it .
When I make the library file (bypassing the main function) from the same source code and calling the function from GUI takes arround 20 to 30 minutes. The source code for the library orginially written in C/C++ but I compiled it using manged c++ pure MSIL to match with the GUI.
Compilation and linking everything is fine and I can not find and explain the cause of 20 to 30 times slow running when library is used.
Is there anybody here in this forum help me or explain the possible cause of slow running.
Any idea, link, suggestion will be highly appreciated.
Thank you.
|
|
|
|
|
Hi,
are you sure you both the lib and exe are in /clr:pure? If the exe is /clr:pure and the lib is /clr, then it is possible that the whole program runs 20-30x slower. This is because of thunking between managed and native world, data type marshalling etc. It gets even worse when many functions are called in managed world (which is usual in image processing).
What you can do is compile your c++ functions in a DLL as native, and then just call 1 function from managed C++.
I'm also doing image processing, and am interested to know more.
|
|
|
|
|
thanks for your suggession.
I already created a DLL in naive code and importing a function to my GUI and used P/Invoke to call this function from GUI. It is much better but not yet perfect. It is 2 to 3 times slower now when comparing to the win32 console application.
Somebody suggested me to call the function in a seperate thread which I will try.
There might be some messsage pump working between GUI(Winform application) and native dll when I called the function.
If you have any other suggessions then let me know.
thank you again.
|
|
|
|
|
when i Serialize Object in My Application int the FileStream I can't
Deserialize FileStream in Other Application . so
how To Serialize Object in fileStream into My Application And Deserialize FileStream in other Application
|
|
|
|