c# - ubuntu用mono4跑exe,读取app.config总是异常
高洛峰
高洛峰 2017-04-22 08:55:35
0
0
524

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

高洛峰
高洛峰

拥有18年软件开发和IT教学经验。曾任多家上市公司技术总监、架构师、项目经理、高级软件工程师等职务。 网络人气名人讲师,...

全部回复(0)
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板