xyzio

Archive for the ‘Mono’ Category

libapache2 mod_mono install freezing during install on Ubuntu at Digital Ocean

with one comment

I had a problem with my libapache2-mod-mono install freezing during install when trying to run ASP.NET applications on Ubuntu.

The workaround for this is to open another session and restart/reload apache:

root@xyzio:/home/xyzio# service apache2 reload
root@xyzio:/home/xyzio# service apache2 restart

This is what I would see and the session would freeze at the [OK]:

apt-get install libapache2-mod-mono

Setting up libapache2-mod-mono (2.11+git20130708.6b73e85-2) ...
Using mono-apache-server4...
apache2_invoke: Enable module mod_mono
* Restarting web server apache2 [ OK ]
apache2_invoke: Enable module mod_mono_auto
* Restarting web server apache2 [Sun Dec 08 23:03:01.698809 2013]
[so:warn] [pid 4455] AH01574: module mono_module is already loaded, skipping
[ OK ]

Source:
http://askubuntu.com/questions/135547/how-do-i-set-up-mod-mono-on-11-10

Advertisements

Written by M Kapoor

February 5, 2014 at 10:00 pm

Generating PDFs using iTextSharp on Mono

leave a comment »

I was looking for a .NET pdf generator so that I could add online bingocard generation to my side project, BingoWords.  The code and website are built using .NET and I run the site under Mono on a VPS at Linode.  So, it was important that the PDF generator run under Mono without issues.  Being cheap and full featured were two other desired features.  After some research, I found that there were two major players that satisfied this criteria,  PDFSharp and  iTextSharp.  Both are open source, free, and are fully featured.

Although some posts on the web indicated that PDFSharp would run under Mono, it was a no-go from  the beginning.  It failed the mono compatibility tool – Mono Migration Analyzer or M0MA almost right away.  I still decided to try out PDFSharp with Mono after reading a few posts stating that it may work if my code avoided the non-Mono compatible portions of the code but that was a total failure.  

So, I had no choice but to use iTextSharp.  iTextSharp passed under MoMA and it worked great on my Linode VPS under Mono.  With iTextSharp, I can generate PDFs that comply with the PDF standard and are viewable on every major platform.  So, if you are planning to generate PDFs under Mono, I would highly recommend iTextSharp.  Or to get a better sense of the features, try out my free Online Bingo Card Generator!

 I noticed that weren’t many code samples available while doing my research and coding the Bingo Card Generator.  So, here are some samples from my code for those that are just getting started:

Creating a new PDF document:

MemoryStream ms = new MemoryStream();
Document document = new Document(PageSize.LETTER);
PdfWriter writer = PdfWriter.GetInstance(document, ms);
document.Open();

Creating a BaseFont.  A BaseFont contains the parameters of the font that is written to the PDF document:

BaseFont bf = BaseFont.CreateFont(BaseFont.COURIER, BaseFont.CP1252, BaseFont.NOT_EMBEDDED);

Writing center-aligned text to 400pts from the left and 400pts from the top:

cb.BeginText();
cb.ShowTextAligned(PdfContentByte.ALIGN_CENTER, “Title Text”, (int)(Math.Abs(400, 400, 0);
cb.EndText();

Getting the width of a string in points:

titleWidth = (int)cb.GetEffectiveStringWidth(“Hello World!”, false);
Setting the font size of a BaseFont:
cb.SetFontAndSize(bf, titleFontSize);

Draw a line from the top left to the bottom left of the document:

cb.MoveTo(document.Left, document.Top);
cb.LineTo(document.Left, document.Bottom);
cb.Stroke();

Editing the document’s properties:

document.AddTitle(“Designed by BingoWords.com”);
document.AddAuthor(“Author goes here!”);
document.AddSubject(“Subject Goes Here!”);
document.AddKeywords(“Keyword1, keyword2, …”);

Closing your document:

document.Close();

Put this after the “document.Close()” to return your document with the name “file.pdf” when a user clicks on a link:

Response.ContentType = “application/pdf”;
Response.AddHeader(“content-disposition”, “attachment;filename=file.pdf”);
Response.Buffer = true;
Response.Clear();
Response.OutputStream.Write(ms.GetBuffer(), 0, ms.GetBuffer().Length);
Response.OutputStream.Flush();
Response.End();

I hope this comes in handy.  Feel free to contact me if you have any questions or comments.

Written by M Kapoor

June 20, 2010 at 5:52 am

Free Bingo Card and Wordsearch Designer

leave a comment »

If you are looking for a free Bingo Card or Wordsearch Designer then look no more – BingoWords Puzzle Designer is now free for everybody!  Click here to go to the website!

Features:

  • Create arbitrary sized Wordsearch puzzles
  • Create Bingo Cards up to 5×5 squares in size
  • Save your wordlists for future use and to share with co-workers
  • Print an unlimited number of Bingo Cards and Word Search Puzzles
  • Print up to 8 Bingo Cards per page
  • Quick access to common word lists using the built in Word Wizard

For more details, read on.

Why is it Free?

Originally, I was planning to sell Bingo Words Puzzle Designer but then I realized that I’d rather spend my free time working on new code instead of on marketing and all the hassle that comes with running a business.  Besides, putting together something like this only took me a couple weeks of part-time work and it annoys me that some people are charging over $30/copy for something that is this simple to make.

My hope is that it will be useful to someone and that they will pay it forward some day.

About

BingoWords Puzzle Designer is a project I worked on in order to teach myself C#/ASP.NET.  The application is made with C# and Winforms.  The website is build using ASP.NET and is hosted using Mono on a  virtual server at Linode.  I was able to learn every aspect of creating an app with this project – from drawing on the screen to printing and to saving files to generating serial numbers.

Feel free to contact me with questions or suggestions for improvement!

Written by M Kapoor

February 19, 2010 at 4:06 am

Getting Mono Working at Linode on Ubuntu 9.10

leave a comment »

I’m looking into moving one of my ASP.NET projects to Mono and had trouble getting Mono working on Ubuntu 9.10. Turns out the steps to set it up were simple, but they took some digging around so here they are:

Step 1:

Install Apache2:
apt-get install apache2 apache2.2-common apache2-mpm-prefork apache2-utils libexpat1 ssl-cert

Step 2:

Enable the Universe repositories. To do this, uncomment the universe repositories in /etc/apt/sources.list so it looks like this:

## main; restricted repositories
deb http://us.archive.ubuntu.com/ubuntu/ karmic main restricted
deb-src http://us.archive.ubuntu.com/ubuntu/ karmic main restricted

deb http://security.ubuntu.com/ubuntu karmic-security main restricted
deb-src http://security.ubuntu.com/ubuntu karmic-security main restricted

## universe repositories
deb http://us.archive.ubuntu.com/ubuntu/ karmic universe
deb-src http://us.archive.ubuntu.com/ubuntu/ karmic universe

deb http://us.archive.ubuntu.com/ubuntu/ karmic-updates universe
deb-src http://us.archive.ubuntu.com/ubuntu/ karmic-updates universe

deb http://security.ubuntu.com/ubuntu karmic-security universe
deb-src http://security.ubuntu.com/ubuntu karmic-security universe

Step 3:

Run ‘apt-get update’ to get the latest sources.

Step 4:

Finally, follow the steps listed in the Ubuntu ModMono guide:

Install the mod_mono packages: libapache2-mod-mono mono-apache-server2-
apt-get install libapache2-mod-mono mono-apache-server2

Enable the Apache module:
a2enmod mod_mono_auto

Restart Apache:
apache2ctl graceful

Step 5:
Place a .aspx page where Apache can see it, for example at ‘/var/www/’

Written by M Kapoor

January 2, 2010 at 10:03 pm

Posted in ASP.NET, hosting, Linode, Mono

Tagged with , , ,