Click here to Skip to main content
15,914,225 members
Home / Discussions / Managed C++/CLI
   

Managed C++/CLI

 
AnswerRe: How to test on a pushed button in the leave event of a textfield Pin
Luc Pattyn5-Nov-09 0:44
sitebuilderLuc Pattyn5-Nov-09 0:44 
QuestionRe: How to test on a pushed button in the leave event of a textfield [modified] Pin
cad-JC5-Nov-09 1:06
cad-JC5-Nov-09 1:06 
GeneralRe: How to test on a pushed button in the leave event of a textfield Pin
Luc Pattyn5-Nov-09 1:20
sitebuilderLuc Pattyn5-Nov-09 1:20 
QuestionRe: How to test on a pushed button in the leave event of a textfield [modified] Pin
cad-JC5-Nov-09 1:57
cad-JC5-Nov-09 1:57 
AnswerRe: How to test on a pushed button in the leave event of a textfield Pin
Luc Pattyn5-Nov-09 2:20
sitebuilderLuc Pattyn5-Nov-09 2:20 
GeneralRe: How to test on a pushed button in the leave event of a textfield Pin
cad-JC5-Nov-09 2:38
cad-JC5-Nov-09 2:38 
QuestionRe: How to test on a pushed button in the leave event of a textfield Pin
cad-JC8-Nov-09 22:29
cad-JC8-Nov-09 22:29 
QuestionDelegate with a cli::array as a parameter (Error Reentrancy was Detected) [modified] Pin
Greggor014-Nov-09 10:31
Greggor014-Nov-09 10:31 
Hi all, this is my first post. Normally I am able to figure out the problems I encounter either by searching this board or others like it on the web but not this time. I've been fighting with this for weeks now and am finally turning to you guys. Any and all help is appreciated.

I've got a CORBA Event channel feeding multiple applications data. If you are unfamiliar with CORBA it's okay, you don't need to know much aside from that the code generated for CORBA related functions in UNMANAGED. The data is pushed at a 1Hz interval and the applications register as a consumer to receive the data. My task is to create a common DLL for all Managed applications that are being built going forward that makes the registering and consumption of data easy and localized.

I've had little problem getting this to work with primitive data types but the final piece of my puzzle is to receive a sequence of data that is in a CORBA defined structure.

Here is what I am dealing: a Managed C++ DLL (built with CLR support) that contains Managed and Unmanaged(CORBA) classes, and a C# Application that references the DLL.

The MDA (Managed Debugging Assistant) Gives this description:An unhandled exception of type 'System.ExecutionEngineException' occurred in Unknown Module.

Attempting to call into managed code without transitioning out first. Do not attempt to run managed code inside low-level native extensibility points, such as the vectored exception handler, since doing so can cause corruption and data loss.


After hitting continue I get an ExecutionEngineException:

An unhandled exception of type 'System.ExecutionEngineException' occurred in Unknown Module.


**The following code snippets are in the Managed C++ DLL**
ManagedWrapper.h

	public delegate void BasicCallbackDelegate(short cmd);
	public delegate void NonBasicCallbackDelegate(array<EPClass^>^ epList);

	[StructLayoutAttribute(Sequential, CharSet = Ansi )]
	public ref struct ManagedBasicDelegateWrapper
	{
		[MarshalAsAttribute(UnmanagedType::FunctionPtr)]
		BasicCallbackDelegate^ _Delegate;
        };

	[StructLayoutAttribute(Sequential, CharSet = Ansi )]
	public ref struct ManagedNonBasicDelegateWrapper
	{
		[MarshalAsAttribute(UnmanagedType::FunctionPtr)]
		NonBasicCallbackDelegate^ _nDelegate;
        };

	public ref class ManagedWrapperClass
	{
	public:
		ManagedWrapperClass(ManagedBasiceDelegateWrapper^ cbd);
		ManagedWrapperClass(ManagedNonBasicDelegateWrapper^ cbd);
	};


ManagedWrapper.cpp

        extern class BasicPushConsumer *BasicPushConsumerObject;
        extern class NonBasicPushConsumer *NonBasicPushConsumerObject;

	ManagedWrapperClass::ManagedWrapperClass(ManagedBasicDelegateWrapper^ cbd)
	{
		gt_Callback callback;

		Marshal::StructureToPtr(cbd, safe_cast<System::IntPtr>(&callback), false);

		BasicPushConsumerObject->SetCallbackInUnmanaged(callback);
	}
	
	ManagedWrapperClass::ManagedWrapperClass(ManagedNonBasicDelegateWrapper^ cbd)
	{
		ep_Callback callback;

		Marshal::StructureToPtr(cbd, safe_cast<System::IntPtr>(&callback), false);

		NonBasicPushConsumer->SetCallbackInUnmanaged(callback);
	}


*pruned* NonBasicPushConsumer.cpp
//Unmanaged class required by CORBA

typedef void (*gt_Callback) (short cmd);
typedef void (*ep_Callback) (array<EPClass^>^ epList);

void NonBasicPushConsumer::SetCallbackInUnmanaged(ep_Callback ptr2f)
{
	scallback = ptr2f;
}

void NonBasicPushConsumer::ManagedMethodToCall(array<EPClass^>^ epList)
{
	scallback(epList); //This produces the crash in question
}


**The following code is part of the C# Application**
*pruned* Form1.cs

            ManagedNonBasicDelegateWrapper mcf = new ManagedNonBasicDelegateWrapper();
            mcf._epDelegate = new EntityPositionCallbackDelegate(CallbackFunction);
            ManagedWrapperClass mwc = new ManagedWrapperClass(mcf);

        public static void CallbackFunction(System.Array epList)
        {
            Console.WriteLine("CALLBACK!");
        }


modified on Wednesday, November 4, 2009 6:44 PM

AnswerRe: Delegate with a cli::array as a parameter (Error Reentrancy was Detected) Pin
Dave Doknjas4-Nov-09 10:58
Dave Doknjas4-Nov-09 10:58 
GeneralRe: Delegate with a cli::array as a parameter (Error Reentrancy was Detected) Pin
Greggor016-Nov-09 2:36
Greggor016-Nov-09 2:36 
QuestionGet Command line returned string Pin
wael_r3-Nov-09 22:54
wael_r3-Nov-09 22:54 
QuestionHow to close/hide the console window when window form is open? Pin
santoshkaif1-Nov-09 23:33
santoshkaif1-Nov-09 23:33 
AnswerRe: How to close/hide the console window when window form is open? Pin
N a v a n e e t h1-Nov-09 23:44
N a v a n e e t h1-Nov-09 23:44 
GeneralRe: How to close/hide the console window when window form is open? Pin
santoshkaif2-Nov-09 0:08
santoshkaif2-Nov-09 0:08 
AnswerRe: How to close/hide the console window when window form is open? Pin
Mark Salsbery2-Nov-09 9:07
Mark Salsbery2-Nov-09 9:07 
GeneralRe: How to close/hide the console window when window form is open? Pin
santoshkaif2-Nov-09 17:36
santoshkaif2-Nov-09 17:36 
GeneralRe: How to close/hide the console window when window form is open? Pin
N a v a n e e t h2-Nov-09 20:08
N a v a n e e t h2-Nov-09 20:08 
QuestionMerge exe(of managed and unmanaged code) and dlls into single exe Pin
santoshkaif1-Nov-09 22:55
santoshkaif1-Nov-09 22:55 
AnswerRe: Merge exe(of managed and unmanaged code) and dlls into single exe Pin
N a v a n e e t h1-Nov-09 23:28
N a v a n e e t h1-Nov-09 23:28 
GeneralRe: Merge exe(of managed and unmanaged code) and dlls into single exe Pin
santoshkaif1-Nov-09 23:38
santoshkaif1-Nov-09 23:38 
GeneralRe: Merge exe(of managed and unmanaged code) and dlls into single exe Pin
N a v a n e e t h1-Nov-09 23:57
N a v a n e e t h1-Nov-09 23:57 
GeneralRe: Merge exe(of managed and unmanaged code) and dlls into single exe Pin
santoshkaif2-Nov-09 0:06
santoshkaif2-Nov-09 0:06 
QuestionThread injection Pin
csrss30-Oct-09 12:12
csrss30-Oct-09 12:12 
AnswerRe: Thread injection Pin
N a v a n e e t h30-Oct-09 16:44
N a v a n e e t h30-Oct-09 16:44 
GeneralRe: Thread injection Pin
csrss30-Oct-09 17:45
csrss30-Oct-09 17:45 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.