Standard: Can't use System.Configuration.Configuration manager in a .NET Standard library on .NET Core

Created on 12 Jul 2017  路  11Comments  路  Source: dotnet/standard

From: https://twitter.com/adamralph/status/88485320147171328

@adamralph

In my preview2 build I have the System.Configuration type forwarder in: C:\Program Files\dotnet\shared\Microsoft.NETCore.App\2.0.0-preview2-25407-01

I have also used this package multiple times. I'm wondering what is different for @adamralph

Most helpful comment

@robertmuehsig did you add a reference to the System.Configuration.ConfigurationManager nuget package? It doesn't look like it from the screenshot you posted.

All 11 comments

@weshaggard any thoughts?

@adamralph if you can give some further information I can help you figure out what is going on.

@adamralph any further information on this issue?

@terrajobst, you mentioned yesterday that you had hit a packaging bug in ConfigurationManager where the wrong asset was being selected. I don't know if its related but we should try to get to the bottom of this.

sharing the project.assets.json would be supper helpful

The link is 404-in now, so I'm not sure what the issue was.

you mentioned yesterday that you had hit a packaging bug in ConfigurationManager where the wrong asset was being selected. I don't know if its related but we should try to get to the bottom of this.

Did I? I think I might have mentioned Azure Storage where there are issues where win8 assets are preferred over netstandard1.3 assets in UWP. That's by design and an issue with the package authoring.

I've just tried to use System.Configuration.ConfigurationManager from a .NET Standard library that in turn is referenced from a .NET Core console app and everything was working fine (and by everything I mean reading app settings from the app.config).

I'm not sure what the issue was either (and I've no idea why the tweet link is a 404).

I also just tried installing System.Configuration.ConfigurationManager in a .NET Standard project, which is invoked from a .NET Core console app, and it all worked fine.

I believe this issue can be withdrawn.

Awesome! Glad its working now how I had hoped it was :)

Somehow I ended up with the same issue:
image


project.assets.json

{
  "version": 3,
  "targets": {
    ".NETStandard,Version=v2.0": {
      "Microsoft.NETCore.Platforms/1.1.0": {
        "type": "package",
        "compile": {
          "lib/netstandard1.0/_._": {}
        },
        "runtime": {
          "lib/netstandard1.0/_._": {}
        }
      },
      "NETStandard.Library/2.0.0": {
        "type": "package",
        "dependencies": {
          "Microsoft.NETCore.Platforms": "1.1.0"
        },
        "compile": {
          "lib/netstandard1.0/_._": {}
        },
        "runtime": {
          "lib/netstandard1.0/_._": {}
        },
        "build": {
          "build/netstandard2.0/NETStandard.Library.targets": {}
        }
      }
    }
  },
  "libraries": {
    "Microsoft.NETCore.Platforms/1.1.0": {
      "sha512": "kz0PEW2lhqygehI/d6XsPCQzD7ff7gUJaVGPVETX611eadGsA3A877GdSlU0LRVMCTH/+P3o2iDTak+S08V2+A==",
      "type": "package",
      "path": "microsoft.netcore.platforms/1.1.0",
      "files": [
        "ThirdPartyNotices.txt",
        "dotnet_library_license.txt",
        "lib/netstandard1.0/_._",
        "microsoft.netcore.platforms.1.1.0.nupkg.sha512",
        "microsoft.netcore.platforms.nuspec",
        "runtime.json"
      ]
    },
    "NETStandard.Library/2.0.0": {
      "sha512": "7jnbRU+L08FXKMxqUflxEXtVymWvNOrS8yHgu9s6EM8Anr6T/wIX4nZ08j/u3Asz+tCufp3YVwFSEvFTPYmBPA==",
      "type": "package",
      "path": "netstandard.library/2.0.0",
      "files": [
        "LICENSE.TXT",
        "THIRD-PARTY-NOTICES.TXT",
        "build/NETStandard.Library.targets",
        "build/netstandard2.0/NETStandard.Library.targets",
        "build/netstandard2.0/ref/Microsoft.Win32.Primitives.dll",
        "build/netstandard2.0/ref/System.AppContext.dll",
        "build/netstandard2.0/ref/System.Collections.Concurrent.dll",
        "build/netstandard2.0/ref/System.Collections.NonGeneric.dll",
        "build/netstandard2.0/ref/System.Collections.Specialized.dll",
        "build/netstandard2.0/ref/System.Collections.dll",
        "build/netstandard2.0/ref/System.ComponentModel.Composition.dll",
        "build/netstandard2.0/ref/System.ComponentModel.EventBasedAsync.dll",
        "build/netstandard2.0/ref/System.ComponentModel.Primitives.dll",
        "build/netstandard2.0/ref/System.ComponentModel.TypeConverter.dll",
        "build/netstandard2.0/ref/System.ComponentModel.dll",
        "build/netstandard2.0/ref/System.Console.dll",
        "build/netstandard2.0/ref/System.Core.dll",
        "build/netstandard2.0/ref/System.Data.Common.dll",
        "build/netstandard2.0/ref/System.Data.dll",
        "build/netstandard2.0/ref/System.Diagnostics.Contracts.dll",
        "build/netstandard2.0/ref/System.Diagnostics.Debug.dll",
        "build/netstandard2.0/ref/System.Diagnostics.FileVersionInfo.dll",
        "build/netstandard2.0/ref/System.Diagnostics.Process.dll",
        "build/netstandard2.0/ref/System.Diagnostics.StackTrace.dll",
        "build/netstandard2.0/ref/System.Diagnostics.TextWriterTraceListener.dll",
        "build/netstandard2.0/ref/System.Diagnostics.Tools.dll",
        "build/netstandard2.0/ref/System.Diagnostics.TraceSource.dll",
        "build/netstandard2.0/ref/System.Diagnostics.Tracing.dll",
        "build/netstandard2.0/ref/System.Drawing.Primitives.dll",
        "build/netstandard2.0/ref/System.Drawing.dll",
        "build/netstandard2.0/ref/System.Dynamic.Runtime.dll",
        "build/netstandard2.0/ref/System.Globalization.Calendars.dll",
        "build/netstandard2.0/ref/System.Globalization.Extensions.dll",
        "build/netstandard2.0/ref/System.Globalization.dll",
        "build/netstandard2.0/ref/System.IO.Compression.FileSystem.dll",
        "build/netstandard2.0/ref/System.IO.Compression.ZipFile.dll",
        "build/netstandard2.0/ref/System.IO.Compression.dll",
        "build/netstandard2.0/ref/System.IO.FileSystem.DriveInfo.dll",
        "build/netstandard2.0/ref/System.IO.FileSystem.Primitives.dll",
        "build/netstandard2.0/ref/System.IO.FileSystem.Watcher.dll",
        "build/netstandard2.0/ref/System.IO.FileSystem.dll",
        "build/netstandard2.0/ref/System.IO.IsolatedStorage.dll",
        "build/netstandard2.0/ref/System.IO.MemoryMappedFiles.dll",
        "build/netstandard2.0/ref/System.IO.Pipes.dll",
        "build/netstandard2.0/ref/System.IO.UnmanagedMemoryStream.dll",
        "build/netstandard2.0/ref/System.IO.dll",
        "build/netstandard2.0/ref/System.Linq.Expressions.dll",
        "build/netstandard2.0/ref/System.Linq.Parallel.dll",
        "build/netstandard2.0/ref/System.Linq.Queryable.dll",
        "build/netstandard2.0/ref/System.Linq.dll",
        "build/netstandard2.0/ref/System.Net.Http.dll",
        "build/netstandard2.0/ref/System.Net.NameResolution.dll",
        "build/netstandard2.0/ref/System.Net.NetworkInformation.dll",
        "build/netstandard2.0/ref/System.Net.Ping.dll",
        "build/netstandard2.0/ref/System.Net.Primitives.dll",
        "build/netstandard2.0/ref/System.Net.Requests.dll",
        "build/netstandard2.0/ref/System.Net.Security.dll",
        "build/netstandard2.0/ref/System.Net.Sockets.dll",
        "build/netstandard2.0/ref/System.Net.WebHeaderCollection.dll",
        "build/netstandard2.0/ref/System.Net.WebSockets.Client.dll",
        "build/netstandard2.0/ref/System.Net.WebSockets.dll",
        "build/netstandard2.0/ref/System.Net.dll",
        "build/netstandard2.0/ref/System.Numerics.dll",
        "build/netstandard2.0/ref/System.ObjectModel.dll",
        "build/netstandard2.0/ref/System.Reflection.Extensions.dll",
        "build/netstandard2.0/ref/System.Reflection.Primitives.dll",
        "build/netstandard2.0/ref/System.Reflection.dll",
        "build/netstandard2.0/ref/System.Resources.Reader.dll",
        "build/netstandard2.0/ref/System.Resources.ResourceManager.dll",
        "build/netstandard2.0/ref/System.Resources.Writer.dll",
        "build/netstandard2.0/ref/System.Runtime.CompilerServices.VisualC.dll",
        "build/netstandard2.0/ref/System.Runtime.Extensions.dll",
        "build/netstandard2.0/ref/System.Runtime.Handles.dll",
        "build/netstandard2.0/ref/System.Runtime.InteropServices.RuntimeInformation.dll",
        "build/netstandard2.0/ref/System.Runtime.InteropServices.dll",
        "build/netstandard2.0/ref/System.Runtime.Numerics.dll",
        "build/netstandard2.0/ref/System.Runtime.Serialization.Formatters.dll",
        "build/netstandard2.0/ref/System.Runtime.Serialization.Json.dll",
        "build/netstandard2.0/ref/System.Runtime.Serialization.Primitives.dll",
        "build/netstandard2.0/ref/System.Runtime.Serialization.Xml.dll",
        "build/netstandard2.0/ref/System.Runtime.Serialization.dll",
        "build/netstandard2.0/ref/System.Runtime.dll",
        "build/netstandard2.0/ref/System.Security.Claims.dll",
        "build/netstandard2.0/ref/System.Security.Cryptography.Algorithms.dll",
        "build/netstandard2.0/ref/System.Security.Cryptography.Csp.dll",
        "build/netstandard2.0/ref/System.Security.Cryptography.Encoding.dll",
        "build/netstandard2.0/ref/System.Security.Cryptography.Primitives.dll",
        "build/netstandard2.0/ref/System.Security.Cryptography.X509Certificates.dll",
        "build/netstandard2.0/ref/System.Security.Principal.dll",
        "build/netstandard2.0/ref/System.Security.SecureString.dll",
        "build/netstandard2.0/ref/System.ServiceModel.Web.dll",
        "build/netstandard2.0/ref/System.Text.Encoding.Extensions.dll",
        "build/netstandard2.0/ref/System.Text.Encoding.dll",
        "build/netstandard2.0/ref/System.Text.RegularExpressions.dll",
        "build/netstandard2.0/ref/System.Threading.Overlapped.dll",
        "build/netstandard2.0/ref/System.Threading.Tasks.Parallel.dll",
        "build/netstandard2.0/ref/System.Threading.Tasks.dll",
        "build/netstandard2.0/ref/System.Threading.Thread.dll",
        "build/netstandard2.0/ref/System.Threading.ThreadPool.dll",
        "build/netstandard2.0/ref/System.Threading.Timer.dll",
        "build/netstandard2.0/ref/System.Threading.dll",
        "build/netstandard2.0/ref/System.Transactions.dll",
        "build/netstandard2.0/ref/System.ValueTuple.dll",
        "build/netstandard2.0/ref/System.Web.dll",
        "build/netstandard2.0/ref/System.Windows.dll",
        "build/netstandard2.0/ref/System.Xml.Linq.dll",
        "build/netstandard2.0/ref/System.Xml.ReaderWriter.dll",
        "build/netstandard2.0/ref/System.Xml.Serialization.dll",
        "build/netstandard2.0/ref/System.Xml.XDocument.dll",
        "build/netstandard2.0/ref/System.Xml.XPath.XDocument.dll",
        "build/netstandard2.0/ref/System.Xml.XPath.dll",
        "build/netstandard2.0/ref/System.Xml.XmlDocument.dll",
        "build/netstandard2.0/ref/System.Xml.XmlSerializer.dll",
        "build/netstandard2.0/ref/System.Xml.dll",
        "build/netstandard2.0/ref/System.dll",
        "build/netstandard2.0/ref/mscorlib.dll",
        "build/netstandard2.0/ref/netstandard.dll",
        "build/netstandard2.0/ref/netstandard.xml",
        "lib/netstandard1.0/_._",
        "netstandard.library.2.0.0.nupkg.sha512",
        "netstandard.library.nuspec"
      ]
    }
  },
  "projectFileDependencyGroups": {
    ".NETStandard,Version=v2.0": [
      "NETStandard.Library >= 2.0.0"
    ]
  },
  "packageFolders": {
    "C:\\Users\\muehsig\\.nuget\\packages\\": {},
    "C:\\Program Files (x86)\\Microsoft SDKs\\NuGetPackagesFallback\\": {},
    "C:\\Program Files\\dotnet\\sdk\\NuGetFallbackFolder": {}
  },
  "project": {
    "version": "1.0.0",
    "restoreSettings": {
      "hideWarningsAndErrors": true
    },
    "restore": {
      "projectUniqueName": "D:\\TFS\\ONEOFFIXX\\Dev\\LetsTryAspNetCore\\OneOffixx.Web.Shared.NetStandard\\OneOffixx.Web.Shared.NetStandard.csproj",
      "projectName": "OneOffixx.Web.Shared.NetStandard",
      "projectPath": "D:\\TFS\\ONEOFFIXX\\Dev\\LetsTryAspNetCore\\OneOffixx.Web.Shared.NetStandard\\OneOffixx.Web.Shared.NetStandard.csproj",
      "packagesPath": "C:\\Users\\muehsig\\.nuget\\packages\\",
      "outputPath": "D:\\TFS\\ONEOFFIXX\\Dev\\LetsTryAspNetCore\\OneOffixx.Web.Shared.NetStandard\\obj\\",
      "projectStyle": "PackageReference",
      "fallbackFolders": [
        "C:\\Program Files (x86)\\Microsoft SDKs\\NuGetPackagesFallback\\",
        "C:\\Program Files\\dotnet\\sdk\\NuGetFallbackFolder"
      ],
      "configFilePaths": [
        "D:\\TFS\\ONEOFFIXX\\Dev\\LetsTryAspNetCore\\.nuget\\NuGet.Config",
        "D:\\TFS\\ONEOFFIXX\\Dev\\LetsTryAspNetCore\\NuGet.Config",
        "C:\\Users\\muehsig\\AppData\\Roaming\\NuGet\\NuGet.Config",
        "C:\\Program Files (x86)\\NuGet\\Config\\Microsoft.VisualStudio.Offline.config",
        "C:\\Program Files (x86)\\NuGet\\Config\\Microsoft.VisualStudio.Offline.Fallback.config"
      ],
      "originalTargetFrameworks": [
        "netstandard2.0"
      ],
      "sources": {
        "C:\\Program Files (x86)\\Microsoft SDKs\\NuGetPackages\\": {},
        "https://api.nuget.org/v3/index.json": {}
      },
      "frameworks": {
        "netstandard2.0": {
          "projectReferences": {}
        }
      },
      "warningProperties": {
        "warnAsError": [
          "NU1605"
        ]
      }
    },
    "frameworks": {
      "netstandard2.0": {
        "dependencies": {
          "NETStandard.Library": {
            "suppressParent": "All",
            "target": "Package",
            "version": "[2.0.0, )",
            "autoReferenced": true
          }
        },
        "imports": [
          "net461"
        ],
        "assetTargetFallback": true,
        "warn": true
      }
    }
  }
}

"imports: net461" - it this correct? Shouldn't it be net471?

I installed the most recent .NET 4.7.1 dev pack.

@robertmuehsig did you add a reference to the System.Configuration.ConfigurationManager nuget package? It doesn't look like it from the screenshot you posted.

Uh - this would make sense I guess.

Was this page helpful?
0 / 5 - 0 ratings