Note that there are some explanatory texts on larger screens.

plurals
  1. POConfigurationSettings.AppSettings is empty, throws null exception
    primarykey
    data
    text
    <p>I have a class like this:</p> <pre><code>public class RxNormFolderMgr { // properties public string RxNormFolder { get { return ConfigurationSettings.AppSettings["rootFolder"].ToString(); } } } </code></pre> <p>When I try to use it like this:</p> <pre><code>public class TestRxNormFolderManager : ColumnFixture { public string RxNormFolder() { RxNormFolderMgr folderMgr = new RxNormFolderMgr(); return folderMgr.RxNormFolder; } } </code></pre> <p>I get an error: "System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.NullReferenceException: Object reference not set to an instance of an object." The AllKeys property for AppSettings is an array of zero length where I am expecting length of 1.</p> <p>My app.config file in the project looks like this:</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8" ?&gt; &lt;configuration&gt; &lt;appSettings&gt; &lt;add key="rootFolder" value ="C:\RxNorm" /&gt; &lt;!-- Root folder must not end with slash. --&gt; &lt;/appSettings&gt; &lt;/configuration&gt; </code></pre> <p>I know ConfigurationSettings.AppSettings is supposed to be obsolete and I should use ConfigurationManager.AppSettings, but I can't even get that to compile. I do have a reference in the project to System.configuration (c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\System.configuration.dll on my machine) and using statement at top of my code.</p> <p>I am using Fitnesse to test the code, and that's when I get the error. It's my understanding that I should also place a copy of the app.config file in the Bin>Debug folder of the test fixtures project which I have done. So, I don't know why I'm getting this error still.</p> <p>Please, help.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload