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

Managed C++/CLI

 
QuestionHow to (re)size an array using Int64 Pin
zaccheus17-Sep-06 1:25
zaccheus17-Sep-06 1:25 
AnswerRe: How to (re)size an array using Int64 Pin
Christian Graus17-Sep-06 11:24
protectorChristian Graus17-Sep-06 11:24 
GeneralRe: How to (re)size an array using Int64 Pin
zaccheus17-Sep-06 12:51
zaccheus17-Sep-06 12:51 
GeneralRe: How to (re)size an array using Int64 Pin
Christian Graus17-Sep-06 13:19
protectorChristian Graus17-Sep-06 13:19 
AnswerRe: How to (re)size an array using Int64 Pin
Daniel Grunwald22-Sep-06 21:50
Daniel Grunwald22-Sep-06 21:50 
GeneralRe: How to (re)size an array using Int64 Pin
zaccheus23-Sep-06 1:20
zaccheus23-Sep-06 1:20 
Questionmorris pratt Pin
vtalau17-Sep-06 0:44
vtalau17-Sep-06 0:44 
Questionunmanaged -> managed call (again) Pin
Dragan Matic14-Sep-06 23:16
Dragan Matic14-Sep-06 23:16 
Few days ago I asked a similar question, but it seems I wasn't clear about the problem. I'll try to rephrase question in hope that it will be more clear.

I have a managed code that I would like to call from unmanaged application. This is the sample that explains the problem that I stumbled upon.
Here is a C++ dll that I would like to call:

using namespace System::Windows::Forms;

extern "C" DLL2005_API int fnDll2005(void)
{
// unmanaged Message box
::MessageBoxA(0, "unmanaged text", "unmanaged caption", 0);

// Managed message box
System::Windows::Forms::MessageBox::Show("managed text", "managed caption");

return 42;
}
--------
I am trying to call this DLL from a sample console application written in VC6:

extern "C" __declspec(dllexport) int fnDll2005(void);

int main(int argc, char* argv[])
{
fnDll2005();
return 0;
}

so far so good, everything works fine, console application calls dll and both
dialog boxes are shown, unmanaged and managed one.

Problem arises when C++ function tries to call another managed method written
in C#. Here is the C# code:

using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms;

namespace ClassLibrary1
{
public class Class1
{
public static int ShowDialog(string sText, string sCaption)
{
System.Windows.Forms.MessageBox.Show(sText, sCaption);
return 0;
}
}
}

nothing special, a simple C# assembly, and here is the modified C++ function
that should call C# method:

using namespace System::Windows::Forms;
using namespace ClassLibrary1;

extern "C" DLL2005_API int fnDll2005(void)
{
::MessageBoxA(0, "unmanaged text", "unmanaged caption", 0);
System::Windows::Forms::MessageBox::Show("managed text", "managed caption");
ClassLibrary1::Class1::ShowDialog("class library text", "class library caption");
return 42;
}

and here's the problem. The moment that console application tries to call fnDll2005 function the program breaks with message "unhandled exception in console1.exe (KERNEL32.DLL)..."

If I compile console program with VS2005 everything works fine. I don't understand why the program breaks when I call C# code when in the first example obviously CLR was started when I called it from C++ code. Since I'm a newbie in managed world I don't know if what I am trying to do is possible at all? Is there a way to call unmanaged function (from a program written in VC6) in a DLL that would later call managed code?

Tnx in advance

Dragan
AnswerRe: unmanaged -> managed call (again) Pin
User 58385218-Sep-06 15:53
User 58385218-Sep-06 15:53 
Questioncan you tell me the function is use for? thanks Pin
fly4me14-Sep-06 16:20
fly4me14-Sep-06 16:20 
AnswerRe: can you tell me the function is use for? thanks Pin
Christian Graus14-Sep-06 19:30
protectorChristian Graus14-Sep-06 19:30 
QuestionString.Split - tutorial? samples? Pin
LudwigKeck14-Sep-06 16:16
LudwigKeck14-Sep-06 16:16 
AnswerRe: String.Split - tutorial? samples? Pin
baerten21-Sep-06 5:01
baerten21-Sep-06 5:01 
GeneralRe: String.Split - tutorial? samples? Pin
LudwigKeck21-Sep-06 15:02
LudwigKeck21-Sep-06 15:02 
QuestionWizard Control in vc++ express Pin
aguest14-Sep-06 7:41
aguest14-Sep-06 7:41 
AnswerRe: Wizard Control in vc++ express Pin
led mike14-Sep-06 8:11
led mike14-Sep-06 8:11 
Questionbios.h and terminos.h in Dev c++ compiler Pin
prashw13-Sep-06 21:55
prashw13-Sep-06 21:55 
AnswerRe: bios.h and terminos.h in Dev c++ compiler Pin
Christian Graus14-Sep-06 19:32
protectorChristian Graus14-Sep-06 19:32 
Questionalternate code for cp command Pin
vinod_kumar23313-Sep-06 1:40
vinod_kumar23313-Sep-06 1:40 
AnswerRe: alternate code for cp command Pin
Christian Graus14-Sep-06 19:35
protectorChristian Graus14-Sep-06 19:35 
GeneralRe: alternate code for cp command Pin
vinod_kumar23314-Sep-06 21:44
vinod_kumar23314-Sep-06 21:44 
GeneralRe: alternate code for cp command Pin
Christian Graus14-Sep-06 22:20
protectorChristian Graus14-Sep-06 22:20 
QuestionGlobal hook for system menu events Pin
Harshabhi12-Sep-06 15:22
Harshabhi12-Sep-06 15:22 
QuestionStatus window in DLL Pin
mparent12-Sep-06 11:45
mparent12-Sep-06 11:45 
Questionlistview and columns Pin
aguest12-Sep-06 11:26
aguest12-Sep-06 11:26 

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.