Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8262709
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T03:50:45+00:00 2026-06-08T03:50:45+00:00

I am working on a c# project which needs to work on Windows and

  • 0

I am working on a c# project which needs to work on Windows and Linux (Mono) which when it starts up it reads some settings from an xml config file. On windows this is working fine but on Linux it is going wrong. It throwing an exception saying that it has an invalid URI but this can’t be correct as it works fine on Windows.

I thought maybe it was due to the file getting corrupted in some way during the transfer so I removed the config file and retyped it manually but it is still coming up with the same error.

Below is the code that reads in the config file

public Dictionary<string, string> readConfig(string sectionName, bool soapService=false)
        {
            Dictionary<string, string> config = new Dictionary<string, string>();
            try
            {
                XmlDocument configXml = new XmlDocument();
                string configPath = "";
                if (soapService)
                {
                    string applicationPath = HttpContext.Current.Server.MapPath(null);
                    configPath = Path.Combine(applicationPath, "config.xml");
                }
                else
                {
                    string applicationPath = Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase);
                    configPath = Path.Combine(applicationPath, "config.xml");
                }
                configXml.Load(configPath);
                XmlNodeList options = configXml.SelectNodes(string.Format("/options/{0}", sectionName));
                XmlNodeList parameters = configXml.GetElementsByTagName("item");
                foreach (XmlNode option in options)
                {
                    foreach (XmlNode setting in option)
                    {
                        string key = setting.Attributes["key"].Value;
                        string value = setting.Attributes["value"].Value;

                        config.Add(key, value);
                    }
                }
            }
            catch (KeyNotFoundException ex)
            {
                Console.WriteLine("Config KeyNotFoundException: {0}", ex.Message);
            }
            catch (XmlException ex)
            {
                Console.WriteLine("Config XmlException: {0}", ex.Message);
            }
            catch (Exception ex)
            {
                Console.WriteLine("Config Exception: {0}", ex.Message);
            }
            return config;
        }

The full exception is Config Exception: Invalid URI: The Authority/Host could not be parsed

Below is the config.xml

<?xml version="1.0" encoding="utf-8" ?>
<options>
  <database>
    <item key="server" value="localhost" />
    <item key="database" value="emailserver" />
    <item key="username" value="myusername" />
    <item key="password" value="mypassword" />
    <item key="port" value="3306" />
    <item key="logFile" value="email_server.txt" />
  </database>
  <EmailServer>
    <item key="ip_address" value="127.0.0.1" />
    <item key="port" value="12345" />
  </EmailServer>
  <SmtpServer>
    <item key="ip_address" value="127.0.0.1" />
    <item key="port" value="25" />
  </SmtpServer>
  <SendMailSettings>
    <item key="smtp_server" value="smtp.gmail.com" />
    <item key="smtp_port" value="587" />
    <item key="smtp_useSSL" value="true" />
    <item key="smtp_username" value="myusername" />
    <item key="smtp_password" value="mypassword" />
    <item key="smtp_useAuthentication" value="true" />
  </SendMailSettings>
</options>

I don’t understand why it is displaying this error.

Thanks for any help you can provide.

UPDATE
Below is the stack trace as requested

StackTrace: at System.Uri.Parse (UriKind kind, System.String
uriString) [0x00000] in :0 at System.Uri.ParseUri
(UriKind kind) [0x00000] in :0 at System.Uri..ctor
(System.String uriString, Boolean dontEscape) [0x00000] in :0 at System.Uri..ctor (System.String uriString) [0x00000]
in :0 at System.Xml.XmlResolver.ResolveUri
(System.Uri baseUri, System.String relativeUri) [0x00000] in :0 at System.Xml.XmlUrlResolver.ResolveUri (System.Uri
baseUri, System.String relativeUri) [0x00000] in :0
at Mono.Xml2.XmlTextReader..ctor (System.String url,
System.Xml.XmlNameTable nt) [0x00000] in :0 at
System.Xml.XmlTextReader..ctor (System.String url,
System.Xml.XmlNameTable nt) [0x00000] in :0 at
System.Xml.XmlDocument.Load (System.String filename) [0x00000] in
:0 at BoardiesITSolutions.Config.readConfig
(System.String sectionName, Boolean soapService) [0x00000] in
:0

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T03:50:48+00:00Added an answer on June 8, 2026 at 3:50 am

    I’ve found out the problem, I don’t understand why this is the problem I’m guessing it must be a bug in Mono as it works fine in Windows.

    Even though the following code works fine in Windows for some reason in Mono it throws that exception even though it does get the correct path. If I remove that code and just change the configPath to be "config.xml" then it works fine.

    string applicationPath = Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase);
    configPath = Path.Combine(applicationPath, "config.xml");
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm working in a project which needs to clean up some third party XSD
I'm working on a project which needs to use youtube api. The html and
I'm working on a project which needs to design a web crawler in Java
I'm working to a Visual C++ 2008 project which needs two libraries (A and
A project I'm working on needs avro, which requires python-snappy, which requires snappy. I
I have a VS2010 project which is a windows application that acquires data from
I'm working on a simulation project using c++ on both windows and linux. There
I am working on a project in which I need to download and parse
I am working on a project in which I need to generate 8 random
I'm working on a project in which I need to process a huge amount

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.