First steps with .Net


Timotheus Pokorra, January 2005

Frameworks:


The Microsoft .Net Framework 1.1 DotGNU Mono Delphi 2005
platforms
Win98, ..., XP Win XP, Linux Win XP, Linux
Win
GUI
WinForms
WinForms not complete, but working
No published binaries for WinForms
WinForms, VCL.Net
(VCL.net depends on win32)
To compile a program on the command line you need to set the PATH environment variable to the directory where the csc.exe compiler is:
set PATH=%PATH%;C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322
Start the Build Environment (basically a command prompt with prepared environment variables) from the DotGNU/Portable.Net program group in the startmenu. Start the Mono command prompt from the start menu
PATH:
C:\Program Files\Borland\BDS\3.0\Bin
To compile your c# program:
csc hello.cs
cscc hello.cs -o hello.exe
mcs hello.cs
dccil
You execute the program:
hello.exe
ilrun hello.exe
mono hello.exe
hello.exe

VCL.net on other platforms than win32

I tried a very simple VCL.Net Application, with just a label on the form.
I copied from C:\Program Files\Borland\BDS\3.0\lib the files
Borland.Delphi.dcpil, Borland.VCL.dcpil, and Borland.VCLRTL.dcpil
into the same directory as the .exe file.
I changed the extensions from dcpil to dll. I run it, and got that output:

ilrun Project1.exe
metadata error: could not locate the .jar central directory
metadata error: could not locate the .jar central directory
metadata error: could not locate the .jar central directory
Project1.exe: invalid metadata in image

The reasons for that is:
see VCL and the Unmanaged Win32 API:
ms-help://borland.bds3/bds3dnetguide/html/LanguageIssues.htm
The interesting bit is the first paragraph of the section "Working with the Unmanaged Win32 API".
It says: "Units that require the Windows operating system are tagged with the platform directive"
Have a look into the source file for the TForm VCL.net implementation:
C:\Program Files\Borland\BDS\3.0\source\dotNet\vcl\Borland.Vcl.Forms.pas
It has the following lines, which indicate dependency on Win32:
unit Borland.Vcl.Forms platform;
const  user32 = 'user32.dll';
[DllImport(user32, CharSet = CharSet.Auto, SetLastError = False, EntryPoint = 'SendMessage')]
function SendMessage(hWnd: HWND; Msg: UINT; wParam: WPARAM; lParam: LPARAM): LRESULT; external;

SendMessage is used all over the place.

Another way of investigating dependancies is to use AssemblyExplorer, which quite nicely shows all the windows native dll that many Borland, even managed code, assemblies still have.

compile Mono with Winforms implementation on Cygwin

See Mono Compiling
MWF
Compiling Mono


Cygwin: you need autoconf, automake, libtool, gnome-lib, pkgconfig, Glib, all sorts of glib and glib-devel libraries libfontconfig-devel, libpng-devel, xorg-x11-devel, bison;
NOT glib2-devel
export PKG_CONFIG_PATH=/lib/pkgconfig:/usr/lib/pkgconfig:/usr/local/lib/pkgconfig:$PKG_CONFIG_PATH
for csc.exe:
export PATH=/cygdrive/c/WINDOWS/Microsoft.NET/Framework/v1.1.4322:$PATH
export PATH=/cygdrive/c/timotheus/mono/mcs/tools/resgen:$PATH

cd libgdiplus
./autogen.sh
Problem was: pkg-config complained: Did not find Glib >= 2.2.3
Solution: try to run: pkg-config --atleast-version 2.2.3 glib-2.0
Download the necessary libraries, all called glib and glib2, and the glib-devel libs

to compile cairo on its own, you need to add a line perhaps you need to add the line to autogen.sh:
ACLOCAL_FLAGS="-I /usr/share/aclocal"


http://www.mono-project.com/contributing/compiling.html#manually
download http://www.go-mono.com/archive/glib-2.0.4-20020703.zip
and http://www.go-mono.com/archive/glib-dev-2.0.4-20020703.zip
iconv as well
and unzip them into the cygwin directory
include => /usr/include
share => /usr/share
lib?

change C:\cygwin\lib\pkgconfig\glib-2.0.pc first line to prefix=/usr instead of target

configure: error: Your version of gwin32.h is broken and will cause compilation
errors when building mono. Please fix it by deleting the line: '#   define ftrun
cate...' from '/usr/include/glib-2.0/glib/gwin32.h' then re-run configure.

the dlls go into the bin directory, not lib

don't forget the dlls:
mcs swfbuttons.cs -r System.Windows.forms.dll -r System.Drawing

Compile mono on fedora core 3

yum install subversion
yum install gcc
yum install bison
yum install glib-devel
yum install glib2-devel
svn co ..../trunk/mcs
wget http://www.mono-project.com/contributing/mono-build.sh
run that
add /home/timop/mono/install/bin to $PATH
add /home/timop/mono/install/lib to $LD_LIBRARY_PATH
don't forget to copy the class libraries to /home/timop/mono/install/lib

The mono build scripts do not include the mcs binaries nor does it build mcs
for you.
You need to build mcs from cvs.
Once mcs built, then you can:
cp ~/mono/mcs/mcs/mcs* ~/mono/install/bin
cp ~/mono/mcs/class/lib/* ~/mono/install/lib

need to copy file /usr/X11R6/lib/libX11.so.6 to mono/install/lib, or change ld library path?
need to add line
dllmap dll="libX11" target="libX11.so.6"
to file install/etc/mono/config
to avoid message dllnotfoundexception libX11