Answer the question
In order to leave comments, you need to log in
Why doesn't the console application work in Mono?
We are trying to run a simple console application that uses Log4Net (12.10) for its work.
Used AltLinux 6.0.1 and Mono 2.6.7, .Net Framework 3.5.
Here is the result of a normal "exhaust" on Windows:
F:\Work\Projects\Mono\Debug>Tool.exe
List of possible arguments:
Tool.exe [-CheckDB] [-CheckFreeSpace] [-BackupDB] [-ShrinkDB]
-CheckDB Check DB
-CheckFreeSpace Check if there is free space on the hard disk
-BackupDB Backup database
-BackupAttachments Backup attached files
-RemoveOldBackups Remove old backups
-RestoreLogConfig Restore logging configuration file
-ShrinkDB Clean up unused data
# sudo mono Tool.exe
Unhandled Exception: System.TypeInitializationException: An exception was thrown by the type initializer for Tool ---> Common.Logging.ConfigurationException: Unable to create type 'Common.Logging.Log4Net .Log4NetLoggerFactoryAdapter, Common.Logging.Log4net' ---> System.TypeLoadException: Could not load type 'Common.Logging.Log4Net.Log4NetLoggerFactoryAdapter, Common.Logging.Log4net'.
at (wrapper managed-to-native) System.Type:internal_from_name (string,bool,bool)
at System.Type.GetType (System.String typeName, Boolean throwOnError, Boolean ignoreCase) [0x00000] in :0
at Common.Logging. ConfigurationSectionHandler.ReadConfiguration (System.Xml.XmlNode section) [0x00000] in :0
--- End of inner exception stack trace ---
at Common.Logging.ConfigurationSectionHandler.ReadConfiguration (System.Xml.XmlNode section) [0x00000] in :0
at Common.Logging.ConfigurationSectionHandler.Create (Common.Logging.Configuration.LogSetting parent, System.Object configContext, System.Xml.XmlNode section) [0x00000] in :0
at Common.Logging.ConfigurationSectionHandler.System.Configuration.IConfigurationSectionHandler.Create (System.Object parent, System.Object configContext, System.Xml.XmlNode section) [0x00000] in :0
at System.Configuration .ConfigurationSection.GetRuntimeObject () [0x00000] in :0
at System.Configuration.ClientConfigurationSystem.System.Configuration.Internal.IInternalConfigSystem.GetSection (System.String configKey) [0x00000] in :0
at System.Configuration.ConfigurationManager.GetSection (System.String sectionName) [0x00000] in :0
at Common.Logging.Configuration.DefaultConfigurationReader.GetSection (System.String sectionName) [0x00000] in :0
at Common.Logging.LogManager+<> c__DisplayClass3.b__0 () [0x00000] in :0
at Common.Logging.Configuration.ArgUtils+<>c__DisplayClass13.b__12 () [0x00000] in :0
at Common.Logging.Configuration.ArgUtils.Guard[Int32] (Common.Logging. Configuration.Function`1 function, System.String messageFormat, System.Object[] args) [0x00000] in :0
--- End of inner exception stack trace ---
<?xml version="1.0" encoding="utf-8" ?>
...
[[email protected] Tool]# sudo mono --debug Tool.exe
[[email protected] Tool]#
# sudo mono --debug Tool.exe -CheckFreeSpace
??????: An exception was thrown by the type initializer for Tool.Factory
if (!(ConfigurationManager.GetSection("Config") is Config))
{
throw new ConfigurationErrorsException(Resource.ErrorConfiguration + Resource.ErrorConfigSectionIsWrongOrEmpty);
}
Config = (Config)ConfigurationManager.GetSection("Config");
Answer the question
In order to leave comments, you need to log in
Problem solved by tweaking Mono source code and utility.
The program started after fixing two errors (on Mono 4.3.0):
1. one of the libraries was not connected correctly;
2. there was a typo in the config;
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question