Filmmaker, Video Editor, Motion Graphics Designer, and Photographer in Cairo, Egypt.
Keeping notes to remember.. You may consider it some sort of Documentation.

Stay In Touch

Wednesday, August 20, 2008

The Mono Porject


My first task in my summer training was to know what is Mono Project and how to install it on Linux Ubuntu. Sounds easy, like a bar of chocolate, isn't it?!

I felt so excited to know what is that thing called Mono. So I started searching at once, and where's what I found:
Mono provides the necessary software to develop and run .NET client and server applications on Linux, Solaris, Mac OS X, Windows, and Unix. Sponsored by Novell the Mono open source project has an active and enthusiastic contributing community and is positioned to become the leading choice for development of Linux applications.

The Mono Project's objective is to enable UNIX developers to build and deploy cross-platform .NET Applications. The project implements various technologies developed by Microsoft that have now been submitted to the ECMA for standardization.

The only thing .NET (Microsoft original framework) and Mono have in common are the idea. A central cross-platform development framework, and one is based on the other.

Mono allows you to write an application in a list of languages so you can use the language of your choice. You don’t need to learn something new in order to use it. Some of the languages currently supported in Mono are: C#, Visual Basic.NET, Javascript, ASP.NET, and others.

Considering that Mono is supported on Linux, UNIX, OSX, Solaris, BSD and Windows, you can write an application within one and almost instantly port it to the next. Assuming the other platform has the mono common libraries (which are included in Ubuntu and Windows for starters) and your application doesn’t depend on any platform dependent libraries. If this is the case you just wrote an application that can be used on Linux, OSX and Windows without any additional work.
See, as I said, just a bar of chocolate:D.

After about two hours, my CEO came to check my progress, and with a lot of excitement I told him:
- " I found what it is all ... I got it". In returns he said: - "Great! so tell me, which version of Mono works with which version of .NET??" - "Oh .. ah .. well .. I can't remember that I read something about that ... give me couple minute and I'll figure it out :D"

I've to say that it was a little bit embracing :"> ... I know Right-Brained people like me are big picture oriented, and that's why I miss small details :-S


Anyway, till this moment, the latest version of .NET is 3.5, and the latest version of Mono is 1.9. But (also for the current moment) Mono supports .NET 2.0 only!! Some of .NET 3.0 and 3.5 new features are supported, but still most of them under developing.

My references for this post, and for more details, check those links:
- Squashing A Few Myths About Mono
- Mono (Software) from Wikipedia
- Mono Project Website

Thursday, August 14, 2008

How To Configure ASP.NET websites On Ubuntu Localhost


To those who are interested in developing ASP.NET websites on Ubuntu operating system and mono platform, here's the steps to configure your website to the localhost.

1- Install Apache web server on your machine (you may use the Synaptic Package Manager for that).
2- Install Mod-Mono module, the Apache module responsible for serving and rendering ASP.NET pages.
3- Develop your website normally using MonoDevelop IDE.

Now, your application would run normally by the MonoDevelop. But, it still not configured on the localhost. So we need to create a " virtual directory" for the new website to be hosted. Virtual directors are made on 5 main steps. Let's assume that the new website we wanna to add in the local host is named "new_ASP_Solu", and the path of the default.aspx file is "new_ASP_Solu/new_ASP_Solu"

Step 1: Copy your solution in the /var/www directory
  • Write in the terminal the following command line:
$ sudo cp -r Desktop/new_ASP_Solu /var/www
  • sudo => is short for "superuser do", it allows a permitted user to execute a command as the superuser or root user.
  • cp => is short for "copy", it copies only on single file.
  • -r => an option added to some Linux commands to make it execute recursively. That's why we're using it here, to copy the whole directory :D
  • Desktop/new_ASP_Solu => the path of the solution. (It's just an assumption that it exists on the Desktop)
  • /var/www => the distention path, where we're coping the new website.
Step 2: Add a new virtual directory to the "Default"
If you opened the /etc/apache2/sites-available directory, you'd find one single file called "Default". This is where you should add the new virtual directory.
  • Open this file using this command:
$ sudo vi /etc/apache2/sites-available/Default
    • vi => is Linux text editor, use it to edit any file you wish.
  • Append the following code between the two tags <virtualhost> and </virtualhust>
<directory /var/www/new_ASP_Solu/new_ASP_Solu>
Options Indexes FollowSymLinks MultiViews
AllowOverride all
Order allow,deny
Allow from all
SetHandller mono
DirectoryIndex Deault.aspx index.html
</directory>
  • /var/www/new_ASP_Solu/new_ASP_Solu => the path of the default.aspx file.
  • SetHandller mono => determines the Apache module that will render this solution pages.
  • DirectoryIndex => it determines the website default (or starting) web page. In this case it's the Default.aspx, and for HTML it'd be the index.html.
Step 3: Create a file named "new_ASP_Solu.webapp"
  • Create a new file in /etc/mono-server2, with the same name of the solution, but the the extension .webapp
$ sudo touch /etc/mono-server2/new_ASP_Solu.webapp
    • touch => command creates an empty file.
  • Open this new empty file
$ sudo vi /etc/mono-server2/new_ASP_Solu.webapp
  • Add this code in it:
<apps>
<web-application>
<name>new_ASP_Solu</name>
<vpath>/new_ASP_Solu</vpath>
<path>/var/www/new_ASP_Solu/new_ASP_Solu</path>
<vhost>localhost</vhost>
<port>80</port>
</web-application>
</apps>
  • name => just give a name to your new web site.
  • vpath => the virtual path of your web page on the local host. In this case, if you typed in your web browser "http://localhost/new_ASP_Solu" it will open your solution.
  • path => the local path of your solution on your PC.
  • port => determines the port number to use.
Step 4: Add the new virtual directory in httpd.conf file
  • Open the httpd.conf file
$ sudo vi /etc/apache2/httpd.conf
  • Append the following:
MonoApplications "/new_ASP_Solu:/var/www/new_ASP_Solu/new_ASP_Solu"
<location /new_ASP_Solu>
SetHandler mono
</location>

Step 5: Restart Apache
This step is mandatory to run your website correctly.
$ sudo /etc/init.d/apache2 restart

Now, go to your web browser, type "http://localhost/new_ASP_Solu" in the address bar. Yep! It works!! ;) :D.

Monday, August 11, 2008

Error With MySQL Connection With C#


While I was trying to compile a simple C# program that connects to a MySQL database, I got a compilation error about a missing file called "libmono-il8m2.0"!!! Take into consideration that I was on Linux/Ubuntu operating system, using Mono Project platform, and MonoDevelop IDE. So, here's the steps I tooked in order to get out of this trouble:
  1. Searched about that file (it's full name is "libmono-il8n2.0-cil")
  2. Installed it:
  • Using the Synaptic Package Manager.
  • OR, from terminal: $ sudo apt-install libmono-il8n2.0-cil
  • If you've been asked for a passowrd, enter the passowrd of your PC.
3. Recompile your solution again from the MonoDevelop or from the terminal, it'd work prefectly now :)

Sunday, August 10, 2008

Connect To Server Through FTP Command


To connect to a server using command prompt (for Microsoft Windows) or terminal (for Linux), use the "ftp"' command followed by the server IP-address.

Say, for example, that the server IP address is "10.2.2.25", so you'd write the following on your command prompt:
$ ftp 10.2.2.25

Then click enter.

After few seconds you'd be connected directly to your server and can brows it using usual commands such as cd, get, ls, etc.

And in order to log-out or disconnect from this server connection, just use the command "quit"
$ quit