question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

System.InvalidOperationException: Could not find 'UserSecretsIdAttribute' on assembly 'System.Private.CoreLib'

See original GitHub issue

Describe the bug

This bug seems to me to be very similar to aspnet/AspNetCore#7649. I’m using F# with Giraffe to fiddle around with a simple api project, but when I start it, I get the exception shown in the title. Here’s the full backtrace:

23:55 $ dotnet run
Unhandled exception. System.InvalidOperationException: Could not find 'UserSecretsIdAttribute' on assembly 'System.Private.CoreLib'.
Check that the project for 'System.Private.CoreLib' has set the 'UserSecretsId' build property.
If the 'UserSecretsId' property is already set then add a reference to the Microsoft.Extensions.Configuration.UserSecrets package.
   at Microsoft.Extensions.Configuration.UserSecretsConfigurationExtensions.AddUserSecrets(IConfigurationBuilder configuration, Assembly assembly, Boolean optional, Boolean reloadOnChange)
   at Microsoft.Extensions.Configuration.UserSecretsConfigurationExtensions.AddUserSecrets[T](IConfigurationBuilder configuration)
   at GinghamStreet.Shopify.IntegrationApi.App.configureServices(IServiceCollection services) in /Users/ben/proj/c9/gssext/src/GinghamStreet.Shopify.IntegrationApi/Program.fs:line 116
   at GinghamStreet.Shopify.IntegrationApi.App.main@141-1.Invoke(IServiceCollection delegateArg0) in /Users/ben/proj/c9/gssext/src/GinghamStreet.Shopify.IntegrationApi/Program.fs:line 141
   at Microsoft.AspNetCore.Hosting.WebHostBuilder.<>c__DisplayClass10_0.<ConfigureServices>b__0(WebHostBuilderContext _, IServiceCollection services)
   at Microsoft.AspNetCore.Hosting.WebHostBuilder.BuildCommonServices(AggregateException& hostingStartupErrors)
   at Microsoft.AspNetCore.Hosting.WebHostBuilder.Build()
   at GinghamStreet.Shopify.IntegrationApi.App.main(String[] _arg1) in /Users/ben/proj/c9/gssext/src/GinghamStreet.Shopify.IntegrationApi/Program.fs:line 134

At first I just used the dotnet tooling to set up user secrets: dotnet user-secrets init, which added the UserSecretsIdAttribute property to my .fsproj file; followed by a couple of dotnet user-secrets set "key:value" commands. When the above error was thrown when I tried to run at this point, I tried disabling AssemblyInfo generation with GenerateUserSecretsAttribute set to false and then writing my own AssemblyInfo.fs, but that didn’t change anything.

To Reproduce

Steps to reproduce the behavior:

  1. Using this version of ASP.NET Core: 3.0.0 with SDK 3.0.100 on macOS.
  2. Run this code: see attached zip
  3. See error

gssext.zip

Expected behavior

I expected to just run the dotnet user-secrets tools and have things work.

Additional context

01:23 $ dotnet --info
.NET Core SDK (reflecting any global.json):
 Version:   3.0.100
 Commit:    04339c3a26

Runtime Environment:
 OS Name:     Mac OS X
 OS Version:  10.14
 OS Platform: Darwin
 RID:         osx.10.14-x64
 Base Path:   /usr/local/share/dotnet/sdk/3.0.100/

Host (useful for support):
  Version: 3.0.0
  Commit:  7d57652f33

.NET Core SDKs installed:
  2.2.300 [/usr/local/share/dotnet/sdk]
  3.0.100 [/usr/local/share/dotnet/sdk]

.NET Core runtimes installed:
  Microsoft.AspNetCore.All 2.1.6 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.All]
  Microsoft.AspNetCore.All 2.1.7 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.All]
  Microsoft.AspNetCore.All 2.1.8 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.All]
  Microsoft.AspNetCore.All 2.1.9 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.All]
  Microsoft.AspNetCore.All 2.2.5 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.All]
  Microsoft.AspNetCore.App 2.1.6 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 2.1.7 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 2.1.8 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 2.1.9 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 2.2.5 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 3.0.0-preview4-19216-03 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 3.0.0-preview5-19227-01 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 3.0.0 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 2.1.6 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
  Microsoft.NETCore.App 2.1.7 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
  Microsoft.NETCore.App 2.1.8 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
  Microsoft.NETCore.App 2.1.9 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
  Microsoft.NETCore.App 2.2.5 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
  Microsoft.NETCore.App 3.0.0-preview4-27615-11 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
  Microsoft.NETCore.App 3.0.0-preview5-27626-15 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
  Microsoft.NETCore.App 3.0.0 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
Pilchiecommented, Oct 2, 2019

Also tagging @cartermp in case of something F# specific.

0reactions
msftbot[bot]commented, Jan 27, 2020

This issue has been automatically marked as stale because it has been marked as requiring author feedback but has not had any activity for 4 days. It will be closed if no further activity occurs within 3 days of this comment. If it is closed, feel free to comment when you are able to provide the additional information and we will re-investigate.

See our Issue Management Policies for more information.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Could not find 'UserSecretsIdAttribute' on assembly - ...
After deploying ASP.NET Core app to azure and opening the site, I get the following error: InvalidOperationException: Could not find ' ...
Read more >
Could not find 'UserSecretsIdAttribute' on assembly ...
Describe the bug This bug seems to me to be very similar to dotnet/aspnetcore#7649. I'm using F# with Giraffe to fiddle around with...
Read more >
Could not find 'UserSecretsIdAttribute' on assembly 'ef'
I am using ASP.NET Core 1.1 and I have the following on startup: ConfigurationBuilder builder = new ConfigurationBuilder(); builder.AddUserSecrets();.
Read more >
Could not find file (but file exists in the project)
Coding example for the question System.IO.FileNotFoundException: 'Could not find file (but file exists in the project)
Read more >
Azure Function and Entity Framework Sql Server error
I found this error to be reproducible. Create a new HTTP Trigger Azure Function, .NET 6. Add the below class to create a...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found