Silverlight Console Applications
Last week Harry Pierson wrote:
I wonder what the hosting model for the Silverlight CLR looks like? According to the "essential architecture", Silverlight includes the .NET Framework, the Core Presentation Framework and the Browser Host. But can you host somewhere other than the browser?
When I examined the Silverlight mscorlib assembly I noticed that Console.WriteLine and Console.ReadLine were still available. The functionality left in the Silverlight system assemblies has been pretty ruthlessly trimmed down. This lead me to believe that the Console class had been left there for a reason and there must be a way to run Silverlight console applications.
After some experimentation I have come up with agx.exe - a Silverlight console runner. The agx.exe name is a mixture of agclr.dll (one of the Silverlight assemblies) and clix.exe (the SSCLI/Rotor managed code runner).
Below is an example that shows some environment information and demonstrates Console.ReadLine working:
Hear is the IronPython interactive shell running as a console application inside Silverlight. I did have to tweak the source a bit to get this working. A few things like Assembly.Load(...) behave a little differently to their .NET 2.0 equivalents. A few IronPithon features appear not to be implemented when compiled for Silverlight.
The reason I'm experimenting with Silverlight console applications is so that unit tests can be executed inside the CoreCLR. I will then be able to add a 'Test With... Silverlight' option to TestDriven.NET. If you would like to try an early version of this functionality, feel free to drop me an email.