The mono throws me the following error - mono

When I try to run the mono with the "sudo mono server.exe" command it returns me in the following error.
log4net:ERROR Could not create Appender [conLogger] of type [log4net.Appender.ColoredConsoleAppender]. Reported error follows. System.EntryPointNotFoundException: GetConsoleOutputCP at (wrapper managed-to-native) log4net.Appender.ColoredConsoleAppender:GetConsoleOutputCP () at log4net.Appender.ColoredConsoleAppender.ActivateOptions () <0x412efc70 + 0x0005b> in :0 at log4net.Repository.Hierarchy.XmlHierarchyConfigurator.ParseAppender (System.Xml.XmlElement appenderElement) <0x412e7000 + 0x009f6> in :0 log4net:ERROR Appender named [conLogger] not found.

The source clearly indicates that this appender is Windows only,
https://github.com/apache/logging-log4net/blob/master/src/log4net/Appender/ColoredConsoleAppender.cs#L532
and there is no conditional compilation to avoid such exceptions on Linux or other platforms.
Thus, you might report to them as a bug (but I don't think they would fix it).
You might switch to the common ConsoleAppender, or develop your own Linux version, or search the internet to see if anyone already implemented one.

Related

Mono Framework Build Error - Mac OSX

When using the Mono framework 5.10.0.16 (regardless of IDE: VS for Mac, JetBrains Rider and MonoDevelop) the same error occurs and I cannot make sense of it:
Microsoft.VisualBasic.Core.targets(73, 5): [MSB3883] Unexpected exception:
Microsoft.VisualBasic.Core.targets(73, 5): [null] System.ComponentModel.Win32Exception (0x80004005): ApplicationName='vbnc.exe', CommandLine=' /noconfig #"/var/folders/sj/sblgn2q93b1084nm213419f80000gn/T/tmp54fb2d36c21545118516981a1817b134.rsp"', CurrentDirectory='', Native error= Cannot find the specified file
at System.Diagnostics.Process.StartWithCreateProcess (System.Diagnostics.ProcessStartInfo startInfo) [0x002dc] in <f8bb3922e51744d9ace1aa6aedc374ea>:0
at System.Diagnostics.Process.Start () [0x0003a] in <f8bb3922e51744d9ace1aa6aedc374ea>:0
at (wrapper remoting-invoke-with-check) System.Diagnostics.Process.Start()
at Microsoft.Build.Utilities.ToolTask.ExecuteTool (System.String pathToTool, System.String responseFileCommands, System.String commandLineCommands) [0x000c9] in <0027e94ddd2948b0b937f5e2d51fcfe1>:0
at Microsoft.CodeAnalysis.BuildTasks.ManagedCompiler.ExecuteTool (System.String pathToTool, System.String responseFileCommands, System.String commandLineCommands) [0x00066] in <896b154c97654cea80889fd96e18abdc>:0
I have tried installing different versions, the error persists, I'm not sure what to make of it but I notice a vnbc.exe
I am using MacOSX version 10.13.4
This issue in mono https://github.com/mono/mono/issues/7756. It's already fixed. We are waiting for new release.

.Net/Mono & Ubuntu versus log4net

I've been asked to write a small instrument-calibration app on Ubuntu Linux (14.04) and have been writing some small proof-of-concept apps (serial i/o, GUI, SQLite, etc.) to see if Mono is a good fit. Things were going well until I tested log4net, my favorite logging package. I cannot get the code to work. Here's a simple test app that works fine on a Windows box:
using System;
using log4net;
using log4net.Config;
public class L
{
public static void Main(string[] args)
{
Console.WriteLine("Version: " + Environment.Version);
XmlConfigurator.Configure(
new System.IO.FileInfo("console.logconfig.xml"));
Console.WriteLine("logging configured.");
ILog log = LogManager.GetLogger("root");
log.Info("This is an info message.");
log.Warn("This is a warning message.");
log.Error("This is an error message.");
}
}
Compiled with
gmcs -pkg:log4net,dotnet -main:L -out:L.exe L.cs
the code compiles, but generates a runtime error:
Version: 2.0.50727.1433
Missing method System.Reflection.Assembly::op_Equality(Assembly,Assembly) in assembly /usr/lib/mono/2.0/mscorlib.dll, referenced in assembly /usr/lib/mono/gac/log4net/1.2.10.0__a5715cc6d5c3540b/log4net.dll
Unhandled Exception:
System.MissingMethodException: Method not found: 'System.Reflection.Assembly.op_Equality'.
at log4net.LogManager.GetRepository (System.Reflection.Assembly repositoryAssembly) [0x00000] in <filename unknown>:0
at log4net.Config.XmlConfigurator.Configure (System.IO.FileInfo configFile) [0x00000] in <filename unknown>:0
at L.Main (System.String[] args) [0x00000] in <filename unknown>:0
This looks like a .Net version mismatch (maybe op_equality wasn't available in .Net 2.0?). When I try to force version 4 or 4.5 of the SDK:
gmcs -sdk:4.5 -pkg:log4n35,dotnet -main:L -out:L.exe L.cs
I get a compile error:
error CS0006: Metadata file `cscompmgd.dll' could not be found
This is on a brand-new Ubuntu 14.04 VM with Mono installed via:
sudo apt-get install mono-complete
sudo apt-get install liblog4net1.2-cil
sudo apt-get install liblog4net-cil-dev
Recommendations, please?
Unfortunately the version of log4net packaged for Ubuntu (1.2.10) is pretty old and known to have problems with .NET 4.0. 1.2.11 has been released in October 2011 and as of this writing 1.2.13 is the latest release.
You need to download the latest version from the Apache log4net site directly: http://logging.apache.org/log4net/download_log4net.cgi
You almost had it; Ubuntu 14.04:
gmcs -sdk:4.5 -r:/usr/lib/cli/log4net-1.2/log4net.dll App.cs

Does fastcgi-mono-serverX work with mono 3.0 & nginx 1.2.4

I have been trying for some days to get mono 3.0 & nginx 1.2.4 and fastcgi-mono-serverX in the XSP 2.10 package going on Centos 6.3 ...the XSP4 server works but I can't get the fastcgi method working.
I built and tested mono 3.0 from source, it works fine.
I followed the config at http://www.mono-project.com/FastCGI_Nginx to no avail and many other settings from the nginx site.
...does the current XSP 2.10 module work with mono 3.0?
...should I downgrade mono to 2.11.4 to work with XSP 2.10?
...ultimately I would like to run ASP.Net 4.0 Web Forms
Update: Here's some output from the mono-server.log:
Server stack trace:
at Mono.WebServer.FastCgi.ApplicationHost.ProcessRequest (Mono.WebServer.FastCgi.Responder responder) [0x00000] in <filename unknown>:0
at (wrapper remoting-invoke-with-check) Mono.WebServer.FastCgi.ApplicationHost:ProcessRequest (Mono.WebServer.FastCgi.Responder)
at (wrapper xdomain-dispatch) Mono.WebServer.FastCgi.ApplicationHost:ProcessRequest (object,byte[]&,byte[]&)
Exception rethrown at [0]:
---> System.InvalidCastException: Cannot cast from source type to destination type.
at System.Configuration.ConfigurationManager.get_AppSettings () [0x00000] in <filename unknown>:0
at Mono.WebServer.FastCgi.WorkerRequest..cctor () [0x00000] in <filename unknown>:0
--- End of inner exception stack trace ---
at (wrapper xdomain-invoke) Mono.WebServer.FastCgi.ApplicationHost:ProcessRequest (Mono.WebServer.FastCgi.Responder)
at (wrapper remoting-invoke-with-check) Mono.WebServer.FastCgi.ApplicationHost:ProcessRequest (Mono.WebServer.FastCgi.Responder)
at Mono.WebServer.FastCgi.Responder.Process () [0x00000] in <filename unknown>:0
[2012-11-05 12:35:14Z] Error Failed to process connection. Reason: The object was used after being disposed.
I was about to file a bug report with Xamarin... then I came across this submitted bug report from a year ago.
https://bugzilla.xamarin.com/show_bug.cgi?id=2876
tl;dr
You need to update the shell script (found with which mono-fastcgi-server4), and move mono-fastcgi-server4.exe from /usr/lib/mono/4.0 to /usr/lib/mono/4.5.
Longer Explanation
As mentioned, I'm using the mono-fastcgi-server4 package directly from the main canonical Ubuntu source which lists these file contents
/usr/bin/fastcgi-mono-server4
/usr/lib/mono/4.0/fastcgi-mono-server4.exe
/usr/lib/mono/gac/fastcgi-mono-server4/2.10.0.0__0738eb9f132ed756/fastcgi-mono-server4.exe
/usr/share/doc/mono-fastcgi-server4/AUTHORS
/usr/share/doc/mono-fastcgi-server4/NEWS.gz
/usr/share/doc/mono-fastcgi-server4/README
/usr/share/doc/mono-fastcgi-server4/README.Debian
/usr/share/doc/mono-fastcgi-server4/changelog.Debian.gz
/usr/share/doc/mono-fastcgi-server4/copyright
/usr/share/man/man1/fastcgi-mono-server4.1.gz
Based on the bug report solution, I was able to get this working. Essentially you edit the shell script used to launch fastcgi-mono-server4.exe by hand (which should be in /usr/bin), and move the .exe file by hand... or... you can use this little snippet of script that I incorporated into the deploy:setup of a Capistrano script. It uses sed to update the script.
fastcgi=$(which fastcgi-mono-server4) &&
sudo sed -i.bak -e 's/4\\.0/4.5/' $fastcgi &&
fastcgi_src='/usr/lib/mono/4.0/fastcgi-mono-server4.exe' &&
fastcgi_dest='/usr/lib/mono/4.5/fastcgi-mono-server4.exe' &&
if [ -f "$fastcgi_src" ]; then sudo mv $fastcgi_src $fastcgi_dest; fi;
This report also seems related
https://bugzilla.xamarin.com/show_bug.cgi?id=3582
If you use Mono 3.0, use a tag from xsp that is 3.x too. End of story.
Also, to avoid bugs like 3582, use Mono 3.0.3 or higher.

How to get file + line info debug info in Linux mono's assembly

I have an abnormal exception in a Linux mono assembly.
Unhandled Exception: System.ObjectDisposedException: The object was used after being disposed.
at System.Net.Sockets.Socket.ReceiveAsync (System.Net.Sockets.SocketAsyncEventArgs e) [0x00000] in <filename unknown>:0
at cloudBus.TCPConnection.Receive () [0x0003d] in /home/xyz/cloudBus/TCPServer.cs:26
...
I want to get line number and filename for ReceiveAsync.
I did compile in with -debug flag and execute with --debug.
I also get full mono from Git and recompile it but I can't get debug info.
What option to use to get the exception line info? I think this is mono make option but can't find it.
When found I'll try to fix this bug, only reproductible on Linux, and report correction.
You could build Mono from source, if you want to track this problem on git HEAD version.
On the other hand, Debian should have debug/development versions of Mono available as well, that will give you debugging info for your installed version.
I have found.
To build framework with debug info, in the file mono/mcs/build/config.make
add the line
MCS_FLAGS = -debug
On Debian the package mono-dbg provides debugging information for System.*. For your own code have a look at mono debug information with exceptions on debian? .

NAnt build issues with Mono

I am trying to build a Mono project using NAnt but I get the error listed below. I have tried altering the environment variable PKG_CONFIG_PATH to include the path leading to the file: mono.pc but that does not seem to work.
Failed to initialize the 'Mono 3.5 Profile' (mono-3.5) target framework.:
NAnt.Core.BuildException: Failed to initialize the 'Mono 3.5 Profile' (mono-3.5) target framework. ---> Unable to locate 'mono' module using pkg-config. Download the Mono development packages from http://www.mono-project.com/downloads/.:
NAnt.Core.BuildException: Unable to locate 'mono' module using pkg-config. Download the Mono development packages from http://www.mono-project.com/downloads/.
at NAnt.Core.Tasks.FailTask.ExecuteTask () [0x00000] in <filename unknown>:0
at NAnt.Core.Task.Execute () [0x00000] in <filename unknown>:0
--- End of inner exception stack trace ---
at NAnt.Core.FrameworkInfo.Init () [0x00000] in <filename unknown>:0
at NAnt.Core.FrameworkInfo.Validate () [0x00000] in <filename unknown>:0
at NAnt.Core.ProjectSettingsLoader.ConfigureRuntimeFramework () [0x00000] in <filename unknown>:0
I've recently had the same problem trying to install the TAO Framework on Mac OSX 10.6.5 under Mono 2.8.1 with Nant 0.90 (FYI). Here's how I was led to solve this (guided by this page):
Locate the nant script itself ('/usr/bin/nant' on OSX, try 'which nant')
Open the 'nant' script in an editor (you might need the right permissions).
On a new line and before the 'exec ...' line, add something like:
export
PKG_CONFIG_PATH=/path/to/Mono/Framework/Versions/VERSION/lib/pkgconfig
my Mac OSX version looks like:
export PKG_CONFIG_PATH=/opt/local/lib/pkgconfig:/Library/Frameworks/Mono.framework/Versions/Current/lib/pkgconfig/
(nb. my version actually has 2 pkgconfig paths, separated by a colon ':', '/usr/lib/pkgconfig' is also searched automatically, JFYI).
Also, you should add the exact same 'export' line to one of your .bashrc or .profile files (or the corresponding /etc/bashrc or /etc/profile files to set this globally).
Hope this helps.
Cheers
Rich
For me adding '/Library/Frameworks/Mono.framework/Versions/Current/bin' to the PATH has solved the issue on Mac OS X 10.7.3 with Mono 2.10.9 and NAnt 0.91.