A MoMA Background

By Jeff Cogswell  |  Posted 2009-04-07 Email Print this article Print


The MoMA tool is actually pretty small; there isn't much to it. You simply specify a list of .NET binaries, and the tool will analyze them to look for calls into classes and functions that aren't implemented by Mono, as well as calls directly into the operating system.

This might surprise you, as it did me. The tool analyzes the binaries. At first this might seem a little odd that it's doing some reverse engineering. But, in fact, the so-called binaries that run under the .NET CLI run-time are actually P-code stored in resources of executable files; these files are in turn known as assemblies.

Microsoft includes tools with its SDKs (software development kits) that make reverse-engineering your binaries a snap. The ILDASM (Intermediate Language Disassembler) tool easily opens up any CLI binary file and looks at the metadata describing the file, as well as at the actual assembly code.

However, this "assembly" code isn't Intel assembly; rather, it's the P-code, which is an assembled form of what is called IL (Intermediate Language), and this language is a much higher-level language than plain old assembly. This means it's easy for the MoMA tool to open up your binary and do a full inspection of it-noting what libraries it calls and so on-without touching your source code.

Of course, if the tool finds problems, you'll have to make the changes yourself, which means going back to your original source code and recompiling it. But if you think about it, thanks to the immediate code compiled to P-code, which follows a strict standard, it's a lot easier for a tool such as MoMA to analyze binaries than to analyze source code that could be quite messy.

But that's not the end of the story. The run-time that ships with Mono can process binaries that were compiled under .NET. If the tool detects no problems, then you don't need to recompile it under Mono (although you can if you want to). Instead, you can launch the Mono run-time, passing the .NET program's name as a command-line parameter, and your .NET program will run (hopefully) as is under Mono-even on Linux.

Don't believe me? Try it. Create a simple Form application in Visual Studio and compile it. Then boot to Linux. From the Linux command prompt, type mono, and pass the full path and file name to the form1.exe file, or whatever you called it. I kid you not-it will run under Linux, provided you installed all the Mono libraries, including the Forms library. Note, however, that by default you might not have the Forms library. If not, Google the error message you see and you'll find instructions on how to install it. Then watch your program run under Linux.

Jeff Cogswell is the author of Designing Highly Useable Software (http://www.amazon.com/dp/0782143016) among other books and is the owner/operator of CogsMedia Training and Consulting.Currently Jeff is a senior editor with Ziff Davis Enterprise. Prior to joining Ziff, he spent about 15 years as a software engineer, working on Windows and Unix systems, mastering C++, PHP, and ASP.NET development. He has written over a dozen books.

Submit a Comment

Loading Comments...
Manage your Newsletters: Login   Register My Newsletters

Thanks for your registration, follow us on our social networks to keep up-to-date
Rocket Fuel