There was a question on the mono IRC about how to Copy&Paste from a Console window when running a console application from within MonoDevelop.

I tried to reproduce that, and first got the error:

cannot execute … File name has not been set

The answer is that you have to install the xterm package. See http://stackoverflow.com/questions/21834612/how-does-one-set-the-filename-in-monodevelop

Actually, here is the source that determines which terminal to use: https://github.com/mono/monodevelop/blob/master/main/src/addins/GnomePlatform/GnomePlatform.cs#L305

So it tries gnome-terminal, mate-terminal and konsole, depending on the environment variables for the desktop (GNOME_DESKTOP_SESSION_ID, MATE_DESKTOP_SESSION_ID, or KDE_SESSION_VERSION). If that fails, it falls back to xterm.

I am using XFCE4, and MonoDevelop falls back to xterm.

Copy&Paste in xterm works like this: just select the text, and then focus the application where you want to paste the text, and hit the middle mouse button. see also http://askubuntu.com/a/237947/194547

Tags: ,
Posted in Software Development | Comments Closed

Debugging Mono Web Services   June 27th, 2014

I had this problem that the asmx files did display fine in the browser, but when I called a function, it would always return a red Zero.

To get to the bottom of this problem, I created a web.config file with this content:

<configuration>
    <system.web>
        <customErrors mode="Off"/>
    </system.web>
    <compilation debug="true" />
</configuration>

Best to use a clean directory without a bin subdirectory, for testing.
Use the MathService sample asmx file from http://www.mono-project.com/Writing_a_WebService:

<%@ WebService Language="C#" Class="MathService.MathService" %>
 
using System;
using System.Web.Services;
 
namespace MathService
{
	[WebService (Namespace = "http://tempuri.org/NumberService")]
	public class MathService : WebService
	{
		[WebMethod]
		public int AddNumbers (int number1, int number2)
		{
			return number1 + number2;
		}
 
		[WebMethod]
		public int SubtractNumbers (int number1, int number2)
		{
			return number1 - number2;
		}
	}
}

Starting the xsp server for testing purposes:

. /opt/mono/env.sh
cd /var/www/openpetra
MONO_OPTIONS=--debug xsp4 --port 80 --verbose

When you now call the asmx file in your browser, you see the output on the console.

In my case there was an error about sqlite3.dll in the bin directory, which is a windows dll, and this caused trouble for the server.

But it still did only show a red zero. Finally I looked at the html source of the asmx file in the webbrowser, and I realised that the ports got mixed up, since I was using port forwarding into a virtual machine. So the port defined in the webbrowser was different than the port that xsp was running on.

The url in the browser is: http://myhost:8090, but this is the url in the source code:

getXML ("GET", "http://myhost/test.asmx/SubtractNumbers", "number1=asf&number2=asdf");

To solve this: make sure that in your /etc/lighttpd/vhosts.d/openpetra9000.conf, you have a server.name set with a value that the server is reachable from the client.
It seems the document path is also part of server.name. You can put the port into another variable called server.port, but then the port will be attached to the server.name, after the document path.

In the end, I am now only using the default port.

Tags: ,
Posted in Software Development | Comments Closed

I have just finished the work on the latest MonoDevelop packages.

Quite a bit has changed in the build process, so it needed some work to make the build from tarball finish successfully again.
See this thread on the mailinglist: http://lists.ximian.com/pipermail/monodevelop-list/2014-May/016077.html

I have updated the packages at
https://build.opensuse.org/project/monitor/home:tpokorra:mono

MonoDevelop 4.2.5:
http://software.opensuse.org/download.html?project=home%3Atpokorra%3Amono&package=monodevelop-opt

MonoDevelop 4.3.4:
http://software.opensuse.org/download.html?project=home%3Atpokorra%3Amono&package=monodevelop-beta

MonoDevelop 5.1 (nightly build from this morning):
http://software.opensuse.org/download.html?project=home%3Atpokorra%3Amono&package=monodevelop-alpha

By the way, I am working on a new project called LightBuildServer, which is a very light-weight alternative to OBS.
see http://lightbuildserver.org

Tags: , , ,
Posted in Software Development | Comments Closed

This post covers several topics at once:

I have got some experience with OpenVZ, and was looking how LXC could satisfy the requirements that I am used to. Especially how to install several Linux distributions on one LXC host. I will show how to install CentOS, Ubuntu, and Debian Wheezy on a Ubuntu LXC container.

The other issue is that I wanted to play with a virtual machine called JiffyBox provided by DomainFactory.

Let’s look first at how to configure the JiffyBox, before we configure the LXC containers:

This post on the web Linux Containers (lxc) in Linode (xen)  helped me to understand how LXC works fine on a JiffyBox.
With the default kernel from JiffyBox, lxc-checkconfig shows that some requirements for LXC are missing.
JiffyBox allows you to start from a custom kernel. Now I was looking for a fitting kernel to install.
I have no idea how to do that on CentOS, but on the mentioned blog I found that Ubuntu can easily install a kernel that works fine for virtualization.

So you install a 64 bit Ubuntu JiffyBox, and then run these commands to setup LXC:

apt-get install lxc linux-virtual

After that, in the admin website of JiffyBox, select the custom kernel Bootmanager 64 Bit (pvgrub64); see also the german JiffyBox FAQ. Then restart your JiffyBox.

After the restart, uname -a should show something like:

Linux j80074.servers.jiffybox.net 3.2.0-58-virtual #88-Ubuntu SMP Tue Dec 3 17:58:13 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux

Now we will install some virtual machines:

First an Ubuntu 12.04 (precise) machine, which should work without any problems:

lxc-create -t ubuntu -n demo1
lxc-start -n demo1

You can login with username ubuntu, and password ubuntu. To get out of the machine, you type shutdown -h now.

To make the machine start at boot time, and to visit the console once the machine is running, type this:

ln -s /var/lib/lxc/demo1/config /etc/lxc/auto/demo1.conf
lxc-console -n demo1

By the way: you find the templates in /var/cache/lxc/, and the containers in /var/lib/lxc/.

For Debian, there is a template in directory /usr/lib/lxc/templates, but that is for Debian 6 (Squeeze). You need to slightly modify the template, so that Debian 7 (Wheezy) is installed. See my gist for that: Debian Wheezy template file

wget https://gist.github.com/tpokorra/8488744/raw/f1d050704e8cc8c70dd956eb18e6374d70f8ecf6/lxc-debian-wheezy
mv lxc-debian-wheezy /usr/lib/lxc/templates/lxc-debian-wheezy
chmod a+x /usr/lib/lxc/templates/lxc-debian-wheezy
lxc-create -t debian-wheezy -n demo2

You can login with username root and password root.

For CentOS, I have modified an existing Gist, so that it works for the latest CentOS 6.5. You might to check the latest differences in the revision, to adjust the script to future releases of CentOS. Have a look at my gist for lxc-centos.

wget https://gist.github.com/tpokorra/8488836/raw/dbcd0920c1b9047da707c318190959cf64d72f7c/lxc-centos
mv lxc-centos /usr/lib/lxc/templates/lxc-centos
chmod a+x /usr/lib/lxc/templates/lxc-centos
apt-get install yum
lxc-create -t centos -n demo3

You can login with username root and password password.

In this blog post, I want to describe some of the workarounds I need to do to release the latest mono and monodevelop packages on OBS.

For more details on this project from a using perspective, see:
Easy installation of current Mono and MonoDevelop for all major Linux Distributions

The download of the source files is specified in the _service file, eg. https://build.opensuse.org/package/view_file/home:tpokorra:mono/mono/_service?expand=1

The problem is that sometimes the tarballs are not available on http://download.mono-project.com/sources/mono or http://download.mono-project.com/sources/monodevelop, especially for the Alpha releases.

As long as you can find a tagged release at Github, you can build your own tarball (eg. on CentOS):

Preparations:

wget -O /etc/yum.repos.d/home:tpokorra:mono.repo http://download.opensuse.org/repositories/home:tpokorra:mono/CentOS_CentOS-6/home:tpokorra:mono.repo
yum install git-core automake autoconf libtool tar which gcc-c++ gettext mono-opt bzip2

For Mono:

git clone https://github.com/mono/mono.git
cd mono 
git checkout -b tarball mono-3.2.5
./autogen.sh
. /opt/mono/env.sh
make dist

And for MonoDevelop:

git clone https://github.com/mono/monodevelop.git
cd monodevelop
git branch tarball monodevelop-4.3.0
git checkout tarball
. /opt/mono/env.sh
./configure
make dist

I have uploaded the resulting tarballs to http://download.pokorra.de/mono/tarballs/, and my _service files are now referencing that location if the official source directory is missing the tarball or the tarball is broken.

Tags: , , ,
Posted in Software Development | Comments Closed

Install OpenPetra on Linux   November 15th, 2013

Installing OpenPetra on Linux should be fairly easy.

Please note that the server works fine on Linux, but the client is not yet fully reliable. But the more interest and fixes it gets, the chances are higher that the client will become stable on Linux too.

We need for the server a patched version of Mono, for the .Net remoting. In the future we aim to switch away from .net remoting to https, but that is still experimental.
The client should be fine with Mono 2.10 upwards.

Install Mono 3.2.3 with OpenPetra patches:
The mono-openpetra package is available for Debian, Ubuntu and CentOS from http://software.opensuse.org/download.html?project=home%3Atpokorra%3Aopenpetra&package=mono-openpetra.
Please follow the instructions there for installing Mono.

I will do this tutorial with Ubuntu LTS 12.04 (precise):

wget http://download.opensuse.org/repositories/home:tpokorra:openpetra/xUbuntu_12.04/Release.key
apt-key add - &lt; Release.key echo 'deb http://download.opensuse.org/repositories/home:tpokorra:openpetra/xUbuntu_12.04/ /' &gt;&gt; /etc/apt/sources.list.d/mono-openpetra.list
apt-get update
apt-get install mono-openpetra

Next thing is to install Postgresql 9.1:

apt-get install postgresql

Now you download the latest release of OpenPetra for Linux from Sourceforge OpenPetra Downloads:

wget http://sourceforge.net/projects/openpetraorg/files/openpetraorg/OpenPetra.org%20Alpha%200.2/openpetraorg-server-debian-postgresql-MyOpenPetra-0.2.26.4.tar.gz/download -O openpetraorg-server-debian-postgresql-MyOpenPetra-0.2.26.4.tar.gz

There is also a package available for CentOS/RedHat based distributions:

wget http://sourceforge.net/projects/openpetraorg/files/openpetraorg/OpenPetra.org%20Alpha%200.2/openpetraorg-server-centos-postgresql-MyOpenPetra-0.2.26.4.tar.gz/download -O openpetraorg-server-centos-postgresql-MyOpenPetra-0.2.26.4.tar.gz

By the way, the code for this release is currently maintained here: https://github.com/openpetra/openpetra/tree/Alpha-0.2.26-Linux

Now, unpack your server tar.gz file:

tar xzf openpetraorg-server-debian-postgresql-MyOpenPetra-0.2.26.4.tar.gz
cd openpetraorg-0.2.26.4
# have a look at the INSTALL file
cat INSTALL
cp config-sample.sh config.sh
# have a look at config.sh; we are not configuring the .net remoting keys at the moment
cat config.sh
. config.sh
./setup.sh

Next thing, you initialise the database:

/etc/init.d/openpetraMyOpenPetra createdb
/etc/init.d/openpetraMyOpenPetra init
/etc/init.d/openpetraMyOpenPetra start

If you get an error like “Possible cause: Npgsql.NpgsqlException: Failed to establish a connection to ‘localhost’.”, try to edit /etc/postgresql/9.1/main/postgresql.conf and enable listen_addresses = '*'. Then service postgresql restart. I don’t currently know why this is necessary on my computer.

Now you should download an empty database, or a demo database from Sourceforge Demo Databases:

wget http://sourceforge.net/projects/openpetraorg/files/openpetraorg/demodata/demoWith1ledger.yml.gz/download -O /tmp/demoWith1ledger.yml.gz

Then load this database:

/etc/init.d/openpetraMyOpenPetra loadYmlGz /tmp/demoWith1ledger.yml.gz

Please note that the path for the demo file must be readable by the user that the openpetra server is running under, that is why I am using the /tmp directory.

For the OpenPetra client on Linux, you also need to install mono-openpetra-libgdiplus:

apt-get install mono-openpetra-libgdiplus

Get the linux client, and unpack it:

wget http://sourceforge.net/projects/openpetraorg/files/openpetraorg/OpenPetra.org%20Alpha%200.2/openpetraorg-client-MyOpenPetra-0.2.26.4.tar.gz/download -O openpetraorg-client-MyOpenPetra-0.2.26.4.tar.gz
tar xzf openpetraorg-client-MyOpenPetra-0.2.26.4.tar.gz
cd openpetraorg-0.2.26.4
./startClient.sh

At the moment, the communication between client and server is not encrypted. This can be enabled though, or you can use a VPN.
We are working on switching to https, replacing .Net remoting in the near future.

To connect the client to another server than localhost, you need to modify the file etc30/PetraClientRemote.config in the client directory, search for localhost and replace it with the hostname of your server! You might need to work on the firewall settings of the server, to allow communication on port 9000, or change to a more common port, eg. 80.

Known issues in the OpenPetra client for Linux:

  • There will be a message, that the patches cannot be found. Please ignore that, and try to login with user demo and password demo!
  • Partner Find layout of the window is broken.  Sometimes it does not find partners, says: no criteria. Workaround: tab out of current control. It worked for me the second time I opened the Find partner screen.
  • Partner Edit screen: also gives lots of errors. Cannot close without saving, when saving complains about empty address.
    The finance screens (Gift Batch, GL Batch, etc) might work better.

The question is: should we invest into the fat OpenPetra client to run on Linux and on Mac, or should we work on a client running in the browser, eg. based on Twitter Bootstrap, see the OpenPetra Demo with Twitter Bootstrap!

Tags: ,
Posted in Software Development | Comments Closed

For OpenPetra, we want to provide a preconfigured Linux machine, so that interested developers can have a quick start, and don’t need to spend so much time on installing a development environment.

I looked at FreeNX, NeatX, OpenNX, and X2Go.
NeatX does not seem to be continued.

FreeNX with OpenNX works, but I had problems with the sound.
To install FreeNX on Ubuntu Oneiric, follow the instructions at Ubuntu Forums. This avoids the problem with esound and libesd0 packages.


Finally, I have to say that X2Go works best for me. Sound is played, and access from Windows and Linux works fine to my Linux Remote Desktop.


To install the X2Go server on Ubuntu Oneiric:

 apt-add-repository ppa:x2go/stable
 add universe to /etc/apt/sources.list
 apt-get update
 apt-get install x2goserver

You get the client from http://code.x2go.org/releases/binary-win32/x2goclient/


One thing I had problems with: there was a blank or black screen, after logging in.
To debug this: I searched the log files, but could not find any clues. Then I remembered this: use the terminal as login shell, which works. There you can start your desktop manager, in my case /usr/bin/startlxde.
The error that came up was: missing libNX_Xext.so.6
I then found on the mailing list a discussion: http://www.mail-archive.com/x2go-dev@lists.berlios.de/msg03254.html
So I added the line 

 LD_LIBRARY_PATH=/usr/lib/nx/X11



at the top of /usr/bin/startlxde, and everything works now.


I also installed libjpeg-turbo, which should make the remote desktop even faster:

wget 'http://sourceforge.net/projects/libjpeg-turbo/files/1.2.0/libjpeg-turbo_1.2.0_i386.deb/download' -O libjpeg-turbo_1.2.0_i386.deb
dpkg -i ...
rm /usr/lib/i386-linux-gnu/libjpeg.so.62
ln -s /opt/libjpeg-turbo/lib/libjpeg.so.62.0.0 /usr/lib/i386-linux-gnu/libjpeg.so.62



One useful key combination is ctrl alt t, which allows you to terminate or to suspend the current session.
It seems ctrl alt k does not work with X2Go, which would allow the task switching with Alt Tab to be inside the Linux workstation.
The shortcuts available from NoMachine are listed here: http://www.nomachine.com/ar/view.php?ar_id=AR03C00172


By the way, I got X2Go work fine on virtual machines running on VMWare ESXi, and also on OpenVZ.

We have upgraded all the code of OpenPetra to .net 4.0.
We also upgraded to Ext.Net 1.2.

There were two bugs in Mono 2.10, which were show-stoppers:
http://bugzilla.xamarin.com/show_bug.cgi?id=2505 was a problem with the mono compiler, in Mono 2.10.x
This was fixed in mono master.

So I tried to build mono from master, but then I had problems with fastcgi, while xsp4 was serving the content correctly:
http://bugzilla.xamarin.com/show_bug.cgi?id=2876
This was also fixed in mono master.

Below is a link to a tar.gz file, that contains the build of Mono, with mod_mono and xsp, at the beginning of February 2012.

I wanted to use lighttpd and fastcgi with Mono and Ext.Net, but that did not work.
The error that I got was similar as to described here, but without a solution that works for me:
http://forums.ext.net/showthread.php?14040-All-DirectEvents-Is-Error
It works fine with xsp4.

I then tried with mod_mono and apache2:
I came across this issue http://forums.ext.net/showthread.php?12348-404-Not-Found-for-a-few-resources-requests, that the resources cannot be loaded. The solution from that thread also helped me:
Add CleanResourceUrl = “false” to your .aspx file:

<ext:ResourceManager  runat="server" CleanResourceUrl="false" />
So here are my configuration steps for Ext.Net with Mono and Apache2:

This works with Ubuntu Oneiric 64 bit (11.04). But it might work on other Ubuntu/Debian version as well. I have also used it on CentOS.

apt-get install apache2
cd /opt
wget http://download.pokorra.de/mono/ubuntu/mono.tar.gz
for 32 bit: wget http://download.pokorra.de/mono/ubuntu32/mono.tar.gz
tar xzf mono.tar.gz
cd /usr/lib/apache2/modules/
wget http://download.pokorra.de/mono/ubuntu/mod_mono.so
for 32 bit: wget http://download.pokorra.de/mono/ubuntu32/mod_mono.so
cd /etc/apache2/mods-enabled
wget http://download.pokorra.de/mono/ubuntu/mod_mono.conf
# note that mod_mono.conf contains this line:
# MonoServerPath /opt/mono-2.10-git/bin/mod-mono-server4
vi /etc/init.d/apache2
# search for LANG, and replace with this line:

ENV="env -i LANG=en_GB PATH=/opt/mono-2.10-git/bin:/usr/local/bin:/usr/bin:/bin"

Mono will create a directory /var/www/.mono which should not be public.
In your apache site configuration file, add just before 

           Deny from all

cd /var/www
wget http://download.pokorra.de/mono/ubuntu/extnet-sample-mono.tar.gz
tar xzf extnet-sample-mono.tar.gz
chown -R www-data:www-data /var/www
/etc/init.d/apache2 restart

See the result here:
http://demo.openpetra.org/DemoDesktop

This is the demo for the Desktop from Ext.Net 1.2, with a slight modification in Default.aspx and Desktop.aspx for the ResourceManager as described above.

Ext.Net and Mono   March 15th, 2011

I like ext.js/Sencha for having a rich client in the browser.

On the other hand, we are using Mono for running our .Net server.

ext.net is a good library that helps you to easily write web applications, based on your .net libraries.

For OpenPetra, I have created an online application system, and the backend for the registration office is written with ext.net.
Here are some problems I came across, and how I solved them:
First, I had to recompile the ext.net dlls and also the Newtonsoft.Json.Net20.dll.
The Newtonsoft.Json.Net20.dll has been compiled with the latest compiler built from Mono 2.8 trunk. This was necessary so that no Microsoft dlls were linked in.
The ext.net dll was built against the Mono compiled Newtonsoft.Json.Net20.dll on Windows with SharpDevelop. The mono compiler crashed on Linux when trying to build the ext.net solution.
The resulting files are available from the online source repository of OpenPetra, eg. http://bazaar.launchpad.net/~openpetracore/openpetraorg/trunkhosted/files/head:/csharp/ThirdParty/ext.net/
I was not able to get Ext.Net to run with the latest Mono 2.8, but it is working fine with 2.6.7.
I had to build it from the sources.
Some links related to the problems I had with Mono 2.8 and Ext.Net:
compile ext.net: There is no implicit reference conversion from `Ext.Net.ComboBox’ to `Ext.Net.ComboBoxBase
Running ext.net on Mono 2.8: get the error: Cannot add a Ext.Net.Parameter to System.String
For the moment, the solution for me was to use Mono 2.6.7.
The examples of ext.net only show the c# code inside the aspx file, but with growing size of the code it would be good to be able to split the code behind code from the UI code.
This is possible, but you need to define all controls in the .cs file, at least those you want to use in your code behind code.
In the aspx file, make sure you have at the top:
<%@ Page Language="C#"
Inherits=”Ict.Petra.WebServer.MConference.TPageOnlineApplication”
src=”Desktop.aspx.cs” %>

<%@ Register assembly="Ext.Net" namespace="Ext.Net" tagprefix="ext" %>

see the whole file here: OnlineRegistrationBackend/Desktop.aspx

Now I ran into errors like this when Mono was compiling the code on the fly:

Compiler Error Message: CS1644: Feature `anonymous types’ cannot be used because it is not part of the C# 2.0 language specification

I found on the Internet this page: http://www.4guysfromrolla.com/articles/121207-1.aspx

linked from http://web.archiveorange.com/archive/v/c2PM7RMRJf7Ti7PP7uVb, where they discuss how to use “extension methods” and “collection initializers” with Mono.
I have added all those settings to my web.config, see the result here:
You can see a running demo here: http://demo.openpetra.org:8009/
Today I wanted to install Smoothwall on a fan-less device, Lex Light LG8302.
There is the tool UNetbootin http://unetbootin.sourceforge.net/, but it does not support the Smoothwall iso image, and even if it copies to iso file to USB, when you boot from it you get the UNetbootin default option, but that does not do anything.
I used 7zip to extract the iso image of Smoothwall, which gives me the [Boot] directory.
It seems that UNetbootin is not able to extract the boot files from the iso image, from Bootable_2.88M.img, even though it does attempt it.
I used RawWrite for Windows (http://www.chrysocome.net/rawwrite) to extract the files from Bootable_2.88M.img. The partition size of the USB stick will be only 2 MB, but that is ok for the moment. Copy the files initrd.img, vmlinuz und syslinux.cfg to your local harddrive. Change the names from capital to lower case letters. Reformat the USB stick to its normal size. Then run again UNetbootin, and use the Smoothwall iso image as the source. Then copy the 3 files initrd.img, vmlinuz und syslinux.cfg to the USB stick, you will need to overwrite the existing syslinux.cfg.
To test the USB stick with VMWare, I followed the instructions at http://www.pendrivelinux.com/boot-a-usb-flash-drive-in-virtualbox/.
Then on the fan-less device, I first was not sure how to get it to boot from the usb stick. Then the hint was on http://nion.modprobe.de/blog/archives/343-My-new-Lex-Light-CV860A.html where it tells that you have to change the boot order to use USB-ZIP which will boot from the USB stick.
UPDATE:
it seems I rejoiced too early…
The installer does start from the USB stick, and does format the harddrive, but then it does not seem to find the file smoothwall.tgz and does not install all the network card drivers. So even the network install does not work.
The function findharddiskorcdrom looks for CDROM or harddrive, but I could not figure out why it does not find the USB stick. It only seems to check /dev/scd0, but no other device.