VASmalltalk – Embedding Mono Runtime system ….

There are several IT-system infrastructures out there, where interaction would be nice to have within Smalltalk. The most important is of course the old and easy one: the plain C-programs.

Other infrastructures are Java (interaction possible with JNIPort – not available under VA) and .NET/Mono. For Visualworks is a package available to interact with .NET.

Mono offers interfaces for embedding Mono in a plain C application. This is possible under all platforms, where Mono is available. I tried this under Windows and under Linux and early experiments showed, that this is possible.

| domain assembly wrapper domainName pathName argV |

"A Console based application we developed using Mono and MonoDevelop"
pathName := 'C:\\Users\\mf\\Documents\\Projects\\Testme\\Testme\\bin\\Debug\\Testme.exe'.
domainName := 'System'.
wrapper := MSKMonoInterface startWithSync.

"Set the environment under Windows - where is Mono"
wrapper
  setLibPathDir: 'C:\\Program Files\\Mono-2.10.8\\lib'
  pathEtc: 'C:\\Program Files\\Mono-2.10.8\\etc'.
"Load default configuration"
wrapper configParse: nil.

"Initializes the JIT system"
(domain := wrapper jitInit: domainName) isNull ifTrue: [^'Error: No Domain creation possible'].

"Open the assembly, where we want to execute the main() method"
(assembly := wrapper openAssemblyPath: pathName domain: domain) isNull ifTrue: [^'Error: No Assembly found!'].

"Execution"
argV := OSObjectPointer calloc: 1 itemType: OSStringZ.
argV at: 0 put: pathName copyToOSMemory.
wrapper jitExecMainIn: assembly domain: domain argc: 1 argv: argV.

"That's it"
wrapper jitCleanup: domain
This entry was posted in .NET, Smalltalk and tagged , . Bookmark the permalink.

One Response to VASmalltalk – Embedding Mono Runtime system ….

  1. Pingback: Sending emails from VA Smalltalk | Joachims Small World

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s