Mono

[SOLVED] System.ExecutionEngineException: Attempting to JIT compile method

Oliver Brown
— This upcoming video may not be available to view yet.

TLDR: Check multiple references to the same nuget package are all on the same version if you use the Mono linker.

Since my ability to post regularly on things I’m interested in is not great, I figured I could at least post stuff that might be useful.

I recently upgraded a Xamarin iOS app from the “classic” (32bit only) API to the Unified API. After doing so I got the error message:

System.ExecutionEngineException: Attempting to JIT compile method
```.

This is caused by the Xamarin (Mono) linker removing code that is only referenced dynamically. The usual solution is to let the compiler know somehow that you are using the code (using a Preserve attribute if it's your own code or something like MvvmCross's [LinkerPleaseInclude.cs](https://github.com/MvvmCross/MvvmCross/blob/f72a92e8a81b9179d1f75d6214eee8c9ca176221/nuspec/TouchContent/LinkerPleaseInclude.cs.pp) otherwisr).

In my case, this did not fix the problem. It turns out the Unified API upgrade was a red herring. I had also updated a few nuget packages at the same time. One of them was used in several projects, but I'd missed updating one of them (so I had Project A using v1 of a package and Project B using v2 of a package). This meant my efforts to stop the linker from removing some stuff only worked on one version of the package.

LINQ is magical

Oliver Brown
— This upcoming video may not be available to view yet.

The secretly named language learning app has been revamped to use LINQ for most of the XML handling. For those that don’t know, LINQ is a new technology that provides querying functionality in the .NET world. In my case I’m using LINQ to XML and it has seriously cut down on the size of the heaviest methods. Also, the part of LINQ to XML that I found least interesting when I read about it is actually the part I’ve found the best - the new XDocument API. Anyway, LINQ combined with a new USB headset that provides some actually quite good audio means that the important fundamental features have been implemented and work. At the moment it can:

  • Generate lessons based on vocabulary1 modules
  • Generate lessons containing past content with the correct repetition timing.
  • Actually play the lessons (but only on Windows2)

There are a few more things I want to add before I release any of it (like more audio for a start). But I thought I’d at least point out development is still happening :o) 1Instead of the Conversation > Phrase > Term style of Pimsleur I’ve decided to go for a more freeform approach to start with (inspired by me listening to Michel Thomas again). A vocabulary module just contains list of words and phrases that are processed in order. 2I still need a cross platform way to play audio. At the moment I use MCI which is part of winmm.dll which is obviously Windows only. Although Wine has apparently implemented it almost completely but I’m not sure how I’d go about making that help me.

So much for Gtk#…

Oliver Brown
— This upcoming video may not be available to view yet.

Well I’ve abandoned my plans to use Gtk# in the language app (which actually secretly has a name now).

The main reason for changing is simplicity. I had a look at the TreeView control in Gtk and decided it was too much work. Although the theory of good MVC separation is good, the user interface is such a small, simple part of my app it wasn’t worth it. The stuff I need from System.Windows.Forms should work in Mono (and .NET 1.1 and hopefully even the Compact Framework).

I still prefer the way Gtk handles layout of controls in general, but I console myself with the Windows form designer in Visual C# Express.

More Maemo Mono

Oliver Brown
— This upcoming video may not be available to view yet.

There is now a single click installation route for getting Mono on the Nokia 770 and Nokia N800. Basically it sets up installation repositories and installs the runtime. From that any apps you install will install only the components they need. Whether there are any really cool Mono apps for Maemo yet is something I don’t know. But I’m sure there will be :)

Mono brings everything together - MythTV, PS3, Nokia 770

Oliver Brown
— This upcoming video may not be available to view yet.

MythTV finally runs on a Playstation 3. Linux has been running on PS3s for a while doing all sorts of cool things. Well Takeshi Yaegashi has now got a USB TV tuner working for it making MythTV essentially complete.

So where does Mono come into this? Well Mono runs on a PS3 as well. Actually that’s not the link. In a cool coincidence, I first found out about MythTV on a PS3 after subscribing to a Mono RSS feed.

And the Nokia 770? Well the very next entry on said RSS feed was about Mono running on a Nokia 770 (and a Nokia N800 and Windows XP and Linux - all with one executable).

It’s a small world…

Cross platform games on the PS3 and the Xbox 360

Oliver Brown
— This upcoming video may not be available to view yet.

In case you didn’t know, the PS3 can run Linux. Not only that but it’s officially supported by Sony. You can download (for free) a utility to put a boot loader on to some media (most likely a hard-drive but memory cards, memory sticks and anything else the PS3 can read (and can hold 10Mb) are supported) and set it to boot “Other OS” (that’s what the menu says).

There are already videos on the Internet of it running Fedora. Zac Bowling already has one running Mono, a task simplified by the fact that the cell processor appears as a PPC. So where does the Xbox 360 come into this? Well Microsoft are releasing something called XNA, a modified/extended version of the the .NET 2.0 run-time with emphasis on Managed DirectX that is available for Windows and the Xbox 360. A version of XNA called Mono.Xna that is built on top of the Tao framework is in development. The end result is that in theory, games developed using XNA will run on Windows, Linux, Macs, PS3’s and Xbox 360’s. A few problems still exist. The processor that the PS3 uses is rather strictly an in-order processor so most stuff that isn’t written specifically for that will run slowly (although video playback will be pretty zippy) and so far there is no hardware 3D support for an “Other OS” so XNA (if it were available now) would run slowly.

ASP.NET sucks

Oliver Brown
— This upcoming video may not be available to view yet.

I recently bought a book about ASP.NET: Pro ASP.NET in C# by Apress, mainly because when I was looking for jobs there were lots of ASP.NET jobs advertised. And I have to say I have no idea why. Part of the problem may be that is book isn’t very good (there are bits of vague contradictions and a general obsessive (and inaccurate) preachiness about it) but I think there are major limitations to ASP.NET.

Firstly the inability to post to a different page. Who the hell decided that was good idea? I know it can be faked but that’s just silly. And you can only really have one form on a page. Well you can only have one “rich” form that ASP.NET can access in a clever and high level way.

I’m assuming people will disagree with me (if not, why is it so popular). If you do, please explain why ASP.NET is supposed to be so amazing because I don’t see it…

Updated - Clarifying my position on ASP.net