A site devoted to discussing techniques that promote quality and ethical practices in software development.

Wednesday, May 24, 2017

The way to suppress Mono's "WARNING: The runtime version supported by this application is unavailable"

Many people would have encountered following dreaded Mono runtime warning,

WARNING: The runtime version supported by this application is unavailable.
Using default runtime: v4.0.30319


when one runs a console application in Mono.

This is caused by the fact that machine running this program does not have the version of the framework used to build the program. The only version of the framework available in this machine is v4.0.30319.

Sadly this warning is written to stdout and hence you can't redirect it to elsewhere if that were written to stderr.

The proper way to deal with this is to tell Mono that your application can also run in whatever version of the framework it has been installed in the machine. To do so you simply add a <startup><supportedRuntime> element into the application configuration file. If your application does not have one, create one containing the following lines:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
    <startup>
            <supportedRuntime version="v2.0.50727"/>
            <supportedRuntime version="v4.0.30319" />
            <supportedRuntime version="v4.0"/>
    </startup> 
</configuration>

This config file also says that if you have version 2 framework installed, it will use that, the one the application is built. The order of the supportedRuntime elements are important.

With that if the only framework version 4.0.30319 is installed, your application will not cause that warning message. Of course as a recommended practice you must also test your application in the framework that is NOT the one you use to build it to ensure no subtle difference in reaction creeps in.

No comments:

Blog Archive