ubuntu用mono4跑exe,读取app.config总是异常


ubuntu用mono4跑exe,报读取app.config异常,是怎么回事。用mono3的时候没问题.
异常信息如下:
System.TypeInitializationException: An exception was thrown by the type initializer for Test.Program ---> System.Configuration.ConfigurationErrorsException: Error Initializing the configuration system. ---> System.Configuration.ConfigurationErrorsException: Unrecognized configuration section (/home/lijing/Desktop/iQQ.Net/Test.exe.config line 3)

程序就是一个简单的helloworld


 namespace Test
{
    class Program
    {
        protected static readonly NameValueCollection AppSettings = ConfigurationManager.AppSettings;
        private static readonly string rootDir = AppSettings["RootDirPath"] ?? "";

        static void Main(string[] args)
        {
            Console.WriteLine("hello world");
            Console.WriteLine(rootDir);
            Console.ReadKey();
        }
    }
}


 <?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <appSettings>
    <add key="RootDirPath" value="xxxxxxxxxxxxxxxxxxxx"/>
    <add key="LibPath" value="Lib\win64\"/>
    <add key="DataDirPath" value=""/>
  </appSettings>
</configuration>

mono版本如下:
Mono JIT compiler version 4.0.2 (Stable 4.0.2.5/c99aa0c Wed Jun 24 10:04:37 UTC 2015)
Copyright (C) 2002-2014 Novell, Inc, Xamarin Inc and Contributors. www.mono-project.com
TLS: __thread
SIGSEGV: altstack
Notifications: epoll
Architecture: amd64
Disabled: none
Misc: softdebug
LLVM: supported, not enabled.
GC: sgen

mono c# .net Ubuntu

xfznyb 9 years, 8 months ago

Your Answer