[Mono-list] Mono-website:FAQ:Technical: Question 2.9: Running Visual C++/CLI programs under mono

Matthias Seemann semmel71 at yahoo.de
Wed Feb 8 11:26:32 EST 2006


Hello,
I am interested in making C++/CLI work with Mono,
because I like my programs to run under Linux, but
being myself to lazy and reluctant to move from C++ to C#. (And with 
C++/CLI there is no real need to do so actually.)

Therefore I would like this to be added in the according FAQ on the mono 
website:

Using C++/CLI in Visual Studio 2005 to create a pure managed executable
which runs under Mono is easy: In your CLR project
just specify in the general configuration properties
"Safe MSIL Common Language Runtime Support
(/clr:safe)" and all dependencies to the C Runtime
Library (CRT) are gone!
You can use PEVerify.exe to check it.

Beware of those linker options "/nodefaultlib /entry:main mscoree.lib" 
currently mentioned in question 2.9. of the technical FAQ. They lead to 
nowhere with C++/CLI of Visual Studio 2005!

Found this in the blog here:
http://stage.bennettadelson.com/bennettadelson/blogs/rbroida/default.aspx

Quick Tutorial (I am using Visual Studio 2005 Beta2):
- Create an empty CLR project "TestApp"
- Add a new source file "Main.cpp"
- Enter the following code:
using namespace System;
int Main(void){
    Windows::Forms::MessageBox::Show("Welcome to Mono
C++/CLI!", "TestApp",
        Windows::Forms::MessageBoxButtons::OK);
    return 0;}

- Select Project->References..->Add Reference adding
"System.dll" and "System.Windows.Forms.dll"
- Select Project->Configuration
Properties->General->Project Defaults->Common Language
Runtime Support-> /clr:safe
- Select Project->Linker->System->SubSystem: Windows
- Select Project->Linker->Advanced->Entry: Main
- Build the project and run the executable "mono
TestApp.exe"

However, I created with the Designer a simple dialog Windows::Form
"MyForm" with just a single pushbuttonin it, and added it to the 
project. When calling "Application::Run(gcnew TestApp::MyForm());" from 
Main, everything is fine with MS.NET but mono fails quietly to run the 
TestApp. I suppose the desinger must have generated code, which is out 
of Mono::WinForms?

Best wishes to all
Matthias Seemann



	

	
		
___________________________________________________________ 
Telefonate ohne weitere Kosten vom PC zum PC: http://messenger.yahoo.de


More information about the Mono-list mailing list