There is a library which contains the following method.

```
public class Class1 
{
    public void X() 
    {
        //....
        var user = ConfigurationManager.AppSettings["UserName"];
        Console.WriteLine(user); // Nothing printed.

```

And it's invoked by Powershell

```
$dllFolder = "C:\...\bin\Debug"

Add-Type -Path "$dllFolder\Class1.dll"
$test = new-object Class1
$test.X()

```

How to assign `ConfigurationManager.AppSettings["UserName"]` in the dll?

**Edit:**

I added `app.config` to the library project and the file `Class1.dll.config` contains the following lines.

```
<appSettings>
  <add key="UserName" value="...." />
</appSettings>

```

However, it still doesn't print the value when running in powershell.