Cross Linking

From RemObjects Software

Jump to: navigation, search

This is a Oxygene Language Feature topic
Feel free to add your notes to this topic below.



Native Linking against different CLR Platforms

Assemblies built for the .NET platform are usually portable between different implementations - if written well, a compiled assembly can be moved from .NET to - say - Mono or the Compact Framework and will usually run out of the box.

Unfortunately, little incompatibilities between the different CLR implementations make this task more difficult. The CF only implements a small subset of the full CLR, for example, and the Mono framework also has subtle differences from the standard Microsoft .NET Framework. Detecting usage of these can become tricky when you build your application against .NET and then simply copy it over - problems do not show until runtime.

What's more, both the CF and Mono implement new namespaces and classes that don't exist on the Microsoft .NET framework. When linking against the standard framework, you simply will not be able to use those at all.

Enter Cross-Linking

Oxygene introduces the concept of Cross-Linking™, where you can use the compiler on one framework implementation (usually the .NET Framework, running inside Visual Studio), and still link against alternative CLR assemblies.

Linking against the Compact Framework

Linking your application against the CF is almost too easy. When installing the Pocket PC or Smart Phone SDK (or any SDK that includes/supports the CF), copies of the CF versions of all the standard .NET assemblies get installed to your development machine (by default, the location for these is "C:\Program Files\Microsoft Visual Studio .NET 2003\CompactFrameworkSDK\v1.0.5000\Windows CE"). To link your project against these versions (rather then the default .NET assemblies), simply open your project properties and adjust the Framework Folder option to match this path:

(TODO: new screenshot for VS2005/2008)

Image:CF Properties.PNG

The next time you build your application, it will automatically be linked against the CF assemblies. If you happen to use classes or method overloads not implemented for the CF, you will get the appropriate compile-time error messages and if you use CF specific classes such as the IrDA Socket classes, your code will compile against them just fine.

Linking against Mono

The same concept applies to linking against Mono. If you installed the Win32 distribution of Mono 1.9.1, by default the Mono assemblies will be available in "C:\Program Files\Mono-1.9.1\lib\mono" and its subfolders. Again, by providing the proper Framework Folder setting, you can link directly against these assemblies.

Oxygene provides the {MONO} and {MONOFRAMEWORK} placeholders that can be used in the FramedworkFolder setting to refer to the default mono framework. {MONO} refers to the base folder of all Mono assemblies (for example the above-mentioned \Mono-1.9.1\lib\mono, while {MONOFRAMEWORK} refers to the folder 2.0 subfolder, which contains mscorlib and the System dlls.

{MONOFRAMEWORK} is the best option to replace the .NET framework folder, when compiling against both targets

{MONO} is well-suited when you need to access assemblies stored in paraell to the 2.0 folder, such as Gtk# or Cocoa#. In this case, the core framework dlls need to be referenced as $(Framework)\2.0\mscorib.dll, etc.

Cross linking works both ways; you could develop an application under Linux/Mono, copy over the windows/MS/.NET dlls to some folder and then use a separate config to test building against these MS dlls.


See Also


Product: RemObjects Oxygene (formerly known as Chrome)
Current version: 3.0 Previous Versions: 'Joyride' (2.0), 'Floorshow' (1.5), 'Adrenochrome' (1.0)

GlossaryKeywordsLanguage FeaturesPlatform FeaturesSamplesArticlesHow ToIssues

Personal tools