|
Hi,
I need to use "not Managed C++/CLI class" in a Managed C++/CLI class. But I got the "not supported" error message.
Is there a way to do following?
--------------------------------------
class A (){};
public ref class B()
{
A a; <----- not supported
}
-------------------------
Thanks
|
|
|
|
|
You could store a pointer to an "A" object in an IntPtr[^].
Mark Salsbery
|
|
|
|
|
Thank you very much for the reply. Could you write some sample code?
Best,
|
|
|
|
|
Just a guess, something like...
class A (){};
ref class B()
{
public:
IntPtr APtr;
}
B ^b = gcnew B();
b->APtr = (IntPtr)new A();
A *a = (A*)b->APtr;
Mark Salsbery
modified 26-Nov-11 15:01pm.
|
|
|
|
|
Hi,
I need to convert a "void*" pointer to a managed class. How can I do it?
Soppose:
----------------
void * pClass
ref class A {};
A^ pA = pClass; <---- compile error
---------------------
Best,
|
|
|
|
|
Maybe something like...
System::Runtime::InteropServices::GCHandle gch = System::Runtime::InteropServices::GCHandle::FromIntPtr((System::IntPtr)pClass);
A ^pA = (A ^)gch.Target;
Of course, this assumes pClass was obtained from an IntPtr obtained from an actual managed reference to an "A" object...
Mark Salsbery
|
|
|
|
|
|
Thank you for your reply.
The classes can not be cast between "Managed" and "un-managed".
Best,
|
|
|
|
|
transoft wrote: I need to convert a "void*" pointer to a managed class. How can I do it?
To start with, based on your other post....
You must NOT attempt to cast an unmanaged class to a managed one.
Doesn't matter why you think that is a good idea because it isn't.
|
|
|
|
|
Why MS design "System::Runtime::InteropServices"?
|
|
|
|
|
That provides a way to proxy between the two.
|
|
|
|
|
Hallo
Is there anyway to stream the file directly from the database to the AxAcroPDF control without first saving the file on the hard drive?
|
|
|
|
|
Hi all, I'm Francesco and that's my first post here. As stated in the subject, I'm having trouble compiling an existing C++ project (an MFC app with many other libraries linked) with the /clr flag. I'm using VS08 sp1 and Win7 64 bit and framework 3.5.
The projects compiles succesfully, but trying to launch (both in release and in debug) I get an error message:
"Application Error : The application was unable to start correctly (0xc000007b)."
I tried to google for the error, someone suggests to run sfc /scannow to repair a possible system problem, but it doesn't find anything wrong.
Any suggest?
Many thanks in advance,
Francesco
|
|
|
|
|
Why are you using the /clr flag for an MFC application?
Unrequited desire is character building. OriginalGriff
I'm sitting here giving you a standing ovation - Len Goodman
|
|
|
|
|
I'd like to use some of the .NET features (in particular WPF) from within the app. It seems to be some compatibility issue with one of the libraries used in the project: any chances that someone has encountered a similar problem before?
|
|
|
|
|
Not sure but you could try posting a follow up question in the WPF forum, explaining in more detail what you are trying to do.
Unrequited desire is character building. OriginalGriff
I'm sitting here giving you a standing ovation - Len Goodman
|
|
|
|
|
|
I tried to recompile the project removing any reference to .NET assemblies and the few lines of WPF code that I added, basically the project is now the original C++/MFC, just compiled with /clr flag active: I get the same error as soon as the app starts, so I guess it's some sort of compatibility issue with one of the libraries I'm using. I'll try to figure out which one is.
|
|
|
|
|
It's perfectly possible and acceptable to use the .NET framework with MFC...I did it for quite a while before migrating all my apps to full WPF/Silverlight.
Mixing WPF with MFC may present some challenges. Both are entire GUI systems handling handling native Window handles and associated messaging etc. To have them run simultaneously in the same process? I don't know...
Mark Salsbery
|
|
|
|
|
Well I tried to add WPF controls in other MFC projects with apparently no problems, anyway it seems not to be a WPF issue cause the problem rises just activating the /clr compilation on the original C++ project.
|
|
|
|
|
We're successfully doing this now (Migrated existing MFC app to WPF and still using MFC in places). We did not switch /clr on everywhere -- for one it would generate IL for ALL our C++ code which would slow down a lot of things. So, we only add /clr on files which have C++/CLI code.
John
|
|
|
|
|
Hello, many thanks for the tip, I already noticed the #pragma managed/unmanaged directive, but I had to abandone the project for a while, as soon as possible I'll try that and make an update here.
|
|
|
|
|
Hello people I wanna know if there is anyway you could freeze or program hold it's execution or control it, like a firewall for instance it freezes the program and tells the user "This program is unsafe.". Do any of you'll AV freaks know anything on how to do such a thing.
Edit: Like pausing the program if you were programming it or compiling it.
Regards,
Brandon T. H.
CodeProject Member
|
|
|
|
|
The only way that anti-virus programs recognise this is by scanning the executable file and looking for patterns that match known viruses. Once the program is running then there is little you can do to recognise when it performs some dangerous or questionable action.
Unrequited desire is character building. OriginalGriff
I'm sitting here giving you a standing ovation - Len Goodman
|
|
|
|
|
I believe that AV programs suspend the process. This is the same advice Mark Russinovich gives when you see a suspicious process -- use task mgr, right-click and pick Suspend.
So, I see the SuspendThread() API which maywork but you'd really want to suspend all threads simultaneously instead of walking all threads and suspending individually.
This article may help: Win32 process suspend/resume tool[^]
John
|
|
|
|